Files
FABLE/generators/speak.py

23 lines
609 B
Python
Raw Normal View History

2023-05-15 10:11:04 +02:00
from TTS.api import TTS
import os
# Running a multi-speaker and multi-lingual model
# List available 🐸TTS models and choose the first one
model_best_multi = "tts_models/en/vctk/vits"
fakenames = {
"Alexander": "p230",
"Benjamin": "p240",
"Amelia": "p270",
"Katherine": "p273"
}
voices = ["Alexander", "Benjamin", "Amelia", "Katherine"]
# Init TTS
def generate_voice(path, text, speaker="Alexander"):
tts = TTS(model_best_multi, gpu=True)
speaker = fakenames[speaker] if speaker in fakenames else speaker
tts.tts_to_file(text=text, file_path=path, speaker=speaker, speed=1)