[异步播报打断]:完成播放中麦克风监听和音色隔离,包含后台监听、助手回放抑制和用户音色打断测试
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from owner_voice_pet.config import AppConfig
|
||||
@@ -238,6 +239,7 @@ class PlaybackInjectedTransport(MemoryAudioTransport):
|
||||
if self.play_count == self.inject_after_play_count:
|
||||
for frame in self.injected_frames:
|
||||
self.inject(frame)
|
||||
time.sleep(0.002)
|
||||
return result
|
||||
|
||||
def health(self) -> TransportHealth:
|
||||
@@ -649,15 +651,41 @@ class LiveRuntimeTests(unittest.TestCase):
|
||||
|
||||
def test_barge_in_interrupts_playback_and_keeps_only_spoken_context(self) -> None:
|
||||
first_question_frames = [wake_frame(0, 0)]
|
||||
first_question_frames.extend(segment_frames(1, 20, partials=["第一问", "第一问"]))
|
||||
first_question_frames.extend(
|
||||
[
|
||||
AudioFrame(
|
||||
frame.pcm,
|
||||
frame.sample_rate,
|
||||
frame.channels,
|
||||
frame.timestamp_ms,
|
||||
frame.frame_id,
|
||||
{**dict(frame.metadata), "speaker_id": "owner"},
|
||||
)
|
||||
for frame in segment_frames(1, 20, partials=["第一问", "第一问"])
|
||||
]
|
||||
)
|
||||
barge_frames = [
|
||||
AudioFrame(b"\xff\x7f", 16000, 1, 600, 20, {"duration_ms": 20, "speech": True, "partial_transcript": "等一下"}),
|
||||
AudioFrame(b"\xff\x7f", 16000, 1, 620, 21, {"duration_ms": 20, "speech": True, "partial_transcript": "等一下"}),
|
||||
AudioFrame(
|
||||
b"\xff\x7f",
|
||||
16000,
|
||||
1,
|
||||
600,
|
||||
20,
|
||||
{"duration_ms": 20, "speech": True, "partial_transcript": "等一下", "speaker_id": "owner"},
|
||||
),
|
||||
AudioFrame(
|
||||
b"\xff\x7f",
|
||||
16000,
|
||||
1,
|
||||
620,
|
||||
21,
|
||||
{"duration_ms": 20, "speech": True, "partial_transcript": "等一下", "speaker_id": "owner"},
|
||||
),
|
||||
*silence_frames(22, 640, 3),
|
||||
]
|
||||
transport = PlaybackInjectedTransport(
|
||||
first_question_frames,
|
||||
inject_after_play_count=8,
|
||||
inject_after_play_count=18,
|
||||
injected_frames=barge_frames,
|
||||
)
|
||||
stt = QueueSttProvider(["第一问", "打断问题"])
|
||||
@@ -677,8 +705,10 @@ class LiveRuntimeTests(unittest.TestCase):
|
||||
speech_provider="cloud",
|
||||
wake_ack_text="",
|
||||
barge_in_enabled=True,
|
||||
barge_in_echo_guard_ms=500,
|
||||
barge_in_echo_guard_ms=0,
|
||||
barge_in_min_speech_ms=40,
|
||||
barge_in_listen_interval_ms=1,
|
||||
barge_in_chunk_ms=20,
|
||||
followup_listen_timeout_ms=3000,
|
||||
),
|
||||
transport=transport,
|
||||
|
||||
Reference in New Issue
Block a user