From db6dfa93205eae9c9fb2950fa8a5b2d8036953b5 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Sat, 23 Apr 2022 17:39:38 -0400 Subject: [PATCH] Get Docker-based dist build to work --- .dockerignore | 11 +++++++ check.sh | 2 +- mimic3-http/mimic3_http/app.py | 16 +++++++--- mimic3-http/mimic3_http/const.py | 4 +++ mimic3-tts/mimic3_tts/voices.json | 52 +++++++++++++++++++++++++++++++ tests/sample_hashes.txt | 31 ++++++++++++++++++ 6 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 tests/sample_hashes.txt diff --git a/.dockerignore b/.dockerignore index 7570c5f..505d68c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,17 @@ * !LICENSE !install.sh +!build-dist.sh +!check.sh +!requirements_dev.txt +!.isort.cfg +!pylintrc +!setup.cfg !pyinstaller/*.py !pyinstaller/mimic3-server !pyinstaller/mimic3-download +!tests/*.py +!tests/sample_hashes.txt # opentts-abc !opentts-abc/setup.py @@ -11,6 +19,7 @@ !opentts-abc/MANIFEST.in !opentts-abc/opentts_abc/*.py !opentts-abc/opentts_abc/VERSION +!opentts-abc/opentts_abc/py.typed # Mimic 3 TTS !mimic3-tts/setup.py @@ -20,6 +29,7 @@ !mimic3-tts/mimic3_tts/*.py !mimic3-tts/mimic3_tts/voices.json !mimic3-tts/mimic3_tts/VERSION +!mimic3-tts/mimic3_tts/py.typed # HTTP server !mimic3-http/setup.py @@ -31,3 +41,4 @@ !mimic3-http/mimic3_http/templates/ !mimic3-http/mimic3_http/*.py !mimic3-http/mimic3_http/VERSION +!mimic3-http/mimic3_http/py.typed diff --git a/check.sh b/check.sh index 457ab13..1cb6fe3 100755 --- a/check.sh +++ b/check.sh @@ -24,7 +24,7 @@ set -eo pipefail this_dir="$( cd "$( dirname "$0" )" && pwd )" # Path to virtual environment -: "${venv:=${base_dir}/.venv}" +: "${venv:=${this_dir}/.venv}" if [ -d "${venv}" ]; then # Activate virtual environment if available diff --git a/mimic3-http/mimic3_http/app.py b/mimic3-http/mimic3_http/app.py index b3ff6e6..33f175f 100644 --- a/mimic3-http/mimic3_http/app.py +++ b/mimic3-http/mimic3_http/app.py @@ -100,6 +100,7 @@ def get_app(args: argparse.Namespace, request_queue: Queue, temp_dir: str): if _TEMP_DIR and (not no_cache): # Store in cache wav_path = _TEMP_DIR / f"{params.cache_key}.wav" + wav_path.parent.mkdir(parents=True, exist_ok=True) wav_path.write_bytes(wav_bytes) _LOGGER.debug("Cached WAV at %s", wav_path.absolute()) @@ -170,28 +171,33 @@ def get_app(args: argparse.Namespace, request_queue: Queue, temp_dir: str): # TTS settings noise_scale = request.args.get("noiseScale") - if noise_scale is not None: + if noise_scale: tts_args["noise_scale"] = float(noise_scale) noise_w = request.args.get("noiseW") - if noise_w is not None: + if noise_w: tts_args["noise_w"] = float(noise_w) length_scale = request.args.get("lengthScale") - if length_scale is not None: + if length_scale: tts_args["length_scale"] = float(length_scale) # Set SSML flag either from arg or content type ssml_str = request.args.get("ssml") - if ssml_str is not None: + if ssml_str: tts_args["ssml"] = _to_bool(ssml_str) elif request.content_type == "application/ssml+xml": tts_args["ssml"] = True text_language = request.args.get("textLanguage") - if text_language is not None: + if text_language: tts_args["text_language"] = str(text_language) + # Id used for cache + cache_id = request.args.get("cacheId") + if cache_id: + tts_args["cache_id"] = str(cache_id) + # Text can come from POST body or GET ?text arg if request.method == "POST": text = (await request.data).decode() diff --git a/mimic3-http/mimic3_http/const.py b/mimic3-http/mimic3_http/const.py index 08d613f..6ecce06 100644 --- a/mimic3-http/mimic3_http/const.py +++ b/mimic3-http/mimic3_http/const.py @@ -30,9 +30,13 @@ class TextToWavParams: length_scale: float ssml: bool = False text_language: typing.Optional[str] = None + cache_id: typing.Optional[str] = None @property def cache_key(self) -> str: + if self.cache_id: + return self.cache_id + return hashlib.md5(repr(self).encode()).hexdigest() diff --git a/mimic3-tts/mimic3_tts/voices.json b/mimic3-tts/mimic3_tts/voices.json index 74cfd45..9e02338 100644 --- a/mimic3-tts/mimic3_tts/voices.json +++ b/mimic3-tts/mimic3_tts/voices.json @@ -1,4 +1,52 @@ { + "af_ZA/google_nwu": { + "files": { + "LICENSE": { + "size_bytes": 56, + "sha256_sum": "9de32c12fbae55d90964a887d50116a3369962799532fcd7663d32f55c1945fe" + }, + "README.md": { + "size_bytes": 186, + "sha256_sum": "14ef9a5565a8b73cf7460098b181268ce1e638c6feb7065dc3544f038f1d20ab" + }, + "SOURCE": { + "size_bytes": 27, + "sha256_sum": "8a9a0d5d775c0264004b68c4ca850fd51c3d8e63cdbc9df61ec257a3ee97e025" + }, + "config.json": { + "size_bytes": 3881, + "sha256_sum": "3f7c44b4ad3ca0bd5aad619f9920d25676f8b02f8a936b9c84fcaa272c0b0935" + }, + "generator.onnx": { + "size_bytes": 76351329, + "sha256_sum": "8366e03683ea3c15f25ba0163aa1b6e87c1692674cf27b1fb6ba479dbef7e0bb" + }, + "phonemes.txt": { + "size_bytes": 322, + "sha256_sum": "fab165ba2b5d964f994f0917abb14307f8ef49310dbd40d262a7488461efc9d4" + }, + "speaker_map.csv": { + "size_bytes": 189, + "sha256_sum": "29dd47e2acc3bf107beb717a86ec02410298fe477803277eabcbaab0011bea5a" + }, + "speakers.txt": { + "size_bytes": 45, + "sha256_sum": "672a1a0b000c2acc51d43b2544ce27e8c3c2f08fa03bd67b73eca3fdf2952a37" + } + }, + "speakers": [ + "7214", + "8963", + "7130", + "8924", + "8148", + "1919", + "2418", + "6590", + "0184" + ], + "properties": {} + }, "de_DE/m-ailabs_low": { "files": { "ALIASES": { @@ -57,6 +105,10 @@ "size_bytes": 31, "sha256_sum": "19b4afb2e1c2c9f2cb07da14acd2d34098a4e11c13fccb09356845c4748fb50c" }, + "README.md": { + "size_bytes": 178, + "sha256_sum": "f8e51cdf7e7907ae3ac8ed45c017fb64aea318ae3e2eeb2d4259ed7e333f9c1f" + }, "SOURCE": { "size_bytes": 28, "sha256_sum": "f351b9304a8fa1e6e58db9b3411f92387e192bb4b57fcbe3e8f839424b13f3c8" diff --git a/tests/sample_hashes.txt b/tests/sample_hashes.txt new file mode 100644 index 0000000..7746a1b --- /dev/null +++ b/tests/sample_hashes.txt @@ -0,0 +1,31 @@ +de_DE/m-ailabs_low eafcf586b582c5ffb58c373a62e34c2e35d3b4b5d9d49288dabfacb50bc4fa8c +de_DE/thorsten-emotion_low d7b765c4cc18364023b1e50d4cef1fc6b6d5a780ea1713d2a6ed60459dcbd02e +de_DE/thorsten_low 60967155b319d1a78c2dade56a4f484cf6996c506f2d24b95dad717fafdad302 +el_GR/rapunzelina_low 2c4f8001209df4d26dbc039b92144af484a8f0a2b54bb3483df6b7764f982306 +en_UK/apope_low 9970bf35456f8deeec8ed17a3033772213ef9241da4c2d46bd24a2a4a65f723c +en_US/cmu-arctic_low cffe215aede2980608ef6b98dfe508681a8bd146899f679203c023efd1cd9e81 +en_US/ljspeech_low 7b8ca151b5bcf4a222ab87596691ff9656f4d93df63392d79997c265770392c3 +en_US/m-ailabs_low 6b49d85817d3db962a237df68ba9b81012f0d1ac2881e691940e9327872bdb1f +en_US/vctk_low 0a35e6bf4e3ee07a39d8cdf7a2cda76870f4c9a0acace2ec2d940b1d4c2b6ed5 +es_ES/carlfm_low 31fa1c7343ac08ae1e5084ced180c8ec6334f5f39d743b46857e0baf7f668a6e +es_ES/m-ailabs_low 8bf16f67ad6b86c2006fbc9da5d42b6b70090550672139093dd39eee0be9ae22 +fa/haaniye_low 8157477b0d75cd234815275d79ea7b58a71c39cacda63b4157e062f7e35b4e10 +fi_FI/harri-tapani-ylilammi_low 743c357c0b59fc9fa24ad2943a224c7850db533b40b9c2d68f0e00c395c965c4 +fr_FR/m-ailabs_low 4b1770b7429c8b3a9faf4d452ac99c3c0360d420a1bbc6551bf1437d9627bd2d +fr_FR/siwis_low 2103220387acb0774586f581b61780275abd1bc3ca54df070273471153291b92 +fr_FR/tom_low b2d59d6484a6e3850f0cd81c2287cab674085c7185e553dfd3852a81d918d2d6 +hu_HU/diana-majlinger_low 80b33323d8693344f736db16663aefd3dcd60086bdecfe2b02e7605aeb4f4c47 +it_IT/mls_low ee2fd9bfb3a8dad8ca8d38e680e26c93c8bc9103727c7dc58a822fe14c851a6e +it_IT/riccardo-fasol_low 0f37384de1a5ae2f703d2a70cdf0fc141988470a24210b8812e3574c7bfdbfa1 +ko_KO/kss_low 0be2ad36bcb3446eb8d8171884bc6ddd5a6cd63eb999d75728feec4aadd79c43 +nl/bart-de-leeuw_low 99ef4919da457f26908fac379a6590d074969dadda562175a5485c48a8eeed0d +nl/flemishguy_low 1a4841b613069edf9c27bebdbe594a403cfe133c34a9eeddf29a266bc2f9169c +nl/nathalie_low f3708f40f2befbb66f319c0c0c7d81bd561fa6404571f0ddb90418d81f1559d8 +nl/pmk_low 2e57b1aa048e6168f9a4e389f1fa1475ff2f47309e8fd285311610711491ffa6 +nl/rdh_low e3794ead9fbaff022ab61ac0fce164da375e0017bc0e741abad92f08a11d4e55 +ru_RU/multi_low 1c328bf9f9d0c57ddff0af01b3b3448ed514ad074ea2361c510905ec564ba40b +sw/lanfrica_low 26560985c67d6a31cafa685ef05681748dfec06bee238136b4a249d87d491926 +te_IN/cmu-indic_low dd19e3e73ec948c6df9d296d9826c98c451ba9e1a83d1c69e169e28313614f0a +uk_UK/m-ailabs_low 9f6b3805843c8f5b1f4edc995f489d62712e9976219924c1ba1bae3c9e7e6754 +vi_VN/vais1000_low cb9d79e8a35a6ce218f69d4645c4b6c0f1a0cfa4a228272e73130a6980667ae5 +yo/crowdsourced_low dd3de28e18ae19cffac43ddb100a42520b3a55b0458e9e2df2145c656d9cd5fb