Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sounddevice with porcupine not response #468

Open
munstr opened this issue May 14, 2023 · 3 comments
Open

Sounddevice with porcupine not response #468

munstr opened this issue May 14, 2023 · 3 comments

Comments

@munstr
Copy link

munstr commented May 14, 2023

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()
@HaHeho
Copy link

HaHeho commented May 14, 2023

Please edit your comment to provide valid and Markdown formatting for Python code according to the Contribution guidelines! :)

@munstr
Copy link
Author

munstr commented May 15, 2023

Ok. Can you help me?

@mgeier
Copy link
Member

mgeier commented May 15, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants