With sr.Microphone() as source: da hata veriyor.
Eymen74 dedi:
from urllib.request import Request
from playsound import playsound
from gtts import gTTS
import speech_recognition as sr
import os
r = sr.Recognizer()
def record(ask = False): (------- hata burda
with sr.Microphone() as source:
if ask:
print(ask)
audio = r.listen(source)
voice = ""
try:
voice = r.recognize_google(audio, language="tr-Tr)")
print("asistan: Anlayamadım")
except sr.RequestError:
print("asistan: Sistem calıimıyor")
return voice


def speak(string):
tts = gTTS(text=string, lang="tr", slow=False)
file = "answer.mp3"
tts.save(file)
playsound(file)
os.remove(file)

speak("Selam Eymen")
voice = record()
if voice!= "":
print(voice)
Genişletmek icin tıkla...