mirror of
https://github.com/Paillat-dev/FABLE.git
synced 2026-01-02 01:06:20 +00:00
Initial commit
This commit is contained in:
23
generators/speak.py
Normal file
23
generators/speak.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user