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 pyttsx3 | |
# Initialize Text to Speech | |
engine = pyttsx3.init('sapi5') | |
voices = engine.getProperty('voices') | |
engine.setProperty('voice', voices[1].id) | |
# Speak Function | |
def speak(audio): | |
engine.say(audio) |
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 required modules for Text to speech conversion | |
from gtts import gTTS | |
import playsound | |
import os | |
#Speak Function | |
def speak(): | |
engine = gTTS(text='Hello World', lang='en', slow=False) | |
engine.save("speech.mp3") | |
playsound.playsound("speech.mp3") |
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) |
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 datetime | |
# Greeting Function | |
def greet(): | |
hour = int(datetime.datetime.now().hour) | |
if hour >= 0 and hour <= 12: | |
speak("Good Morning!") | |
print("Good Morning!") | |
elif hour > 12 and hour < 16: | |
speak("Good Afternoon!") |
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 libraries | |
from bs4 import BeautifulSoup | |
import requests | |
# Configure Browser Header and URL | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'} | |
URL = '' | |
# Check Price of stock |
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 Search module | |
from googlesearch import search | |
# Make Google Query | |
def google_query(query): | |
link = [] | |
for j in search(query, tld="ca", num=10, stop=10, pause=2): | |
link.append(j) | |
return link |
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
# Get location | |
def get_location(): | |
try: | |
URL = 'https://iplocation.com/' | |
page = requests.get(URL, headers=headers) | |
soup = BeautifulSoup(page.content, 'html.parser') | |
city = soup.find(class_='city').get_text() | |
country = soup.find(class_='country_name').get_text() | |
latitude = soup.find(class_='lat').get_text() | |
longitude = soup.find(class_='lng').get_text() |
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 config | |
# Check Weather | |
def weather(latitude, longitude): | |
try: | |
api_key = config.api_key | |
base_url = 'http://api.openweathermap.org/data/2.5/weather?' | |
complete_url = base_url + "lat=" + \ | |
str(latitude) + "&lon=" + str(longitude) + "&appid=" + api_key | |
response = requests.get(complete_url) | |
x = response.json() |
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 imdb | |
# Find IMDB | |
def find_imdb(query): | |
try: | |
query += ' IMDB' | |
URL = google_query(query)[0] | |
page = requests.get(URL, headers=headers) | |
html_content = page.text | |
soup = BeautifulSoup(html_content, 'lxml') |
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
# Rotten Tomatoes Score | |
def rotten_tomatoes_score(query): | |
try: | |
query += query + " Rotten Tomatoes" | |
URL = google_query(query)[0] | |
page = requests.get(URL, headers=headers) | |
soup = BeautifulSoup(page.content, 'html.parser') | |
res = soup.find(class_='mop-ratings-wrap__percentage').get_text() | |
check = res.split(' ') | |
for i in check: |
OlderNewer