在PC上复刻小爱音箱功能
1.离线语音唤醒,用Picovoice实现
相关链接:
Picovoice官网
Picovoice github 主要用于查看python如何调用
python实现示例
import pvporcupine import pyaudio import struct def main(): # 初始化 Porcupine porcupine = pvporcupine.create( access_key="xxxxxxxx", # 替换为你的 Picovoice access key keyword_paths=["./hey-amy_en_windows_v3_0_0.ppn"] # 替换为你的关键词文件路径 ) # 初始化 PyAudio audio = pyaudio.PyAudio() # 获取默认的输入设备 stream = audio.open( rate=porcupine.sample_rate, channels=1, format=pyaudio.paInt16, input=True, frames_per_buffer=porcupine.frame_length ) print("Listening for wake word...") try: while True: # 从麦克风中读取音频数据 pcm = stream.read(porcupine.frame_length) pcm = struct.unpack_from("h" * porcupine.frame_length, pcm) # 处理音频数据,检测是否包含唤醒词 keyword_index = porcupine.process(pcm) if keyword_index >= 0: print("识别到了") except KeyboardInterrupt: print("Stopping...") finally: # 清理资源 stream.close() audio.terminate() porcupine.delete() if __name__ == "__main__": main()
2.语音识别
3.自然语言处理
4.语音合成
5.知识库扩展
6.函数调用(查天气等)