alphacep / alphacep/vosk-api

Segmentation fault during fine-tuning VOSK

Đang mở
#1,043 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
15.1k
Fork
1.8k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hello,

Following the vosk adaptation tutorial, I have re-compiled vosk ("vosk-model-en-us-0.22-compile") to implement some specific words in the model's vocabulary by adding sentences in the “extra.txt“ document. After this, I have changed the paths properly and I have run “compile-graph.sh“.

Once the re-compilation is finished (with no errors), I take the graph/ and rnnlm_out/ folders to change them in the models ”vosk-model-en-us-0.20” and “vosk-model-en-us-0.21“ separately (just to run the same process, but with differents models).

The issue appears when I try to use it in a notebook to check whether the model detects or not the new words. The lines are the following:
![Captura de 2022-06-27 13-02-42](https://user-images.githubusercontent.com/108397866/176425782-4fe8c3eb-7569-4120-a735-d4746656bc14.png)

**Functions used in the code:**

- **Vosk initialization:**

from vosk import Model, KaldiRecognizer
```
actual_path = os.getcwd()
voice_module_index = actual_path.find('voice-module') + len('voice-module')
actual_path = actual_path[:voice_module_index]
model_path = os.path.join(actual_path, self.opt['path'])
if not os.path.exists(model_path):
print('''Please download the model from https://alphacephei.com/vosk/models and unpack as 'model' in the current folder.''')
raise Exception(f"No model was found in path: {model_path}")

return Model(model_path)
```

- **get_transcription():**

```

actual_path = os.getcwd()
voice_module_index = actual_path.find('voice-module') + len('voice-module')
actual_path = actual_path[:voice_module_index]
tmp_file_path = path2file
if not '.wav' in path2file:
tmp_file_path = os.path.join(actual_path, 'tmp_audio.wav')
start_subprocess = time.perf_counter()
subprocess.call(['ffmpeg', '-i', path2file, '-ar', '16000', '-ac', '1', tmp_file_path, '-y'])
print("SUBPROCESS TIME: ", time.perf_counter() - start_subprocess)
print('PATH: ', tmp_file_path)
wf = wave.open(tmp_file_path, "rb")

print("--Audio processing started--")
if wf.getnchannels() != 1 or wf.getsampwidth() != 2 or wf.getcomptype() != "NONE":
print("Audio file must be WAV format mono PCM.")
return Nonestart_model = time.perf_counter()

rec = KaldiRecognizer(self.model, wf.getframerate()) # , '[" coke diet regular", "[unk]"]')rec.SetWords(True)

while True:
data = wf.readframes(4000)
if len(data) == 0:
break if rec.AcceptWaveform(data):
pass # print(rec.Result()) else:
pass # print(rec.PartialResult())print("--Audio processing successfully finished!--")
# os.remove(tmp_file_path)res = self.postprocessing(rec.FinalResult())
print("MODEL TIME: ", time.perf_counter() - start_model)
return res
```

After running vosk.get_transcriptions(), the kernel dies produced by a **segmentation fault**.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.