it is not for arm
pyaudio <= 3.6 version
porcupine 3.5 3.6 not 3.7
import struct
import pyaudio
import pvporcupine
#porcupine = pvporcupine.create(keywords=['porcupine', 'ok google', "picovoice", "blueberry"])
porcupine = pvporcupine.create(keyword_paths=['samel__en_windows_2021-10-26-utc_v1_9_0.ppn'])
pa = pyaudio.PyAudio()
audio_stream = pa.open(
rate=porcupine.sample_rate,
channels=1,
format=pyaudio.paInt16,
input=True,
frames_per_buffer=porcupine.frame_length)
#def get_next_audio_frame():
# return
while True:
pcm = audio_stream.read(porcupine.frame_length)
pcm = struct.unpack_from("h" * porcupine.frame_length, pcm)
keyword_index = porcupine.process(pcm)
if keyword_index >= 0:
# Insert detection event callback here
print("sdfsa")
手机扫一扫
移动阅读更方便
你可能感兴趣的文章