finance_assistant / agents /voice_agent.py
zoya23's picture
Update agents/voice_agent.py
8527a57 verified
raw
history blame contribute delete
425 Bytes
import speech_recognition as sr
import pyttsx3
def speech_to_text():
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("🎤 Listening...")
audio = recognizer.listen(source)
try:
return recognizer.recognize_google(audio)
except:
return "Could not understand."
def text_to_speech(text):
engine = pyttsx3.init()
engine.say(text)
engine.runAndWait()