Sounddevice with porcupine not response
The first version of this code was based on pvrecoder but then errors began to occur and connected sounddevice and the code stopped responding. Doesn't throw any errors. Help me please!
My code:
import pvporcupine
import queue
import sounddevice as sd
import yaml
import sys
with open('tokens.yaml', encoding="utf-8") as f:
data = yaml.safe_load(f)
PICOVOICE_TOKEN = data[0].get("Picovoice")
porcupine = pvporcupine.create(
access_key=PICOVOICE_TOKEN,
keyword_paths=[r'C:\Users\lsiba\OneDrive\Desktop\CODS\jarvis\jarvis_windows.ppn'],
sensitivities=[1]
)
#print(sd.query_devices())
device_info = sd.query_devices(sd.default.device[0], 'input')
samplerate = int(device_info['default_samplerate'])
q = queue.Queue()
def recordCallback(indata, frames, time, status):
if status:
print(status, file=sys.stderr)
q.put(bytes(indata))
def wake_word():
with sd.RawInputStream(dtype='int16',
blocksize = 256,
channels=1,
callback=recordCallback):
global cont
cont = True
while cont==True:
data = q.get()
keyword_index = porcupine.process(data)
if keyword_index >= 0:
cont = False
print("WAKE")
return "WAKE"
wake_word()
Please edit your comment to provide valid and Markdown formatting for Python code according to the Contribution guidelines! :)
Ok. Can you help me?
errors began to occur
Please describe which errors did occur.
Please describe how you started your script.
Please describe what "pvrecoder" and "pvporcupine" even is.
Please tell us what you want to do.
As @HaHeho mentioned, it would be very helpful if you would follow the contribution guidelines.
the code stopped responding
Can you please try to find the line of code where it stopps responding?