-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
31 lines (29 loc) · 971 Bytes
/
test.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
28
29
30
31
import torch
import sounddevice as sd
def say(say):
language = "ru"
model_id = 'v3_1_ru'
speaker = 'aidar'
# if langu == 'ru':
# model_id = 'v3_1_ru'
# speaker = 'aidar'
# if langu == 'en':
# model_id = 'v3_en'
# speaker = 'en_73'
device = torch.device('cpu')
model, _= torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_tts',
language=language,
speaker=model_id)
model.to(device)
sample_rate = 24000
example_text = say
audio = model.apply_tts(text=example_text,
speaker=speaker,
sample_rate=sample_rate,
put_accent=True,
put_yo=True)
sd.play(audio, sample_rate)
sd.sleep(len(audio) / sample_rate + 0.1)
sd.stop()
say("Привет")