-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
27 lines (19 loc) · 921 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from TTS.api import TTS
import os
def synthesize(text, speaker_wav='/voice-samples/anya.wav', output_file='/output/output.wav'):
try:
print("Инициализация модели...")
tts = TTS(model_name="fish-speech/xtts", progress_bar=False)
os.makedirs(os.path.dirname(output_file), exist_ok=True)
print("Генерация речи...")
tts.tts_to_file(
text=text,
speaker_wav=speaker_wav,
languages="ru",
file_path=output_file,
)
print(f"Речь успешно сгенерирована и сохранена а {output_file}")
except Exception as e:
print(f"Ошибка при синтезе речи: {str(e)}")
text = "Привте Бекастан, я хочу поздравить тебя с день рождения, я тебя люблю."
synthesize(text)