Мой код:
import sounddevice as sd
import torch
import time
language = 'ru'
model_id = 'ru_v3'
sample_rate = 48000
speaker = 'aidar'
put_accent = True
put_yo = True
device = torch.device('cpu')
text = 'Привет, Мир!'
model, _ = torch.hub.load(repo_or_dir = 'snakers4/silero-models',
model = 'silero_stt',
language=language,
speaker=model_id)
model.to(device)
audio = model.apply_tts(text=text,
speaker=speaker,
put_accent=put_accent,
put_yo=put_yo)
sd.play(audio, sample_rate)
time.sleep(len(audio) / sample_rate)
sd.stop()
print(text)
Ошибка:
Using cache found in /home/ruslan/.cache/torch/hub/snakers4_silero-models_master
Traceback (most recent call last):
File "/home/ruslan/Документы/Jarvis/m.py", line 14, in <module>
model, _ = torch.hub.load(repo_or_dir = 'snakers4/silero-models',
File "/home/ruslan/.local/lib/python3.10/site-packages/torch/hub.py", line 404, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "/home/ruslan/.local/lib/python3.10/site-packages/torch/hub.py", line 433, in _load_local
model = entry(*args, **kwargs)
File "/home/ruslan/.cache/torch/hub/snakers4_silero-models_master/src/silero/silero.py", line 15, in silero_stt
from .utils import (init_jit_model,
File "/home/ruslan/.cache/torch/hub/snakers4_silero-models_master/src/silero/utils.py", line 4, in <module>
import torchaudio
File "/home/ruslan/.local/lib/python3.10/site-packages/torchaudio/__init__.py", line 1, in <module>
from torchaudio import _extension # noqa: F401
File "/home/ruslan/.local/lib/python3.10/site-packages/torchaudio/_extension.py", line 67, in <module>
_init_extension()
File "/home/ruslan/.local/lib/python3.10/site-packages/torchaudio/_extension.py", line 61, in _init_extension
_load_lib("libtorchaudio")
File "/home/ruslan/.local/lib/python3.10/site-packages/torchaudio/_extension.py", line 51, in _load_lib
torch.ops.load_library(path)
File "/home/ruslan/.local/lib/python3.10/site-packages/torch/_ops.py", line 220, in load_library
ctypes.CDLL(path)
File "/usr/lib/python3.10/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libtorch_hip.so: cannot open shared object file: No such file or directory
Моя система:
Linux Ubuntu 22.04