Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix console output issue in tts function of synthesizer class #3973

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion TTS/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def models(self):

@property
def is_multi_speaker(self):
if hasattr(self.synthesizer.tts_model, "speaker_manager") and self.synthesizer.tts_model.speaker_manager:
if hasattr(self.synthesizer.tts_model, "speaker_Smanager") and self.synthesizer.tts_model.speaker_manager:
return self.synthesizer.tts_model.speaker_manager.num_speakers > 1
return False

Expand Down Expand Up @@ -243,6 +243,7 @@ def tts(
emotion: str = None,
speed: float = None,
split_sentences: bool = True,
SuppresPrintStatements: bool = False,
**kwargs,
):
"""Convert text to speech.
Expand All @@ -267,6 +268,9 @@ def tts(
Split text into sentences, synthesize them separately and concatenate the file audio.
Setting it False uses more VRAM and possibly hit model specific text length or VRAM limits. Only
applicable to the 🐸TTS models. Defaults to True.
SuppresPrintStatements (bool, optional):
Suppress All the Print statements so that when runnging the function in thread the print statement will not apears in the terminal.
Setting it to True will suppress the print statements
kwargs (dict, optional):
Additional arguments for the model.
"""
Expand All @@ -283,6 +287,7 @@ def tts(
style_text=None,
reference_speaker_name=None,
split_sentences=split_sentences,
SuppresPrintStatements=SuppresPrintStatements,
**kwargs,
)
return wav
Expand Down
19 changes: 13 additions & 6 deletions TTS/utils/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def tts(
reference_wav=None,
reference_speaker_name=None,
split_sentences: bool = True,
SuppresPrintStatements: bool= False,
**kwargs,
) -> List[int]:
"""🐸 TTS magic. Run all the models and generate speech.
Expand All @@ -279,6 +280,7 @@ def tts(
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.
split_sentences (bool, optional): split the input text into sentences. Defaults to True.
SuppresPrintStatements (bool, optional): Suppress the Print statements.
**kwargs: additional arguments to pass to the TTS model.
Returns:
List[int]: [description]
Expand All @@ -294,9 +296,11 @@ def tts(
if text:
sens = [text]
if split_sentences:
print(" > Text splitted to sentences.")
if not SuppresPrintStatements:
print(" > Text splitted to sentences.")
sens = self.split_into_sentences(text)
print(sens)
if not SuppresPrintStatements:
print(sens)

# handle multi-speaker
if "voice_dir" in kwargs:
Expand Down Expand Up @@ -420,7 +424,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 not SuppresPrintStatements:
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 @@ -484,7 +489,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 not SuppresPrintStatements:
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 @@ -500,6 +506,7 @@ def tts(
# 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 not SuppresPrintStatements:
print(f" > Processing time: {process_time}")
print(f" > Real-time factor: {process_time / audio_time}")
return wavs
Loading