Код python не воспроизводит звук
Программа должна озвучивать текст при помощи модуля Silero, а вместо этого выводит ошибку.
Код:
import torch
import sounddevice as sd
import time
import silero
language = 'ru'
model_id = 'ru_v3'
sample_rate = 48000
speaker = 'xenia'
put_accent = True
put_yo = True
device = torch.device('cpu')
model, _ = torch.hub.load(repo_or_dir='snakers4/silero-models_master',
model='silero_tts',
language=language,
speaker=model_id)
model.to(device)
def speak(what):
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
speak('Привет')
а вот ошибка:
Warning (from warnings module):
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\hub.py", line 267
warnings.warn(
UserWarning: You are about to download and run code from an untrusted repository. In a future release, this won't be allowed. To add the repository to your trusted list, change the command to {calling_fn}(..., trust_repo=False) and a command prompt will appear asking for an explicit confirmation of trust, or load(..., trust_repo=True), which will assume that the prompt is to be answered with 'yes'. You can also use load(..., trust_repo='check') which will only prompt for confirmation if the repo is not already trusted. This will eventually be the default behaviour
Traceback (most recent call last):
File "C:\Users\Артём\Desktop\speak2.py", line 17, in <module>
model, _ = torch.hub.load(repo_or_dir='snakers4/silero-models_master',
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\hub.py", line 539, in load
repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, trust_repo, "load",
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\hub.py", line 203, in _get_cache_or_reload
_validate_not_a_forked_repo(repo_owner, repo_name, ref)
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\hub.py", line 162, in _validate_not_a_forked_repo
response = json.loads(_read_url(Request(url, headers=headers)))
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\hub.py", line 145, in _read_url
with urlopen(url) as r:
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
response = meth(req, response)
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
response = self.parent.error(
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 561, in error
return self._call_chain(*args)
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(*args)
File "C:\Users\Артём\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
Источник: Stack Overflow на русском