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

Meditation #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions .gitignore

This file was deleted.

36 changes: 36 additions & 0 deletions meditation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys

import speech_recognition as sr
from playsound import playsound
from gtts import gTTS

import time

GOOGLE_CLOUD_SPEECH_CREDENTIALS =
def listener():
r = sr.Recognizer()
with sr.Microphone() as source:
print("listening")
audio = r.listen(source)
try:
print("speech detected")
speech = r.recognize_google_cloud(audio, credentials_json=GOOGLE_CLOUD_SPEECH_CREDENTIALS)
return speech
except sr.UnknownValueError:
print("Google Cloud Speech could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Cloud Speech service; {0}".format(e))

searchQuery = listener()
browser = webdriver.Chrome(r"C:\Users\Bhou5\Downloads\chromedriver_win32\chromedriver.exe")
browser.get('https://www.youtube.com')
browser.find_element_by_id("content").click()
browser.find_element_by_xpath(r'//*[@id="search"]').send_keys(searchQuery + Keys.ENTER)
time.sleep(1)
browser.find_element_by_xpath('//*[@id="title-wrapper"]').click()