Skip to content

Commit

Permalink
Configurable verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiri committed Jul 8, 2023
1 parent 672ec3b commit 9bae7e0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions TTS/utils/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def tts(
style_text=None,
reference_wav=None,
reference_speaker_name=None,
verbose: bool = True,
**kwargs,
) -> List[int]:
"""🐸 TTS magic. Run all the models and generate speech.
Expand All @@ -270,6 +271,7 @@ def tts(
style_text ([type], optional): transcription of style_wav for Capacitron. Defaults to None.
reference_wav ([type], optional): reference waveform for voice conversion. Defaults to None.
reference_speaker_name ([type], optional): speaker id of reference waveform. Defaults to None.
verbose (bool, optional): print verbose output. Defaults to True.
Returns:
List[int]: [description]
"""
Expand All @@ -283,8 +285,9 @@ def tts(

if text:
sens = self.split_into_sentences(text)
print(" > Text splitted to sentences.")
print(sens)
if verbose:
print(" > Text splitted to sentences.")
print(sens)

# handle multi-speaker
if "voice_dir" in kwargs:
Expand Down Expand Up @@ -397,7 +400,8 @@ def tts(
self.vocoder_config["audio"]["sample_rate"] / self.tts_model.ap.sample_rate,
]
if scale_factor[1] != 1:
print(" > interpolating tts model output.")
if verbose:
print(" > interpolating tts model output.")
vocoder_input = interpolate_vocoder_input(scale_factor, vocoder_input)
else:
vocoder_input = torch.tensor(vocoder_input).unsqueeze(0) # pylint: disable=not-callable
Expand Down Expand Up @@ -462,7 +466,8 @@ def tts(
self.vocoder_config["audio"]["sample_rate"] / self.tts_model.ap.sample_rate,
]
if scale_factor[1] != 1:
print(" > interpolating tts model output.")
if verbose:
print(" > interpolating tts model output.")
vocoder_input = interpolate_vocoder_input(scale_factor, vocoder_input)
else:
vocoder_input = torch.tensor(vocoder_input).unsqueeze(0) # pylint: disable=not-callable
Expand All @@ -475,9 +480,10 @@ def tts(
waveform = waveform.numpy()
wavs = waveform.squeeze()

# compute stats
process_time = time.time() - start_time
audio_time = len(wavs) / self.tts_config.audio["sample_rate"]
print(f" > Processing time: {process_time}")
print(f" > Real-time factor: {process_time / audio_time}")
if verbose:
# compute stats
process_time = time.time() - start_time
audio_time = len(wavs) / self.tts_config.audio["sample_rate"]
print(f" > Processing time: {process_time}")
print(f" > Real-time factor: {process_time / audio_time}")
return wavs

0 comments on commit 9bae7e0

Please sign in to comment.