пытаюсь выполнить код, папку vosk-model-ru-0.22 переименовал в model
from vosk import Model, KaldiRecognizer, SetLogLevel
from pydub import AudioSegment
import subprocess
import json
import os
SetLogLevel(0)
model_path = "E:/work/model"
recasepunc_path = "E:/work/recasepunc"
# Устанавливаем Frame Rate
FRAME_RATE = 16000
CHANNELS = 1
model = Model(model_path)
rec = KaldiRecognizer(model, FRAME_RATE)
rec.SetWords(True)
# Используя библиотеку pydub делаем предобработку аудио
mp3 = AudioSegment.from_mp3('E:/work/sound.mp3')
mp3 = mp3.set_channels(CHANNELS)
mp3 = mp3.set_frame_rate(FRAME_RATE)
# Преобразуем вывод в json
rec.AcceptWaveform(mp3.raw_data)
result = rec.Result()
text = json.loads(result)["text"]
# Добавляем пунктуацию
cased = subprocess.check_output(f'python3 {recasepunc_path}\recasepunc.py predict {recasepunc_path}\checkpoint', shell=True, text=True, input=text)
# Записываем результат в файл "data.txt"
with open('E:\work\data.txt', 'w') as f:
json.dump(cased, f, ensure_ascii=False, indent=4)
вот ошибка
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_14808\3415063598.py in
16 CHANNELS = 1
17
---> 18 model = Model(model_path)
19 rec = KaldiRecognizer(model, FRAME_RATE)
20 rec.SetWords(True)
E:\anaconda\envs\ML_Udemy\lib\site-packages\vosk\__init__.py in __init__(self, model_path, model_name, lang)
55 self._handle = _c.vosk_model_new(model_path.encode("utf-8"))
56 if self._handle == _ffi.NULL:
---> 57 raise Exception("Failed to create a model")
58
59 def __del__(self):
Exception: Failed to create a model
вот логи
[I 17:56:58.969 NotebookApp] Saving file at /Transcribition.ipynb
LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=13 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:6:7:8:9:10
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 1 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 2 orphan components.
LOG (VoskAPI:Collapse():nnet-utils.cc:1488) Added 1 components, removed 2
LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from E:/work/model/ivector/final.ie
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (VoskAPI:ReadDataFiles():model.cc:279) Loading HCLG from E:/work/model/graph/HCLG.fst
LOG (VoskAPI:ReadDataFiles():model.cc:297) Loading words from E:/work/model/graph/words.txt
LOG (VoskAPI:ReadDataFiles():model.cc:308) Loading winfo E:/work/model/graph/phones/word_boundary.int
LOG (VoskAPI:ReadDataFiles():model.cc:315) Loading subtract G.fst model from E:/work/model/rescore/G.fst
LOG (VoskAPI:ReadDataFiles():model.cc:317) Loading CARPA model from E:/work/model/rescore/G.carpa
LOG (VoskAPI:ReadDataFiles():model.cc:323) Loading RNNLM model from E:/work/model/rnnlm/final.raw
[I 18:07:49.393 NotebookApp] Saving file at /Transcribition.ipynb