Closed TimCapes closed 5 years ago
I've also tried using:
def get_next_audio_frame(file, current_frame): audio = file.readframes(1); return struct.unpack('<h', audio);
Could you let me know the expected format of the linear pcm data the API expects? The buffer is only 2 bytes.
Have you seen this demo? https://github.com/Picovoice/Porcupine/blob/master/demo/python/porcupine_demo_offline.py
I believe this is doing what you are trying to achieve.
Take a look at this as well: https://github.com/Picovoice/Porcupine/blob/master/binding/python/porcupine.py#L141
For future correspondence always attach the output of the console.
Have you seen this demo? https://github.com/Picovoice/Porcupine/blob/master/demo/python/porcupine_demo_offline.py
I believe this is doing what you are trying to achieve.
Take a look at this as well: https://github.com/Picovoice/Porcupine/blob/master/binding/python/porcupine.py#L141
For future correspondence always attach the output of the console.
In this python demo line 60 https://github.com/Picovoice/Porcupine/blob/master/demo/python/porcupine_demo_offline.py if the audio sample rate is 16000, porcupine.frame_length default is 512 frames, that means everytime sent to process function is a 32ms window , is that too short for detect keywords?
Expected behavior
Actual behavior
API returns False which succeeds on >=0.
Steps to reproduce the behavior
Implement sample code for python wrapper. Pass audio data using wave_readers readnframes with n=1. Giving byte as string.
CODE USED
sensitivities = [0.5] handle = Porcupine(library_path, model_file_path, keyword_file_paths=keyword_file_paths, sensitivities=sensitivities) current_frame = 0 file = wave.open(file, 'r') while has_next_audio_frame(file, current_frame): current_frame = current_frame+1; pcm = get_next_audio_frame(file, current_frame) keyword_index = handle.process(pcm) if keyword_index >=0:
detection event logic/callback
def has_next_audio_frame(file, current_frame): return current_frame < file.getnframes();
def get_next_audio_frame(file, current_frame): return file.readframes(1);
This might be an invalid format for the pcm data or some other issue but if so the error handling should be improved. It may help to improve the documentation here.