Segmentation fault while trying to run KaldiRecognizer
- 主要語言
- Jupyter Notebook
- 星號
- 15.1k
- 分支
- 1.8k
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Hello,
I am using Vosk 3.44 and Python3.6.9 and while running the code below i get the error: "Segmentation fault (core dumped)" this error occurs after the printed "1" and before the printed "2", so i know that it happens at the line "rec = KaldiRecognizer(model, 44100)"
```
import pyaudio
import wave
import gtts
import speech_recognition as sr
import playsound
import time
import pyttsx3
from vosk import Model, KaldiRecognizer
import numpy as np
import face_recognition as fr
import cv2
print(" 0")
model = Model(lang="en-us") #taal (en-us / nl)
print(" 1")
rec = KaldiRecognizer(model, 44100)
print(" 2")
CHUNK = 1024
FORMAT = pyaudio.paInt16 #16bit
CHANNELS = 1
RATE = 44100
WAVE_OUTPUT_FILENAME = "voice.wav"
p = pyaudio.PyAudio() #Start het portaudio systeem
# #Open streaming programma
stream = p.open(format=FORMAT,
channels=CHANNELS, #Aantal kanalen voor audio streams
rate=RATE, #Sample rate in de audio
input=True, #Zorgt ervoor dat het een input stream is
frames_per_buffer=CHUNK) #Aantal samples
engine = pyttsx3.init()
engine.setProperty('rate', 135) #Set spreken aantal woorden per minuut
voices = engine.getProperty('voices') #Details huidige stem
engine.setProperty('voice', voices[0].id) #Set stem naar man (0) en vrouw (1)
print("* recording")
stream.start_stream()
video_capture = cv2.VideoCapture(0)
martijn_image = fr.load_image_file("martijn.JPG")
martijn_face_encoding = fr.face_encodings(martijn_image)[0]
jord_image = fr.load_image_file("jord.JPG")
jord_face_encoding = fr.face_encodings(jord_image)[0]
job_image = fr.load_image_file("job.JPG")
job_face_encoding = fr.face_encodings(job_image)[0]
known_face_encodings = [martijn_face_encoding, jord_face_encoding, job_face_encoding]
known_face_names = ["martijn", "jord", "job"]
while True:
data = stream.read(CHUNK)
said = '' #Variabel die staat voor hetgeen wat is gezegd
if rec.AcceptWaveform(data):
said = rec.Result() #Resultaat uit de opgenomen audiodata
print(said) #Print hetgeen wat is gezegd
ret, frame = video_capture.read()
rgb_frame = frame#[:, :, ::-1] #de eerste : returns alle rijen, de tweeede : returns alle colommen en de ::-1 draait alles om
face_locations = fr.face_locations(rgb_frame) #dit slaat data op en zorgt voor een geheugenprobleem
face_encodings = fr.face_encodings(rgb_frame, face_locations)
name = "Onbekend"
for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
matches = fr.compare_faces(known_face_encodings, face_encoding)
face_distances = fr.face_distance(known_face_encodings, face_encoding)
best_match_index = np.argmin(face_distances)
if matches[best_match_index]:
name = known_face_names[best_match_index]
if "hello" in said:
engine.say("hello" + str(name) + "have a nice day at work")
engine.runAndWait()
if name == "Onbekend":
if "meeting" in said:
engine.say("Follow me please, i will take you to the meeting")
engine.runAndWait()
elif "bathroom" in said:
engine.say("Follow me please, i will take you to the bathroom")
engine.runAndWait()
elif "break" in said:
engine.say("Follow me please, i will take you to the break room")
engine.runAndWait()
elif "hello" in said:
engine.say("hello, how can i help you")
engine.runAndWait()
else:
print("begrijp je niet")
# #print(rgb_frame)
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break
else:
print("begrijp je niet")
print("* done recording")
stream.stop_stream()
stream.close()
p.terminate()
video_capture.release()
cv2.destroyAllWindows()
```
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。