Segmentation fault during fine-tuning VOSK

130 views
Skip to first unread message

Roger Pons Rodon

unread,
Jun 27, 2022, 9:55:23 AM6/27/22
to kaldi-help
Hello,

Following the vosk adaptation tutorial, I have re-compiled vosk 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“.

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.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.

Any help would be much appreciated,
Roger Pons

nshm...@gmail.com

unread,
Jun 27, 2022, 7:33:17 PM6/27/22
to kaldi-help
> 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“.

You can not mix model versions like that, they are not compatible.

Roger Pons Rodon

unread,
Jun 28, 2022, 4:10:33 AM6/28/22
to kaldi-help

Hello again,


I followed the steps in the tutorial for vosk-model-en-us-0.20. I did all the procedures I explained above and the kernel dies produced by a segmentation fault.

I changed the version of the model to vosk-model-en-us-0.21 and repeated the same steps, but the kernel dies anyway.

I do not use both of the models at any moment. I just repeated the process for each version separately to check if maybe this is the source of the problem.

Could you please indicate what I am doing wrong? Once again, I am:

  • I added sentences in the “extra.txt“ document.

  • I have changed the paths properly and I have run “compile-graph.sh“.

  • I take the graph/ and rnnlm_out/ folders to change them in the model ”vosk-model-en-us-0.20”.

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


El dia dimarts, 28 de juny de 2022 a les 1:33:17 UTC+2, nshm...@gmail.com va escriure:

nshm...@gmail.com

unread,
Jun 28, 2022, 8:00:37 AM6/28/22
to kaldi-help
You'd better report this issue on vosk github

> the kernel dies

What is "kernel" exactly?

> I take the graph/ and rnnlm_out/ folders to change them in the model ”vosk-model-en-us-0.20”.

Published update package only works with model 0.22, it is not compatible with 0.20. I don't think we published 0.20 update package.
Reply all
Reply to author
Forward
0 new messages