[英]how create an vocal assistant with python
我想知道創建一個可以解釋單詞的ai對初學者來說是否可行
例如,目前我必須說“給天氣”,它給了我天氣,但如果我說給天氣,請它不會。
我不知道我的野心有多難
因此,如果您已經完成或您在 IA 中了解自己(或不了解)並且您有任何建議,我將不勝感激。
如果我理解正確的話,您所說的是語音助手。 對於初學者來說,創建一個真正的 AI 是可能的,但堅持使用事件驅動編程會很聰明。
無論如何,如果你願意做一個助手,這應該可以幫助你開始 windows:
import speech_recognition as sr
import pyttsx3
r = sr.Recognizer() #
engine = pyttsx3.init() #
engine.setProperty('rate', 145) #
# The Main Part (Listens to the voice)
def speak(audio): #
engine.say(audio) #
engine.runAndWait() #
with sr.Microphone() as source:
print("Say Something: ")
audio = r.listen(source) #Starts listening
try:
text = r.recognize_google(audio).lower()
print('You said : {}'.format(text)) #Tries to understand what you said
except:
print('Sorry I could not recognize your voice')
這應該可以幫助您進行粗略的布局,某些模塊在其他操作系統上是不同的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.