Last active
June 5, 2020 07:34
-
-
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
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 | |
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