Skip to content

Instantly share code, notes, and snippets.

@ahmedbr
Last active June 5, 2020 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmedbr/b6f48650f2bd37e0223b949e08e26a72 to your computer and use it in GitHub Desktop.
Save ahmedbr/b6f48650f2bd37e0223b949e08e26a72 to your computer and use it in GitHub Desktop.
Simple script to conduct a search in YouTube by voice using SpeechRecognition package in python
import speech_recognition as sr
import webbrowser
r1 = sr.Recognizer()
r2 = sr.Recognizer()
with sr.Microphone() as source:
print('Dictate some thing to search in YouTube..')
url = 'https://www.youtube.com/results?search_query='
audio = r1.listen(source)
try:
search_key = r2.recognize_google(audio)
except sr.UnknownValueError as e:
print(e)
print(f'Search key: {search_key}')
webbrowser.get().open_new(url + search_key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment