Aug-03-2019, 07:27 AM
import codecs import pyttsx3 import speech_recognition as sr import datetime import wikipedia engine=pyttsx3.init('sapi5') voices=engine.getProperty('voices') engine.setProperty('voices',voices[0].id) def speak(audio): engine.say(audio) engine.runAndWait() def wishme(): hour=int(datetime.datetime.now().hour) if hour>0 and hour<=12: speak("Good Morning") elif hour>12 and hour<=16: speak("Good Afternoon") elif hour>=16 and hour<20: speak("Good Evening") else: speak("Good Night") speak("I am Jaarvis. Please tell me How may I help You") def takecommand(): r=sr.Recognizer() with sr.Microphone() as source: print("Listening") r.pause_threshold=1 r.energy_threshold=300 audio=r.listen(source) try: print("Recognizing....") query=r.recognize_google(audio,language='en-US') print('user said:',query,'\n') except Exception as e: print(e) print("Say that again Please.......") return "None" return query if __name__ == '__main__': wishme() while True: query=takecommand().upper()
Error:'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte