Timer
This commit is contained in:
41
app/main.py
41
app/main.py
@@ -14,12 +14,12 @@ Flow:
|
||||
# Главный файл приложения (`main.py`).
|
||||
# Здесь находится основной бесконечный цикл, который связывает все компоненты воедино.
|
||||
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
import queue
|
||||
import re
|
||||
import os
|
||||
from collections import deque
|
||||
|
||||
# Для воспроизведения звуков (mp3)
|
||||
@@ -32,18 +32,25 @@ else:
|
||||
_MIXER_IMPORT_ERROR = None
|
||||
|
||||
# Импорт наших модулей
|
||||
from .audio.sound_level import parse_volume_text, set_volume
|
||||
from .audio.stt import cleanup as cleanup_stt
|
||||
from .audio.stt import get_recognizer, listen
|
||||
from .audio.tts import initialize as init_tts
|
||||
from .audio.tts import speak
|
||||
from .audio.wakeword import (
|
||||
wait_for_wakeword,
|
||||
cleanup as cleanup_wakeword,
|
||||
check_wakeword_once,
|
||||
wait_for_wakeword,
|
||||
)
|
||||
from .audio.wakeword import (
|
||||
cleanup as cleanup_wakeword,
|
||||
)
|
||||
from .audio.wakeword import (
|
||||
stop_monitoring as stop_wakeword_monitoring,
|
||||
)
|
||||
from .audio.stt import listen, cleanup as cleanup_stt, get_recognizer
|
||||
from .core.ai import ask_ai, ask_ai_stream, translate_text
|
||||
from .core.cleaner import clean_response
|
||||
from .audio.tts import speak, initialize as init_tts
|
||||
from .audio.sound_level import set_volume, parse_volume_text
|
||||
from .features.alarm import get_alarm_clock
|
||||
from .features.timer import get_timer_manager
|
||||
from .features.weather import get_weather_report
|
||||
|
||||
# Список стоп-слов, чтобы прервать диалог или остановить ассистента
|
||||
@@ -164,6 +171,7 @@ def main():
|
||||
get_recognizer().initialize() # Подключение к Deepgram
|
||||
init_tts() # Загрузка нейросети для синтеза речи (Silero)
|
||||
alarm_clock = get_alarm_clock() # Загрузка будильников
|
||||
timer_manager = get_timer_manager() # Загрузка таймеров
|
||||
print()
|
||||
|
||||
# История чата (храним последние 10 обменов репликами для контекста)
|
||||
@@ -182,6 +190,12 @@ def main():
|
||||
# Гарантируем, что микрофон детектора wake word освобожден
|
||||
stop_wakeword_monitoring()
|
||||
|
||||
# --- Проверка таймеров ---
|
||||
# Проверяем каждую итерацию. Если таймер сработал, он заблокирует выполнение, пока его не выключат.
|
||||
if timer_manager.check_timers():
|
||||
skip_wakeword = False
|
||||
continue
|
||||
|
||||
# --- Проверка будильников ---
|
||||
# Проверяем каждую итерацию. Если будильник сработал, он заблокирует выполнение, пока его не выключат.
|
||||
if alarm_clock.check_alarms():
|
||||
@@ -256,6 +270,17 @@ def main():
|
||||
skip_wakeword = True
|
||||
continue
|
||||
|
||||
# Проверка команд таймера ("поставь таймер на 6 минут")
|
||||
timer_response = timer_manager.parse_command(user_text)
|
||||
if timer_response:
|
||||
clean_timer_response = clean_response(timer_response, language="ru")
|
||||
completed = speak(
|
||||
clean_timer_response, check_interrupt=check_wakeword_once
|
||||
)
|
||||
last_response = clean_timer_response
|
||||
skip_wakeword = not completed
|
||||
continue
|
||||
|
||||
# Проверка команд будильника ("поставь будильник на 7")
|
||||
alarm_response = alarm_clock.parse_command(user_text)
|
||||
if alarm_response:
|
||||
|
||||
Reference in New Issue
Block a user