9
9
from torch import nn
10
10
11
11
from TTS .config import load_config
12
- from TTS .utils .audio .numpy_transforms import save_wav
13
12
from TTS .utils .manage import ModelManager
14
13
from TTS .utils .synthesizer import Synthesizer
15
14
@@ -394,6 +393,7 @@ def voice_conversion_to_file(
394
393
source_wav : str ,
395
394
target_wav : str ,
396
395
file_path : str = "output.wav" ,
396
+ pipe_out = None ,
397
397
) -> str :
398
398
"""Voice conversion with FreeVC. Convert source wav to target speaker.
399
399
@@ -404,9 +404,11 @@ def voice_conversion_to_file(
404
404
Path to the target wav file.
405
405
file_path (str, optional):
406
406
Output file path. Defaults to "output.wav".
407
+ pipe_out (BytesIO, optional):
408
+ Flag to stdout the generated TTS wav file for shell pipe.
407
409
"""
408
410
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 )
410
412
return file_path
411
413
412
414
def tts_with_vc (
@@ -459,6 +461,7 @@ def tts_with_vc_to_file(
459
461
file_path : str = "output.wav" ,
460
462
speaker : str = None ,
461
463
split_sentences : bool = True ,
464
+ pipe_out = None ,
462
465
) -> str :
463
466
"""Convert text to speech with voice conversion and save to file.
464
467
@@ -482,9 +485,11 @@ def tts_with_vc_to_file(
482
485
Split text into sentences, synthesize them separately and concatenate the file audio.
483
486
Setting it False uses more VRAM and possibly hit model specific text length or VRAM limits. Only
484
487
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.
485
490
"""
486
491
wav = self .tts_with_vc (
487
492
text = text , language = language , speaker_wav = speaker_wav , speaker = speaker , split_sentences = split_sentences
488
493
)
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 )
490
495
return file_path
0 commit comments