Picovoice
Picovoice是一家语音AI技术公司。提供一些产品,如Porcupine(离线唤醒词)。
简介
时间轴
Porcupine
Porcupine,产品全称Porcupine Wake Word,是一款离线轻量级的唤醒词引擎,支持多语言,多平台。免费账号每个月只支持3个用户和3个唤醒词训练。
快速开始
以Python语言示例,使用PyAudio录音,需要先安装好。:
- 注册或登录https://console.picovoice.ai/ 获取AccessKey。
- 安装pvporcupine:
pip3 install pvporcupine
。 - 如果需要自定义唤醒词,需要在线训练,并下载指定文件位置,https://console.picovoice.ai/ppn。
- 使用非英语语言模型,需要下载指定位置,https://github.com/Picovoice/porcupine/tree/master/lib/common。
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 官网:https://picovoice.ai
- Picovoice 文档:https://picovoice.ai/docs