我希望安装pyaudio,但是出现了以下错误。我使用的是Windows 10操作系统。我尝试了其他答案中提供的解决方案,但它们对我没有起作用。我正在跟随YouTube上的教程。
代码:
代码:
import pyttsx3
import datetime
import speech_recognition as sr
import wikipedia
import webbrowser
import os
r=sr.Recognizer()
engine = pyttsx3.init('sapi5')
voices=engine.getProperty('voices')
engine.setProperty('voice' , voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def takecommand():
with sr.Microphone() as source:
print("Listening.....")
r.pause_threshold=1
o=r.listen(source)
try:
print("Wait for few moments")
query=r.recognize_google(o,language="en-in")
print("user said ", query)
except Exception as e :
print(e)
speak("Say that Again Please ")
if __name__ == "__main__":
wishme()
takecommand()
while True :
wishme()
query = takecommand().lower()
if"wikipedia" in query:
speak("Searching in wikipedia")
query=query.replace("wikipedia" ,"")
results=wikipedia.summary(query,sentences=2)
speak("According to wikipedia ")
speak(results)
print(results)
elif"open youtube" in query:
speak("opening Boss")
webbrowser.open("youtube.com")
elif "open google" in query:
speak("opening Boss")
webbrowser.open("google.com")
elif "open code"in query:
speak("opening Boss")
codepath = "C:\\Users\\Murali\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
os.startfile(codepath)
elif "open chrome"in query:
speak("opening Boss")
chromepath = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
os.startfile(chromepath)
编辑1:我也尝试过使用pip install PyAudio
,但是它也没有起作用。