mirror of
https://github.com/Paillat-dev/FABLE.git
synced 2026-01-02 01:06:20 +00:00
23 lines
609 B
Python
23 lines
609 B
Python
|
|
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)
|