liumaolin
commited on
Commit
·
bfefeb3
1
Parent(s):
8f823b0
Refactor core queue initialization: move queue definitions to `constants.py` and clean up redundant imports in `main.py` for better modularity.
Browse files
src/VoiceDialogue/main.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import argparse
|
| 2 |
import time
|
| 3 |
import typing
|
| 4 |
-
from multiprocessing import Queue
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
import uvicorn
|
|
@@ -14,6 +13,13 @@ from services.audio.audio_generator.models import tts_config_registry, TTSConfig
|
|
| 14 |
from services.audio.aec_audio_capture import EchoCancellingAudioCapture
|
| 15 |
from services.audio.audio_answer import TTSAudioGenerator
|
| 16 |
from services.audio.audio_player import AudioStreamPlayer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
from services.speech.speech_monitor import SpeechStateMonitor
|
| 18 |
from services.speech.asr_service import ASRWorker
|
| 19 |
from services.text.text_generator import LLMResponseGenerator
|
|
@@ -56,11 +62,6 @@ def launch_system(
|
|
| 56 |
该函数会阻塞运行,直到系统被外部停止或发生异常
|
| 57 |
"""
|
| 58 |
|
| 59 |
-
audio_frames_queue = Queue()
|
| 60 |
-
user_voice_queue = Queue()
|
| 61 |
-
transcribed_text_queue = Queue()
|
| 62 |
-
text_input_queue = Queue()
|
| 63 |
-
audio_output_queue = Queue()
|
| 64 |
threads = []
|
| 65 |
#
|
| 66 |
audio_frame_probe = EchoCancellingAudioCapture(audio_frames_queue=audio_frames_queue)
|
|
|
|
| 1 |
import argparse
|
| 2 |
import time
|
| 3 |
import typing
|
|
|
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
import uvicorn
|
|
|
|
| 13 |
from services.audio.aec_audio_capture import EchoCancellingAudioCapture
|
| 14 |
from services.audio.audio_answer import TTSAudioGenerator
|
| 15 |
from services.audio.audio_player import AudioStreamPlayer
|
| 16 |
+
from services.core.constants import (
|
| 17 |
+
audio_frames_queue,
|
| 18 |
+
user_voice_queue,
|
| 19 |
+
transcribed_text_queue,
|
| 20 |
+
text_input_queue,
|
| 21 |
+
audio_output_queue
|
| 22 |
+
)
|
| 23 |
from services.speech.speech_monitor import SpeechStateMonitor
|
| 24 |
from services.speech.asr_service import ASRWorker
|
| 25 |
from services.text.text_generator import LLMResponseGenerator
|
|
|
|
| 62 |
该函数会阻塞运行,直到系统被外部停止或发生异常
|
| 63 |
"""
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
threads = []
|
| 66 |
#
|
| 67 |
audio_frame_probe = EchoCancellingAudioCapture(audio_frames_queue=audio_frames_queue)
|
src/VoiceDialogue/services/core/constants.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import threading
|
| 2 |
import uuid
|
| 3 |
from collections import OrderedDict
|
|
@@ -27,6 +28,15 @@ SAMPLE_RATE_WINDOW_SIZE_MAPPING = {
|
|
| 27 |
DEFAULT_SAMPLE_RATE = 16000
|
| 28 |
DEFAULT_WINDOW_SIZE = 512
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
# ======================= 全局状态实例 =======================
|
| 31 |
|
| 32 |
# 语音状态管理器实例
|
|
|
|
| 1 |
+
import multiprocessing
|
| 2 |
import threading
|
| 3 |
import uuid
|
| 4 |
from collections import OrderedDict
|
|
|
|
| 28 |
DEFAULT_SAMPLE_RATE = 16000
|
| 29 |
DEFAULT_WINDOW_SIZE = 512
|
| 30 |
|
| 31 |
+
# ======================= 队列变量 =======================
|
| 32 |
+
|
| 33 |
+
# 音频处理相关队列
|
| 34 |
+
audio_frames_queue = multiprocessing.Queue()
|
| 35 |
+
user_voice_queue = multiprocessing.Queue()
|
| 36 |
+
transcribed_text_queue = multiprocessing.Queue()
|
| 37 |
+
text_input_queue = multiprocessing.Queue()
|
| 38 |
+
audio_output_queue = multiprocessing.Queue()
|
| 39 |
+
|
| 40 |
# ======================= 全局状态实例 =======================
|
| 41 |
|
| 42 |
# 语音状态管理器实例
|