mirror of https://github.com/coqui-ai/TTS.git
refactor(api): use save_wav() from Synthesizer instance
This commit is contained in:
parent
89abd98620
commit
806af96e4c
11
TTS/api.py
11
TTS/api.py
|
@ -9,7 +9,6 @@ from typing import Optional
|
||||||
from torch import nn
|
from torch import nn
|
||||||
|
|
||||||
from TTS.config import load_config
|
from TTS.config import load_config
|
||||||
from TTS.utils.audio.numpy_transforms import save_wav
|
|
||||||
from TTS.utils.manage import ModelManager
|
from TTS.utils.manage import ModelManager
|
||||||
from TTS.utils.synthesizer import Synthesizer
|
from TTS.utils.synthesizer import Synthesizer
|
||||||
|
|
||||||
|
@ -394,6 +393,7 @@ class TTS(nn.Module):
|
||||||
source_wav: str,
|
source_wav: str,
|
||||||
target_wav: str,
|
target_wav: str,
|
||||||
file_path: str = "output.wav",
|
file_path: str = "output.wav",
|
||||||
|
pipe_out=None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Voice conversion with FreeVC. Convert source wav to target speaker.
|
"""Voice conversion with FreeVC. Convert source wav to target speaker.
|
||||||
|
|
||||||
|
@ -404,9 +404,11 @@ class TTS(nn.Module):
|
||||||
Path to the target wav file.
|
Path to the target wav file.
|
||||||
file_path (str, optional):
|
file_path (str, optional):
|
||||||
Output file path. Defaults to "output.wav".
|
Output file path. Defaults to "output.wav".
|
||||||
|
pipe_out (BytesIO, optional):
|
||||||
|
Flag to stdout the generated TTS wav file for shell pipe.
|
||||||
"""
|
"""
|
||||||
wav = self.voice_conversion(source_wav=source_wav, target_wav=target_wav)
|
wav = self.voice_conversion(source_wav=source_wav, target_wav=target_wav)
|
||||||
save_wav(wav=wav, path=file_path, sample_rate=self.voice_converter.vc_config.audio.output_sample_rate)
|
self.voice_converter.save_wav(wav=wav, path=file_path, pipe_out=pipe_out)
|
||||||
return file_path
|
return file_path
|
||||||
|
|
||||||
def tts_with_vc(
|
def tts_with_vc(
|
||||||
|
@ -459,6 +461,7 @@ class TTS(nn.Module):
|
||||||
file_path: str = "output.wav",
|
file_path: str = "output.wav",
|
||||||
speaker: str = None,
|
speaker: str = None,
|
||||||
split_sentences: bool = True,
|
split_sentences: bool = True,
|
||||||
|
pipe_out=None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Convert text to speech with voice conversion and save to file.
|
"""Convert text to speech with voice conversion and save to file.
|
||||||
|
|
||||||
|
@ -482,9 +485,11 @@ class TTS(nn.Module):
|
||||||
Split text into sentences, synthesize them separately and concatenate the file audio.
|
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
|
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.
|
applicable to the 🐸TTS models. Defaults to True.
|
||||||
|
pipe_out (BytesIO, optional):
|
||||||
|
Flag to stdout the generated TTS wav file for shell pipe.
|
||||||
"""
|
"""
|
||||||
wav = self.tts_with_vc(
|
wav = self.tts_with_vc(
|
||||||
text=text, language=language, speaker_wav=speaker_wav, speaker=speaker, split_sentences=split_sentences
|
text=text, language=language, speaker_wav=speaker_wav, speaker=speaker, split_sentences=split_sentences
|
||||||
)
|
)
|
||||||
save_wav(wav=wav, path=file_path, sample_rate=self.voice_converter.vc_config.audio.output_sample_rate)
|
self.voice_converter.save_wav(wav=wav, path=file_path, pipe_out=pipe_out)
|
||||||
return file_path
|
return file_path
|
||||||
|
|
Loading…
Reference in New Issue