mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Get the new piper module building on Linux
This commit is contained in:
parent
e38705ef5e
commit
848de725de
@ -15,7 +15,6 @@ from functools import partial
|
||||
from bypy.constants import LIBDIR, OUTPUT_DIR, PREFIX, python_major_minor_version
|
||||
from bypy.constants import SRC as CALIBRE_DIR
|
||||
from bypy.freeze import extract_extension_modules, fix_pycryptodome, freeze_python, is_package_dir, path_to_freeze_dir
|
||||
from bypy.pkgs.piper import copy_piper_dir
|
||||
from bypy.utils import create_job, get_dll_path, mkdtemp, parallel_build, py_compile, run, walk
|
||||
|
||||
j = os.path.join
|
||||
@ -41,8 +40,8 @@ def binary_includes():
|
||||
get_dll_path,
|
||||
('usb-1.0 mtp expat sqlite3 ffi z lzma openjp2 poppler dbus-1 iconv xml2 xslt jpeg png16'
|
||||
' webp webpmux webpdemux sharpyuv exslt ncursesw readline chm hunspell-1.7 hyphen'
|
||||
' icudata icui18n icuuc icuio stemmer gcrypt gpg-error uchardet graphite2'
|
||||
' brotlicommon brotlidec brotlienc zstd podofo ssl crypto deflate tiff'
|
||||
' icudata icui18n icuuc icuio stemmer gcrypt gpg-error uchardet graphite2 espeak-ng'
|
||||
' brotlicommon brotlidec brotlienc zstd podofo ssl crypto deflate tiff onnxruntime'
|
||||
' gobject-2.0 glib-2.0 gthread-2.0 gmodule-2.0 gio-2.0 dbus-glib-1').split()
|
||||
)) + [
|
||||
# debian/ubuntu for for some typical stupid reason use libpcre.so.3
|
||||
@ -112,11 +111,6 @@ def import_site_packages(srcdir, dest):
|
||||
shutil.copytree(f, j(dest, x), ignore=ignore_in_lib)
|
||||
|
||||
|
||||
def copy_piper(env):
|
||||
print('Copying piper...')
|
||||
copy_piper_dir(PREFIX, env.bin_dir)
|
||||
|
||||
|
||||
def copy_libs(env):
|
||||
print('Copying libs...')
|
||||
|
||||
@ -138,6 +132,9 @@ def copy_libs(env):
|
||||
dest = j(env.lib_dir, '..', 'libexec')
|
||||
os.mkdir(dest)
|
||||
shutil.copy2(os.path.join(QT_PREFIX, 'libexec', 'QtWebEngineProcess'), dest)
|
||||
dest = j(env.lib_dir, '..', 'share')
|
||||
os.mkdir(dest)
|
||||
shutil.copytree(os.path.join(PREFIX, 'share/espeak-ng-data'), os.path.join(dest, 'espeak-ng-data'))
|
||||
|
||||
|
||||
def copy_python(env, ext_dir):
|
||||
@ -262,7 +259,7 @@ def strip_files(files, argv_max=(256 * 1024)):
|
||||
|
||||
|
||||
def strip_binaries(env):
|
||||
files = {j(env.bin_dir, x) for x in os.listdir(env.bin_dir) if x != 'piper'} | {
|
||||
files = {j(env.bin_dir, x) for x in os.listdir(env.bin_dir)} | {
|
||||
x for x in {
|
||||
j(os.path.dirname(env.bin_dir), x) for x in os.listdir(env.bin_dir)} if os.path.exists(x)}
|
||||
for x in walk(env.lib_dir):
|
||||
@ -314,7 +311,6 @@ def main():
|
||||
env = Env()
|
||||
copy_libs(env)
|
||||
copy_python(env, ext_dir)
|
||||
copy_piper(env)
|
||||
build_launchers(env)
|
||||
if not args.skip_tests:
|
||||
run_tests(j(env.base, 'calibre-debug'), env.base)
|
||||
|
@ -1195,37 +1195,19 @@
|
||||
},
|
||||
{
|
||||
"name": "onnx",
|
||||
"comment": "This is newer than the version needed for the version of piper-phonemize to get it to build on macOS (see CMakeLists.txt in piper-phonemize)",
|
||||
"unix": {
|
||||
"filename": "onnx-1.20.2.tar.gz",
|
||||
"hash": "sha256:6780b0b4f11d22f30a827dbbd3bd626e85e9c48e98719e9a535eda543446eab8",
|
||||
"urls": ["https://github.com/microsoft/onnxruntime/archive/refs/tags/v1.20.2.tar.gz"]
|
||||
"filename": "onnx-1.22.1.tar.gz",
|
||||
"hash": "sha256:9eacbf624d6f7466da81d9beb4399cb8683808b15c1276b7cd56c6907bf59f77",
|
||||
"urls": ["https://github.com/microsoft/onnxruntime/archive/refs/tags/v1.22.1.tar.gz"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "piper-espeak",
|
||||
"comment": "This is the version needed for the version of piper-phonemize we use (see CMakeLists.txt in piper-phonemize)",
|
||||
"name": "espeak",
|
||||
"comment": "We need the espeak_TextToPhonemesWithTerminator() function. No release of espeak-ng with that function has been made yet, so use a commit that includes it",
|
||||
"unix": {
|
||||
"filename": "espeak-1.zip",
|
||||
"hash": "sha256:150fc955926a084a77ebe25c9e8287bde2e2a17bbf9b23a25c147b556837949f",
|
||||
"urls": ["https://github.com/rhasspy/espeak-ng/archive/0f65aa301e0d6bae5e172cc74197d32a6182200f.zip"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "piper-phonemize",
|
||||
"comment": "This is the version needed for the version of piper we use (see CMakeLists.txt in piper)",
|
||||
"unix": {
|
||||
"filename": "piper-phonemize-1.zip",
|
||||
"hash": "sha256:cc57a4a00a0f5bd50555a93c94c0622da065a2a90b9c896bfbe8b45519e2e9c2",
|
||||
"urls": ["https://github.com/rhasspy/piper-phonemize/archive/bfc2e7549957829b0227c66a305d11cc88167bda.zip"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "piper",
|
||||
"unix": {
|
||||
"filename": "piper-2023.11.14.tar.gz",
|
||||
"hash": "sha256:8b684e102cfe23af097830db9555a8641f17735725853c531a1daeb34b6ed1a8",
|
||||
"urls": ["https://github.com/rhasspy/piper/archive/refs/tags/2023.11.14-2.tar.gz"]
|
||||
"filename": "espeak-a4ca101.zip",
|
||||
"hash": "sha256:3cbbd7bb84bc9b4391c3f3bb86750094a38f4bd6fcdc4fda7e2516d2955d3366",
|
||||
"urls": ["https://github.com/espeak-ng/espeak-ng/archive/a4ca101c99de35345f89df58195b2159748b7092.zip"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -59,7 +59,9 @@ def load_voice_config(path: str) -> VoiceConfig:
|
||||
|
||||
|
||||
def espeak_data_dir() -> str:
|
||||
return '' # TODO: get the correct path when using frozen builds
|
||||
if not getattr(sys, 'frozen', False):
|
||||
return ''
|
||||
return os.path.join(sys.executables_location, 'share', 'espeak-ng-data')
|
||||
|
||||
|
||||
def create_voice_config(config_path: str, length_scale_multiplier: float = 0, sentence_delay: float = 0.2) -> VoiceConfig:
|
||||
@ -84,10 +86,13 @@ class SynthesisResult(NamedTuple):
|
||||
|
||||
|
||||
def simple_test():
|
||||
piper.initialize(espeak_data_dir())
|
||||
d = espeak_data_dir()
|
||||
if d and not os.path.exists(os.path.join(d, 'voices')):
|
||||
raise AssertionError(f'{d} does not contain espeak-ng data')
|
||||
piper.initialize(d)
|
||||
piper.set_espeak_voice_by_name('en-us')
|
||||
if not piper.phonemize('simple test'):
|
||||
raise ValueError('No phonemes returned by phonemize()')
|
||||
raise AssertionError('No phonemes returned by phonemize()')
|
||||
|
||||
|
||||
class Piper(Thread):
|
||||
|
Loading…
x
Reference in New Issue
Block a user