liumaolin
commited on
Commit
·
4e071d3
1
Parent(s):
4e2e3d8
Add `--disable-echo-cancellation` CLI option and update audio pipeline to support toggling echo cancellation and VAD
Browse files- main.py +1 -1
- src/voice_dialogue/cli/args.py +6 -0
- src/voice_dialogue/core/launcher.py +11 -2
main.py
CHANGED
@@ -79,7 +79,7 @@ VoiceDialogue - 语音对话系统
|
|
79 |
print(f"语言设置: {args.language}")
|
80 |
print(f"说话人: {args.speaker}")
|
81 |
print("正在启动命令行语音对话系统...")
|
82 |
-
launch_system(args.language, args.speaker)
|
83 |
|
84 |
elif args.mode == 'api':
|
85 |
launch_api_server(
|
|
|
79 |
print(f"语言设置: {args.language}")
|
80 |
print(f"说话人: {args.speaker}")
|
81 |
print("正在启动命令行语音对话系统...")
|
82 |
+
launch_system(args.language, args.speaker, args.disable_echo_cancellation)
|
83 |
|
84 |
elif args.mode == 'api':
|
85 |
launch_api_server(
|
src/voice_dialogue/cli/args.py
CHANGED
@@ -68,6 +68,12 @@ def create_argument_parser():
|
|
68 |
default='沈逸' if '沈逸' in available_speakers else (available_speakers[0] if available_speakers else '沈逸'),
|
69 |
help='TTS说话人 (默认: 沈逸)'
|
70 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
# API服务器模式参数
|
73 |
api_group = parser.add_argument_group('API服务器模式参数')
|
|
|
68 |
default='沈逸' if '沈逸' in available_speakers else (available_speakers[0] if available_speakers else '沈逸'),
|
69 |
help='TTS说话人 (默认: 沈逸)'
|
70 |
)
|
71 |
+
cli_group.add_argument(
|
72 |
+
'--disable-echo-cancellation',
|
73 |
+
action='store_true',
|
74 |
+
default=False,
|
75 |
+
help='禁用回声消除功能 (默认: 启用)'
|
76 |
+
)
|
77 |
|
78 |
# API服务器模式参数
|
79 |
api_group = parser.add_argument_group('API服务器模式参数')
|
src/voice_dialogue/core/launcher.py
CHANGED
@@ -25,7 +25,8 @@ from voice_dialogue.utils.logger import logger
|
|
25 |
|
26 |
def launch_system(
|
27 |
user_language: str,
|
28 |
-
speaker: str
|
|
|
29 |
) -> None:
|
30 |
"""
|
31 |
启动完整的语音对话系统
|
@@ -61,14 +62,22 @@ def launch_system(
|
|
61 |
threads = []
|
62 |
|
63 |
# 音频采集
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
audio_frame_probe.start()
|
66 |
threads.append(audio_frame_probe)
|
67 |
|
68 |
# 语音状态监测
|
|
|
|
|
69 |
user_voice_checker = SpeechStateMonitor(
|
70 |
audio_frame_queue=audio_frames_queue,
|
71 |
user_voice_queue=user_voice_queue,
|
|
|
72 |
)
|
73 |
user_voice_checker.start()
|
74 |
threads.append(user_voice_checker)
|
|
|
25 |
|
26 |
def launch_system(
|
27 |
user_language: str,
|
28 |
+
speaker: str,
|
29 |
+
disable_echo_cancellation: bool = False,
|
30 |
) -> None:
|
31 |
"""
|
32 |
启动完整的语音对话系统
|
|
|
62 |
threads = []
|
63 |
|
64 |
# 音频采集
|
65 |
+
enable_echo_cancellation = not disable_echo_cancellation
|
66 |
+
logger.info(f"Echo Cancellation: {enable_echo_cancellation}")
|
67 |
+
audio_frame_probe = AudioCapture(
|
68 |
+
audio_frames_queue=audio_frames_queue,
|
69 |
+
enable_echo_cancellation=enable_echo_cancellation
|
70 |
+
)
|
71 |
audio_frame_probe.start()
|
72 |
threads.append(audio_frame_probe)
|
73 |
|
74 |
# 语音状态监测
|
75 |
+
enable_vad = disable_echo_cancellation
|
76 |
+
logger.info(f"VAD: {enable_vad}")
|
77 |
user_voice_checker = SpeechStateMonitor(
|
78 |
audio_frame_queue=audio_frames_queue,
|
79 |
user_voice_queue=user_voice_queue,
|
80 |
+
enable_vad=enable_vad
|
81 |
)
|
82 |
user_voice_checker.start()
|
83 |
threads.append(user_voice_checker)
|