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

Refactor code #8

Open
wants to merge 2 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions diction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from difflib import get_close_matches
import pyttsx3
import json
import pyttsx3
import speech_recognition as sr
from difflib import get_close_matches

data = json.load(open('data.json'))
engine = pyttsx3.init()
Expand Down Expand Up @@ -57,4 +57,4 @@ def translate(word):


if __name__ == '__main__':
translate()
translate("Blah Blah")
17 changes: 8 additions & 9 deletions jarvis.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import pyttsx3
import wikipedia
import speech_recognition as sr
import webbrowser
import datetime
import os
import sys
import pyttsx3
import smtplib
from news import speak_news
import speech_recognition as sr
import sys
import webbrowser
import wikipedia

from diction import translate
from loc import weather
from news import speak_news
from youtube import you

engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)

# print(voices[0].id)


def speak(audio):
engine.say(audio)
Expand All @@ -37,7 +37,6 @@ def takeCommand():
print(f'User said: {query}\n')

except Exception as e:
# print(e)

print('Say that again please...')
return 'None'
Expand Down
2 changes: 1 addition & 1 deletion loc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import geocoder
import requests
import json
import pyttsx3
import requests

g = geocoder.ip('me')

Expand Down
3 changes: 2 additions & 1 deletion news.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
import json
import pyttsx3
import requests

engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
Expand Down
17 changes: 5 additions & 12 deletions youtube.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from urllib.request import urlopen
import urllib.parse
import re
from bs4 import BeautifulSoup
import urllib.parse
import webbrowser
chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
from bs4 import BeautifulSoup
from urllib.request import urlopen

chrome_path = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
webbrowser.register(
'chrome', None, webbrowser.BackgroundBrowser(chrome_path))

Expand All @@ -12,14 +13,6 @@ def you(textToSearch):
query = urllib.parse.quote(textToSearch)
url = "https://www.youtube.com/results?search_query=" + query
webbrowser.get('chrome').open_new_tab(url)
#response = urlopen(url)
#html = response.read()
#soup = BeautifulSoup(html, "lxml")
#flag = 0
#search_results=re.findall('href=\"\\/watch\\?v=(.{11})', html.decode())
#print(search_results)
#webbrowser.get('chrome').open_new_tab('http://youtube.com/watch?v=' + search_results[0])



if __name__ == '__main__':
Expand Down