Skip to content

Commit 69d5a23

Browse files
committed
refactor(api): use save_wav() from Synthesizer instance
1 parent 71426ea commit 69d5a23

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

TTS/api.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from torch import nn
1010

1111
from TTS.config import load_config
12-
from TTS.utils.audio.numpy_transforms import save_wav
1312
from TTS.utils.manage import ModelManager
1413
from TTS.utils.synthesizer import Synthesizer
1514

@@ -394,6 +393,7 @@ def voice_conversion_to_file(
394393
source_wav: str,
395394
target_wav: str,
396395
file_path: str = "output.wav",
396+
pipe_out=None,
397397
) -> str:
398398
"""Voice conversion with FreeVC. Convert source wav to target speaker.
399399
@@ -404,9 +404,11 @@ def voice_conversion_to_file(
404404
Path to the target wav file.
405405
file_path (str, optional):
406406
Output file path. Defaults to "output.wav".
407+
pipe_out (BytesIO, optional):
408+
Flag to stdout the generated TTS wav file for shell pipe.
407409
"""
408410
wav = self.voice_conversion(source_wav=source_wav, target_wav=target_wav)
409-
save_wav(wav=wav, path=file_path, sample_rate=self.voice_converter.vc_config.audio.output_sample_rate)
411+
self.voice_converter.save_wav(wav=wav, path=file_path, pipe_out=pipe_out)
410412
return file_path
411413

412414
def tts_with_vc(
@@ -459,6 +461,7 @@ def tts_with_vc_to_file(
459461
file_path: str = "output.wav",
460462
speaker: str = None,
461463
split_sentences: bool = True,
464+
pipe_out=None,
462465
) -> str:
463466
"""Convert text to speech with voice conversion and save to file.
464467
@@ -482,9 +485,11 @@ def tts_with_vc_to_file(
482485
Split text into sentences, synthesize them separately and concatenate the file audio.
483486
Setting it False uses more VRAM and possibly hit model specific text length or VRAM limits. Only
484487
applicable to the 🐸TTS models. Defaults to True.
488+
pipe_out (BytesIO, optional):
489+
Flag to stdout the generated TTS wav file for shell pipe.
485490
"""
486491
wav = self.tts_with_vc(
487492
text=text, language=language, speaker_wav=speaker_wav, speaker=speaker, split_sentences=split_sentences
488493
)
489-
save_wav(wav=wav, path=file_path, sample_rate=self.voice_converter.vc_config.audio.output_sample_rate)
494+
self.voice_converter.save_wav(wav=wav, path=file_path, pipe_out=pipe_out)
490495
return file_path

0 commit comments

Comments
 (0)