mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-05-29 10:12:34 -04:00
Start work on getting rid of piper code and only using the model data
The inference code if a few hundred lines anyway, piper is unmaintained and forked and the fork depends on the gigantic python ONNXRuntime bindings. Just write the few hundred lines myself.
This commit is contained in:
@@ -153,6 +153,8 @@ uchardet_inc_dirs, uchardet_lib_dirs, uchardet_libs = [], [], ['uchardet']
|
||||
|
||||
openssl_inc_dirs, openssl_lib_dirs = [], []
|
||||
|
||||
piper_inc_dirs, piper_lib_dirs, piper_libs = [], [], []
|
||||
|
||||
ICU = sw = ''
|
||||
|
||||
if iswindows:
|
||||
@@ -211,6 +213,10 @@ else:
|
||||
uchardet_inc_dirs = pkgconfig_include_dirs('uchardet', '', '/usr/include/uchardet')
|
||||
uchardet_lib_dirs = pkgconfig_lib_dirs('uchardet', '', '/usr/lib')
|
||||
uchardet_libs = pkgconfig_libs('uchardet', '', '')
|
||||
piper_inc_dirs = pkgconfig_include_dirs('espeak-ng', '', '/usr/include') + pkgconfig_include_dirs(
|
||||
'libonnxruntime', '', '/usr/include/onnxruntime')
|
||||
piper_lib_dirs = pkgconfig_lib_dirs('espeak-ng', '', '/usr/lib') + pkgconfig_lib_dirs('libonnxruntime', '', '/usr/lib')
|
||||
piper_libs = pkgconfig_libs('espeak-ng', '', 'espeak-ng') + pkgconfig_libs('libonnxruntime', '', 'onnxruntime')
|
||||
for x in ('libavcodec', 'libavformat', 'libavdevice', 'libavfilter', 'libavutil', 'libpostproc', 'libswresample', 'libswscale'):
|
||||
for inc in pkgconfig_include_dirs(x, '', '/usr/include'):
|
||||
if inc and inc not in ffmpeg_inc_dirs:
|
||||
|
||||
@@ -134,6 +134,14 @@
|
||||
"error": "!podofo_error",
|
||||
"needs_c++": "17"
|
||||
},
|
||||
{
|
||||
"name": "piper",
|
||||
"sources": "calibre/utils/tts/piper.cpp",
|
||||
"needs_c++": "17",
|
||||
"libraries": "!piper_libs",
|
||||
"lib_dirs": "!piper_lib_dirs",
|
||||
"inc_dirs": "!piper_inc_dirs"
|
||||
},
|
||||
{
|
||||
"name": "html_as_json",
|
||||
"sources": "calibre/srv/html_as_json.cpp",
|
||||
|
||||
@@ -258,6 +258,7 @@ class ExtensionsImporter:
|
||||
'rcc_backend',
|
||||
'icu',
|
||||
'speedup',
|
||||
'piper',
|
||||
'html_as_json',
|
||||
'fast_css_transform',
|
||||
'fast_html_entities',
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* piper.cpp
|
||||
* Copyright (C) 2025 Kovid Goyal <kovid at kovidgoyal.net>
|
||||
*
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
#include <Python.h>
|
||||
#include <espeak-ng/speak_lib.h>
|
||||
|
||||
static PyObject*
|
||||
phonemize(PyObject *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
// Boilerplate {{{
|
||||
static char doc[] = "Text to speech using the Piper TTS models";
|
||||
static PyMethodDef methods[] = {
|
||||
{"phonemize", (PyCFunction)phonemize, METH_VARARGS,
|
||||
"Convert the specified text into espeak-ng phonemes"
|
||||
},
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
static int
|
||||
exec_module(PyObject *mod) { return 0; }
|
||||
|
||||
static PyModuleDef_Slot slots[] = { {Py_mod_exec, (void*)exec_module}, {0, NULL} };
|
||||
|
||||
static struct PyModuleDef module_def = {PyModuleDef_HEAD_INIT};
|
||||
|
||||
CALIBRE_MODINIT_FUNC PyInit_piper(void) {
|
||||
module_def.m_name = "piper";
|
||||
module_def.m_slots = slots;
|
||||
module_def.m_doc = doc;
|
||||
module_def.m_methods = methods;
|
||||
return PyModuleDef_Init(&module_def);
|
||||
}
|
||||
// }}}
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2025, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
import calibre_extensions.piper as piper
|
||||
|
||||
piper
|
||||
Reference in New Issue
Block a user