Aman22sharma / Python-AI-Virtual-Assistant

This is python AI Virtual Assistant.
39 stars 18 forks source link

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

Open ghost opened 2 years ago

ghost commented 2 years ago

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.

Empireofprogrammers commented 2 years ago

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

ghost commented 2 years ago

@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.

Empireofprogrammers commented 1 year ago

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