如何解决如何比较 Python 中的字符串说“类似于”
我在开发语音助手已经有一段时间了,但我需要它来有效地回复我。这是我的代码:
import sys
#sys.path.insert(0,'/home/pi/AIY-voice-kit-python/src/aiy/voice')
from aiy.voice import tts
#import tts
tts.say('Activated')
from os import environ,path
import os
#sys.path.insert(0,'/home/pi/AIY-voice-kit-python/src/examples/voice')
#from __init__ import LiveSpeech,get_model_path
from pocketsphinx import LiveSpeech,get_model_path
model_path = get_model_path()
speech = LiveSpeech(
verbose=False,sampling_rate=16000,buffer_size=2048,no_search=False,full_utt=False,hmm=os.path.join(model_path,'en-us'),lm=os.path.join(model_path,'en-us.lm.bin'),dic=os.path.join(model_path,'cmudict-en-us.dict')
)
for phrase in speech:
p = str(phrase)
print(p)
if p == 'harry you there':
print("speaking")
tts.say('I am here')
此代码有效,但我的语音识别器经常将“harry”误认为“perry”或“carry”或“marry”。我需要这样的 if 语句:
if p like 'harry you':
print("speaking")
tts.say('I am here')
但是 Python 显然不理解“喜欢”这个词。有人能帮我解决这个问题吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。