Picovoice

Picovoice是一家语音AI技术公司。提供一些产品,如Porcupine(离线唤醒词)。

简介

时间轴

Porcupine

Porcupine,产品全称Porcupine Wake Word,是一款离线轻量级的唤醒词引擎,支持多语言,多平台。免费账号每个月只支持3个用户和3个唤醒词训练。

了解更多 >> Picovoice 官网:Porcupine Picovoice 文档:Porcupine Github:Picovoice/porcupine


快速开始

Python语言示例,使用PyAudio录音,需要先安装好。:

import struct
import pyaudio
import pvporcupine

porcupine = pvporcupine.create(
    access_key='你的AccessKey',
    keyword_paths=['/存储/路径/自定义唤醒词_zh_raspberry-pi_v3_0_0.ppn'],
    model_path='/存储/路径/语言模型/porcupine_params_zh.pv',
    )

# Initialize PyAudio
audio = pyaudio.PyAudio()
stream = audio.open(
    rate=porcupine.sample_rate,
    channels=1,
    format=pyaudio.paInt16,
    input=True,
    frames_per_buffer=porcupine.frame_length,
)

# Main loop
print("Listening for keywords...")
try:
    while True:
        # Read audio data from the microphone
        audio_data = stream.read(porcupine.frame_length)
        audio_frame = struct.unpack_from("h" * porcupine.frame_length, audio_data)

        # Process audio frame with Porcupine
        keyword_index = porcupine.process(audio_frame)

        if keyword_index == 0:
            print("Keyword 0 detected!")
        elif keyword_index == 1:
            print("Keyword 1 detected!")
finally:
    # Clean up resources
    stream.stop_stream()
    stream.close()
    audio.terminate()
    porcupine.delete()

了解更多 >> Picovoice 文档:Porcupine Wake Word Python Quick Start


资源

官网

文章