From f13b1accf66a2821768219050c72f5f910942a13 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 1 Apr 2022 10:21:53 -0400 Subject: [PATCH] Handle empty voices URL format --- mimic3-tts/mimic3_tts/__main__.py | 22 +++++++++++++++++----- mimic3-tts/mimic3_tts/tts.py | 6 +++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mimic3-tts/mimic3_tts/__main__.py b/mimic3-tts/mimic3_tts/__main__.py index f60a8b1..f51ec01 100644 --- a/mimic3-tts/mimic3_tts/__main__.py +++ b/mimic3-tts/mimic3_tts/__main__.py @@ -349,7 +349,11 @@ def process_line( for result in results: state.result_queue.put( - ResultToProcess(result=result, line=line, line_id=line_id,) + ResultToProcess( + result=result, + line=line, + line_id=line_id, + ) ) # Restore voice/speaker @@ -477,10 +481,14 @@ def get_args(): help="Format of stdin text (default: auto)", ) parser.add_argument( - "--voice", "-v", help="Name of voice (expected in /)", + "--voice", + "-v", + help="Name of voice (expected in /)", ) parser.add_argument( - "--speaker", "-s", help="Name or number of speaker (default: first speaker)", + "--speaker", + "-s", + help="Name or number of speaker (default: first speaker)", ) parser.add_argument( "--voices-dir", @@ -520,7 +528,9 @@ def get_args(): ) parser.add_argument( - "--noise-scale", type=float, help="Noise scale [0-1], default is 0.667", + "--noise-scale", + type=float, + help="Noise scale [0-1], default is 0.667", ) parser.add_argument( "--length-scale", @@ -528,7 +538,9 @@ def get_args(): help="Length scale (1.0 is default speed, 0.5 is 2x faster)", ) parser.add_argument( - "--noise-w", type=float, help="Variation in cadence [0-1], default is 0.8", + "--noise-w", + type=float, + help="Variation in cadence [0-1], default is 0.8", ) # Miscellaneous diff --git a/mimic3-tts/mimic3_tts/tts.py b/mimic3-tts/mimic3_tts/tts.py index 3cdbd00..412512c 100644 --- a/mimic3-tts/mimic3_tts/tts.py +++ b/mimic3-tts/mimic3_tts/tts.py @@ -69,7 +69,7 @@ class Mimic3Settings: voices_directories: typing.Optional[typing.Iterable[typing.Union[str, Path]]] = None """Directories to search for voices (/)""" - voices_url_format: str = DEFAULT_VOICES_URL_FORMAT + voices_url_format: typing.Optional[str] = DEFAULT_VOICES_URL_FORMAT """URL format string for a voice directory. May contain: @@ -238,7 +238,7 @@ class Mimic3TextToSpeechSystem(TextToSpeechSystem): description="", speakers=speakers, location=str.format( - self.settings.voices_url_format, + self.settings.voices_url_format or DEFAULT_VOICES_URL_FORMAT, lang=voice_lang, name=voice_name, key=voice_key, @@ -471,7 +471,7 @@ class Mimic3TextToSpeechSystem(TextToSpeechSystem): voice_lang, voice_name = voice_key.split("/", maxsplit=1) voice_info = _VOICES[voice_key] voice_url = str.format( - self.settings.voices_url_format, + self.settings.voices_url_format or DEFAULT_VOICES_URL_FORMAT, key=voice_key, lang=voice_lang, name=voice_name,