我正在构建一个个人语音助手,我想让我的 AI 通过唤醒词来听命令(我不知道这是否是个好主意,所以如果不是建议我),因为 SpeechRecogniton 需要互联网并且它有点重并使AI响应更慢...但是当我输入超过1个唤醒词并执行他时,它无法识别任何命令...
import datetime
import pyttsx3 # pip install pyttsx3
import os
import sys
import re
import snowboy.snowboydecoder as snowboydecoder
engine = pyttsx3.init()
voices = engine.getProperty('voices')
# for voice in voices:
# print(voice.id)
engine.setProperty('voice', voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def Greetings():
speak ("Hi Sir")
def How_are_you_doing():
speak ("I'm very good, Sir. And You?")
def wake_word():
print ("Hello_word")
detector=snowboydecoder.HotwordDetector("Hey_Bold.pmdl",sensitivity=0.5,audio_gain=1)
detector.start(Greetings)
def how_you_doing():
print ("how_you_doing_word")
detector_how = snowboydecoder.HotwordDetector("How_you_doing.pmdl", sensitivity=0.5, audio_gain=1)
detector_how.start(How_are_you_doing)
欢迎任何设备!