Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Mar 13, 2022 · 3 comments
Open

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

ghost opened this issue Mar 13, 2022 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 13, 2022

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
Copy link

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
Copy link
Author

ghost commented Apr 14, 2022

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant