-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSes Algılama Ve Browser.py
175 lines (152 loc) · 6.98 KB
/
Ses Algılama Ve Browser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import pygame
import json
import requests
import webbrowser
import urllib3
import sys
import os
import random
from threading import Thread
import copypaste
import speech_recognition as sr
from selenium import webdriver
import datetime
import pyttsx3
import wolframalpha
import smtplib
import urllib.request
import urllib.parse
import re
weat = "hava durumu"
ara = "internette ara"
youtube = "youtube"
bye = "güle güle"
engine = pyttsx3.init('sapi5')
urllib3.disable_warnings()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[len(voices)-1].id)
def speak(audio):
print('Computer: ' + audio)
engine.say(audio)
engine.runAndWait()
speak('Merhaba efendim, ben sizin dijital asistanınızım Jarvis!')
def myCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
query = r.recognize_google(audio, language='tr-TR')
print('User: ' + query + '\n')
except sr.UnknownValueError:
speak('Üzgünüm Efendim ,Tekrar Deneyin')
query = str(input('Command: '))
return query
if __name__ == '__main__':
while True:
deneme = True
while deneme == True:
speak("Size nasıl yardım edebilirim?")
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source,timeout=None)
try:
metin = r.recognize_google(audio,language="tr-TR")
print("Sen söyledin: " + metin)
if weat in metin.lower():
speak("Hangi şehrin hava durumunu merak ediyorsun?")
audio2 = r.listen(source,timeout=None,phrase_time_limit=5)
try:
metin = r.recognize_google(audio2,language="tr-TR")
print("Söyledin: " + metin)
appid = "APPID" ## Openweather sitesine kayıt olup alabilirsiniz.
url = "http://api.openweathermap.org/data/2.5/weather?q=" + metin + "&appid=" + appid
istek = requests.get(url,verify=False)
try:
istek = istek.json()
name = istek["name"]
istek = istek["main"]
istek = istek["humidity"]
istek = (istek - 32) / 1.8
print(name,"hava durumu:",int(istek),"derece")
except:
print("Böyle bir yer yok.")
except sr.UnknownValueError:
print("Anlamadım.")
except sr.RequestError:
print("Bad Request")
elif "güle güle" in metin.lower():
speak("Sistem: Asistan arka plana alındı.\n")
os.chdir(yer)
main()
elif ara in metin.lower():
speak("İnternette ne aramamı istiyorsun?")
audio2 = r.listen(source,timeout=None)
try:
metin = r.recognize_google(audio2,language="tr-TR")
print("Bunu mu arayayım?: " + metin)
print("Evet/Hayır")
audio3 = r.listen(source,timeout=None)
try:
metin2 = r.recognize_google(audio3,language="tr-TR")
print("Söyledin: " + metin2)
url = "https://www.google.com/search?q=" + metin
if "evet" in metin2.lower():
webbrowser.open_new(url)
except sr.UnknownValueError:
print("Anlamadım.")
except sr.RequestError:
print("Bad request.")
except sr.UnknownValueError:
print("Anlamadım.")
except sr.RequestError:
print("Bad request.")
elif youtube in metin.lower():
print("Youtube'da ne aramamı istiyorsun?")
audio2 = r.listen(source,timeout=None)
try:
metin = r.recognize_google(audio2,language="tr-TR")
print("Bunu mu arayayım?: " + metin)
print("Evet/Hayır")
audio3 = r.listen(source,timeout=None)
try:
metin2 = r.recognize_google(audio3,language="tr-TR")
print(metin2)
query_string = urllib.parse.urlencode({"search_query" : input()})
html_content = urllib.request.urlopen("http://www.youtube.com/results?" + query_string)
search_results = re.findall(r'href=\"\/watch\?v=(.{11})', html_content.read().decode())
print("http://www.youtube.com/watch?v=" + search_results[0])
url = "https://www.youtube.com/search?q=" + metin
if "evet" in metin2.lower():
webbrowser.open_new(url)
except sr.UnknownValueError:
print("Anlamadım.")
except sr.RequestError:
print("Bad request")
except sr.UnknownValueError:
print("Anlamadım.")
except sr.RequestError:
print("Bad request.")
elif music in metin.lower():
t = Thread(target = Cal)
t.start()
elif "durdur" in metin.lower():
pygame.mixer.init()
pygame.mixer.music.stop()
print("Şarkı durduruldu.")
elif "kopyala" in metin.lower():
print("Neyi kopyalamamı istiyorsun?")
audio2 = r.listen(source,timeout=None)
try:
metin = r.recognize_google(audio2,language = "tr-TR")
print("Kopyalandı: " + metin)
copypaste.copy(metin)
except sr.UnknownValueError:
print("Anlamadım.")
except sr.RequestError:
print("Bad Request")
except sr.UnknownValueError:
print("Anlamadım.")
except sr.RequestError:
print("Bad Request")