Add HTTP endpoint argument for which text pipeline to use

This commit is contained in:
Brandon Thomas
2022-07-06 02:26:35 -04:00
parent 551b2670bb
commit b4a24ff561
2 changed files with 9 additions and 6 deletions
+7 -6
View File
@@ -91,15 +91,15 @@ def load_hifigan_model(checkpoint_path, super_resolution = False):
ENGLISH_PIPELINE_V1 = EnglishPipelineV1(EnglishPhonetization(CMUDict(DEFAULT_CMUDICT_PATH)))
LEGACY_FAKEYOU_PIPELINE = LegacyFakeYouPipeline()
def preprocess_text(raw_user_text: str):
def preprocess_text(raw_user_text: str, text_pipeline_type: str):
integer_sequence = []
# TODO/NB: This word-based flag is for testing the rollout
if "this" in raw_user_text:
print("\n\n>>> ENGLISH V1\n\n")
if text_pipeline_type == 'legacy_fakeyou':
integer_sequence = LEGACY_FAKEYOU_PIPELINE.user_input_to_sequence(raw_user_text)
elif text_pipeline_type == 'english_v1':
integer_sequence = ENGLISH_PIPELINE_V1.user_input_to_sequence(raw_user_text)
else:
print("\n\n>>> LEGACY\n\n")
# TODO: Fall back to the newest pipeline once server code has been deployed.
integer_sequence = LEGACY_FAKEYOU_PIPELINE.user_input_to_sequence(raw_user_text)
with torch.no_grad():
@@ -264,6 +264,7 @@ class TacotronWaveglowPipeline:
def infer(self, args):
assert('synthesizer_checkpoint_path' in args)
assert('vocoder_type' in args)
assert('text_pipeline_type' in args)
assert('raw_text' in args)
assert('output_audio_filename' in args)
assert('output_spectrogram_filename' in args)
@@ -271,7 +272,7 @@ class TacotronWaveglowPipeline:
print('Raw text: {}'.format(args['raw_text']))
sequence = preprocess_text(args['raw_text'])
sequence = preprocess_text(args['raw_text'], args['text_pipeline_type'])
tacotron = self.tacotron_model_cache[args['synthesizer_checkpoint_path']]
+2
View File
@@ -210,6 +210,7 @@ class ApiHandler():
# Request parameters
synthesizer_checkpoint_path = raw_data.get('synthesizer_checkpoint_path')
text_pipeline_type = raw_data.get('text_pipeline_type')
vocoder_type = raw_data.get('vocoder_type')
waveglow_vocoder_checkpoint_path = raw_data.get('waveglow_vocoder_checkpoint_path')
hifigan_vocoder_checkpoint_path = raw_data.get('hifigan_vocoder_checkpoint_path')
@@ -224,6 +225,7 @@ class ApiHandler():
raw_data.get('maybe_clear_synthesizer_checkpoint_path')
print('synthesizer_checkpoint_path: {}'.format(synthesizer_checkpoint_path))
print('text_pipeline_type: {}'.format(text_pipeline_type))
print('vocoder_type: {}'.format(vocoder_type))
print('waveglow_vocoder_checkpoint_path: {}'.format(waveglow_vocoder_checkpoint_path))
print('hifigan_vocoder_checkpoint_path: {}'.format(hifigan_vocoder_checkpoint_path))