porcupine语音唤醒python实现
阅读原文时间:2023年07月10日阅读:1

note

it is not for arm

pyaudio <= 3.6 version

porcupine 3.5 3.6 not 3.7

code

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")

application

reference

https://github.com/Picovoice/porcupine/issues/255

https://www.jianshu.com/p/cadb9d80f180

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章