Files
AI-Assistant-for-Computer/main.py
T

40 lines
1.0 KiB
Python
Raw Normal View History

2025-11-26 09:40:01 +03:00
import asyncio
import threading
from voice_player import VoiceImagePlayer, edge_speak
from speech_to_text import record_voice
from groq_ai import get_response
2025-12-15 18:58:00 +03:00
from aircraft_module import handle_aircraft_command
2025-11-26 09:40:01 +03:00
async def get_voice_input():
return await asyncio.to_thread(record_voice)
async def ai_loop(player):
while True:
user_text = await get_voice_input()
if not user_text:
continue
2025-12-15 18:58:00 +03:00
handled = handle_aircraft_command(user_text, player)
if handled:
continue
2025-11-26 09:40:01 +03:00
response = get_response(user_text)
print("AI:", response)
2025-12-15 18:58:00 +03:00
2025-11-26 09:40:01 +03:00
edge_speak(response, player)
player.write_log(f"You: {user_text}")
player.write_log(f"AI: {response}")
2025-12-15 18:58:00 +03:00
2025-11-26 09:40:01 +03:00
def main_loop():
player = VoiceImagePlayer("face.png", size=(900, 900))
def thread_target():
asyncio.run(ai_loop(player))
threading.Thread(target=thread_target, daemon=True).start()
player.root.mainloop()
2025-12-15 18:58:00 +03:00
2025-11-26 09:40:01 +03:00
if __name__ == "__main__":
2025-12-15 18:58:00 +03:00
main_loop()