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

Handle speed #3672

Closed
wants to merge 10 commits 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
2 changes: 2 additions & 0 deletions TTS/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def tts(
style_text=None,
reference_speaker_name=None,
split_sentences=split_sentences,
speed=1.0,
**kwargs,
)
return wav
Expand Down Expand Up @@ -337,6 +338,7 @@ def tts_to_file(
language=language,
speaker_wav=speaker_wav,
split_sentences=split_sentences,
speed=speed,
**kwargs,
)
self.synthesizer.save_wav(wav=wav, path=file_path, pipe_out=pipe_out)
Expand Down
5 changes: 4 additions & 1 deletion TTS/tts/models/xtts.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def get_conditioning_latents(

return gpt_cond_latents, speaker_embedding

def synthesize(self, text, config, speaker_wav, language, speaker_id=None, **kwargs):
def synthesize(self, text, config, speaker_wav, language, speaker_id=None, speed=1.0, **kwargs):
"""Synthesize speech with the given input text.

Args:
Expand Down Expand Up @@ -436,6 +436,7 @@ def full_inference(
gpt_cond_chunk_len=6,
max_ref_len=10,
sound_norm_refs=False,
speed=1.0,
**hf_generate_kwargs,
):
"""
Expand Down Expand Up @@ -484,6 +485,7 @@ def full_inference(
max_ref_length=max_ref_len,
sound_norm_refs=sound_norm_refs,
)
self.speed = speed

return self.inference(
text,
Expand Down Expand Up @@ -518,6 +520,7 @@ def inference(
enable_text_splitting=False,
**hf_generate_kwargs,
):
speed = self.speed
language = language.split("-")[0] # remove the country code
length_scale = 1.0 / max(speed, 0.05)
gpt_cond_latent = gpt_cond_latent.to(self.device)
Expand Down
2 changes: 2 additions & 0 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,
speed=1.0,
**kwargs,
) -> List[int]:
"""🐸 TTS magic. Run all the models and generate speech.
Expand Down Expand Up @@ -391,6 +392,7 @@ def tts(
d_vector=speaker_embedding,
speaker_wav=speaker_wav,
language=language_name,
speed=speed,
**kwargs,
)
else:
Expand Down
Loading