Python-AI-Virtual-Assistant icon indicating copy to clipboard operation
Python-AI-Virtual-Assistant copied to clipboard

Code for speech.py seems too lengthy and can be shortened

Open ghost opened this issue 3 years ago • 3 comments

I personally feel that the code written to open the web browser in speech.py is too long. There is actually no need to specify the path of the chrome installation. Just the use the web browser module and it would open it in the default browser. If you want to open it with chrome, set chrome as default browser. Hope you'd fix this.

ghost avatar Mar 13 '22 04:03 ghost

yes you are true this could be done with this code

import speech_recognition as sr recognizer = sr.Recognizer() microphone = sr.Microphone() with microphone as source: print("Speak now...") recognizer.adjust_for_ambient_noise(source) audio = recognizer.listen(source) response = recognizer.recognize_google(audio).lower() #now you can use the variable response #plz correct the indentation of the code in your editor

plz let me know if this code works for you and other viewers

Empireofprogrammers avatar Apr 11 '22 07:04 Empireofprogrammers

@Empireofprogrammers , I am thankful that you commented on this issue. The code you have written however would not do anything related to the web browser. The code you have written is actually for recognizing the input given by the user. What I meant was that to simply : import webbrowser and simply use this module to open any web url by : webbrowser.open('www.yourlink.com')

I hope you'd test this yourself and see the results.

ghost avatar Apr 14 '22 03:04 ghost

Sorry, I was answering my repository question mistakenly I put the code in the incorrect repository Very Sorry By the Way You are right

Empireofprogrammers avatar Jan 13 '23 05:01 Empireofprogrammers