yaptığım sesli asistan sesimi geç algılayıp geç yanıt veriyor google ın kendi ses algılama motorunu kullanıyorum başka bir ses algılama motoru önerirmisiniz
kullandığım kodlar :
from playsound import playsound
from gtts import gTTS
import speech_recognition as sr
import os
import time
from datetime import date, datetime
import random
from random import choice
from pydub import AudioSegment
import webbrowser
r = sr.Recognizer()
def record(ask=False):
with sr.Microphone() as source:
if ask:
print(ask)
audio = r.listen(source)
voice = ""
try:
voice = r.recognize_google(audio, language="tr-TR")
except sr.UnknownValueError:
print("Asistan: Anlayamadım")
except sr.RequestError:
print("Asistan: Sistem çalışmıyor")
return voice
def response(voice):
if "merhaba" in voice:
speak("merhaba efendim size nasıl yardımcı olabilirim ?")
if "teşekkürler" in voice or "teşekkürler" in voice:
speak("rica ederim efendim")
if "google'ı aç" in voice:
speak("google açılıyor")
os.startfile(r'C:\Program Files\Google\Chrome\Application\chrome.exe')
if "paint'i aç" in voice:
speak("opening the paint")
os.starfile(r'C:\Program Files\paint.net\PaintDotNet.exe')
if "baybay" in voice:
speak("görüşmek üzere efendim")
exit()
if "what day are we on" in voice:
today = time.strftime("%A")
today.capitalize()
if today == "Monday":
today = "monday"
elif today == "Tuesday":
today = "tuesday"
elif today == "Wednesday":
today = "wednesday"
elif today == "Thursday":
today = "thursday"
elif today == "Friday":
today = "friday"
elif today == "Saturday":
today = "saturday"
elif today == "Sunday":
today = "sunday"
speak(today)
if "what time is it" in voice:
selection = ["the time is : ", "Hemen bakıyorum: "]
clock = datetime.now().strftime("%H:%M")
selection = random.choice(selection)
speak(selection + clock)
if "seardh in google" in voice:
speak("what you want to search ?")
search = record()
url = "https://www.google.com/search?q={}".format(search)
webbrowser.get().open(url)
speak("{} for I'm listing what I could find on google.".format(search))
def speak(string):
tts = gTTS(text=string, lang="tr", slow=False)
file = "answer.mp3"
tts.save(file)
playsound(file)
os.remove(file)
def test(wake):
if "jarvis" in wake:
playsound("jarvis active.mp3")
wake = record()
if wake != '':
voice = wake.lower()
print(wake.capitalize())
response(voice)
playsound("Jarvis.mp3")
while True:
wake = record()
if wake != '':
wake = wake.lower()
print(wake.capitalize())
test(wake)