import torch
import sounddevice as sd
import time
language = 'ru'
model_id = 'ru_v3'
sample_rate = 48000 # 48000
speaker = 'baya' # aidar, baya, kseniya, xenia, random
put_accent = True
put_yo = True
device = torch.device('cpu') # cpu или gpu
text = "Салют!!!"
model, _ = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_tts',
language=language,
speaker=model_id)
model.to(device)
# воспроизводим
def va_speak(what: str):
audio = model.apply_tts(text=what+"..",
speaker=speaker,
sample_rate=sample_rate,
put_accent=put_accent,
put_yo=put_yo)
sd.play(audio, sample_rate * 1.05)
time.sleep((len(audio) / sample_rate) + 0.5)
sd.stop()
# sd.play(audio, sample_rate)
# time.sleep(len(audio) / sample_rate)
# sd.stop()
Using cache found in C:\Users\Анисимов Григорий/.cache\torch\hub\snakers4_silero-models_master
Traceback (most recent call last):
File "C:\Users\Анисимов Григорий\Downloads\Jarvis 2.0\tts.py", line 14, in <module>
model, _ = torch.hub.load(repo_or_dir='snakers4/silero-models',
File "C:\Users\Анисимов Григорий\venv\lib\site-packages\torch\hub.py", line 382, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "C:\Users\Анисимов Григорий\venv\lib\site-packages\torch\hub.py", line 411, in _load_local
model = entry(*args, **kwargs)
File "C:\Users\Анисимов Григорий/.cache\torch\hub\snakers4_silero-models_master\src\silero\silero.py", line 87, in silero_tts
imp = package.PackageImporter(model_path)
File "C:\Users\Анисимов Григорий\venv\lib\site-packages\torch\package\package_importer.py", line 75, in __init__
self.zip_reader = torch._C.PyTorchFileReader(self.filename)
RuntimeError: open file failed, file path: C:\Users\Анисимов Григорий/.cache\torch\hub\snakers4_silero-models_master\src\silero\model\ru_v3.pt
Process finished with exit code 1