Minor change.

This commit is contained in:
retoor 2025-01-18 09:19:21 +01:00
parent b8a517cc14
commit 84c83cfd70

15
tts.py
View File

@ -37,17 +37,18 @@ async def main():
recognizer = sr.Recognizer() recognizer = sr.Recognizer()
with sr.Microphone() as source: with sr.Microphone() as source:
print("Adjusting for ambient noise, please wait...") print("Adjusting to surroundings for a five seconds.")
recognizer.adjust_for_ambient_noise(source, duration=1) recognizer.adjust_for_ambient_noise(source, duration=5)
print("Listening...")
while True: while True:
print("Listening...")
try: try:
audio_data = recognizer.listen(source, timeout=10) audio_data = recognizer.listen(source, timeout=10)
text = recognizer.recognize_google(audio_data, language="en-US") text = recognizer.recognize_google(audio_data, language="nl-NL") #en-US
print(f"Recognized Text: {text}") print(f"You said:\n\t{text}")
response_llm = molodetz.gpt4o_mini(text) response_llm = molodetz.gpt4o_mini(text)
print(f"Response from gpt4o_mini: {response_llm}") print(f"GPT4o mini said:\n\t{response_llm}")
await gcloud.tts(response_llm) await gcloud.tts(response_llm)
except sr.WaitTimeoutError: except sr.WaitTimeoutError:
continue continue
@ -58,4 +59,4 @@ async def main():
if __name__ == "__main__": if __name__ == "__main__":
import asyncio import asyncio
asyncio.run(main()) asyncio.run(main())