-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (33 loc) · 989 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# V3
import os
import torch
import torchaudio
device = torch.device('cpu')
torch.set_num_threads(4)
local_file = 'model.pt'
if not os.path.isfile(local_file):
torch.hub.download_url_to_file(
'https://models.silero.ai/models/tts/tt/v3_tt.pt', local_file)
model = torch.package.PackageImporter(
local_file).load_pickle("tts_models", "model")
model.to(device)
example_text = 'Мин почти кеше тавышы. Мин сезнең белән д+ус булырга телим'
# җ
# ү
# ә
# һ
# ң
# ө
text = example_text
filename = text+'.mp3'
sample_rate = 48000
speaker = 'dilyara'
put_accent = True
audio_paths = model.apply_tts(text=text+'.',
speaker=speaker,
sample_rate=sample_rate,
put_accent=put_accent,
)
torchaudio.save('audio/' + filename,
audio_paths.unsqueeze(0),
sample_rate=sample_rate)