Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not read PT file #273

Open
GreenBiever opened this issue Mar 31, 2024 · 1 comment
Open

Can not read PT file #273

GreenBiever opened this issue Mar 31, 2024 · 1 comment

Comments

@GreenBiever
Copy link

ERROR ITSELF

C:\Users\Артем\VoiceAssistantFYP\venv\Scripts\python.exe C:\Users\Артем\VoiceAssistantFYP\tts.py
Using cache found in C:\Users\Артем/.cache\torch\hub\snakers4_silero-models_master
Contents of the directory: ['v3_en.pt', 'v4_ru.pt']
Traceback (most recent call last):
File "C:\Users\Артем\VoiceAssistantFYP\tts.py", line 15, in
model, _ = torch.hub.load(repo_or_dir='snakers4/silero-models',
File "C:\Users\Артем\VoiceAssistantFYP\venv\lib\site-packages\torch\hub.py", line 566, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "C:\Users\Артем\VoiceAssistantFYP\venv\lib\site-packages\torch\hub.py", line 595, in _load_local
model = entry(*args, **kwargs)
File "C:\Users\Артем/.cache\torch\hub\snakers4_silero-models_master\src\silero\silero.py", line 88, in silero_tts
imp = package.PackageImporter(model_path)
File "C:\Users\Артем\VoiceAssistantFYP\venv\lib\site-packages\torch\package\package_importer.py", line 95, in init
self.zip_reader = torch._C.PyTorchFileReader(self.filename)
RuntimeError: open file failed because of errno 2 on fopen: No such file or directory, file path: C:\Users\Артем/.cache\torch\hub\snakers4_silero-models_master\src\silero\model\v3_en.pt

Process finished with exit code 1

My code:
import time

import sounddevice as sd
import torch

language = 'en'
model_id = 'v3_en'
sample_rate = 48000 # 48000
speaker = 'en_0'
put_accent = True
put_yo = True
device = torch.device('cpu') # cpu or gpu
text = "Hello Sir! Nice to see you!"

model, _ = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_tts',
language=language,
speaker=model_id)
model.to(device)

plays

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()

audio = model.apply_tts(text=text,
speaker=speaker,
sample_rate=sample_rate,
put_accent=put_accent,
put_yo=put_yo)

sd.play(audio, sample_rate)
time.sleep(len(audio) / sample_rate)
sd.stop()

@GreenBiever
Copy link
Author

File is located in correct path and can be found by the torch. All permissions are allowed for this file for reading and writing as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant