alphacep / alphacep/vosk-api

Segmentation fault during fine-tuning VOSK

Abierto
#1,043 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
15.1k
Forks
1.8k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.