Last active
September 23, 2020 13:06
-
-
Save zakirangwala/61a24022dffda8ef124d545b61103d52 to your computer and use it in GitHub Desktop.
Tutorial code : Listen Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import speech_recognition as sr | |
# Listen to user input | |
def listen(): | |
r = sr.Recognizer() | |
with sr.Microphone() as source: | |
speak("I'm Listening") | |
print("Listening...") | |
r.pause_threshold = 1 | |
r.adjust_for_ambient_noise(source, duration=1) | |
audio = r.listen(source) | |
try: | |
print("Recognizing...") | |
speak('Recognizing') | |
query = r.recognize_google(audio, language='en-CA') | |
print("User said: {}".format(query)) | |
except sr.UnknownValueError: | |
print("I cannot hear you") | |
speak("I cannot hear you") | |
except sr.RequestError: | |
print("Say that again please") | |
speak("Say that again please") | |
return "None" | |
return query |
Creating a Virtual Assistant, that I will be running on my raspberry pi.
which software are you using to drive it?
…On Wed, Sep 23, 2020 at 7:26 AM Zaki Rangwala ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Creating a Virtual Assistant, that I will be running on my raspberry pi.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/61a24022dffda8ef124d545b61103d52#gistcomment-3464312>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5TJCCAQSKNL3WNIMC2CKTSHHSNVANCNFSM4RW6ROJQ>
.
I will be running the python script on a RaspberryPi OS Lite equipped Raspberry Pi Zero W
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
are you working on speech recognition for Linux? if so I'm highly interested.