I am trying to run pvporcupine on ubuntu system, however when I try to execute below code I am getting OSError: [Errno -9985] Device unavailable error. I tried reinstalling and installing its dependencies but still the problem persists.
import pyaudio
import struct
import pvporcupine
access_key = "somekey"
pvporcupine.create(access_key=access_key,keyword_paths=keyword_file_paths, sensitivities=sensitivities )
sensitivities = [0.05]
handle = pvporcupine.create(access_key=access_key, keywords=['computer', 'jarvis','alexa'])
def get_next_audio_frame():
pa = pyaudio.PyAudio()
audio_stream = pa.open(rate=48000,channels=1,format=pyaudio.paInt16,input=True,frames_per_buffer=handle.frame_length,input_device_index=None)
pcm = audio_stream.read(handle.frame_length)
pcm = struct.unpack_from("h" * handle.frame_length, pcm)
return pcm
while True:
pcm = get_next_audio_frame()
keyword_index = handle.process(pcm)
if keyword_index>=0:
print("**********************************************hi")