Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Calculate PCM duration based on current request audio bytes
# Use current_request_audio_bytes which is already updated by audio frames
Expand All @@ -376,6 +377,22 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(
f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms"
)

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(
ten_env,
f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms",
)
return
ten_env.log_info(
f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms"
)
else:
ten_env.log_info(
f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms"
)

ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
else:
Expand Down Expand Up @@ -505,4 +522,3 @@ def test_append_input(extension_name: str, config_dir: str) -> None:
assert (
error is None
), f"Test failed: {error.error_message() if error else 'Unknown error'}"

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import random
import uuid
import string
import asyncio

TTS_DUMP_CONFIG_FILE = "property_dump.json"
AUDIO_DURATION_TOLERANCE_MS = 50
Expand Down Expand Up @@ -137,7 +138,7 @@ async def on_start(self, ten_env: AsyncTenEnvTester) -> None:
ten_env.log_info(f"Sending request {request_idx + 1}/{self.expected_group_count}: {text} (request_id: {request_id})")

# Each request has only one text, so text_input_end is always True
time.sleep(5)
await asyncio.sleep(5)
await self._send_tts_text_input(
ten_env, text, request_id, metadata, text_input_end=True
)
Expand Down Expand Up @@ -351,6 +352,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Calculate PCM duration based on current request audio bytes
# Use current_request_audio_bytes which is already updated by audio frames
Expand All @@ -371,6 +373,22 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(
f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms"
)

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(
ten_env,
f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms",
)
return
ten_env.log_info(
f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms"
)
else:
ten_env.log_info(
f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms"
)

ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
else:
Expand Down Expand Up @@ -554,4 +572,3 @@ def test_append_input_stress(
assert (
error is None
), f"Test failed: {error.error_message() if error else 'Unknown error'}"

Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
received_audio_duration_ms, _ = data.get_property_int(
"request_total_audio_duration_ms"
)
received_event_interval_ms, _ = data.get_property_int(
"request_event_interval_ms"
)

# Calculate PCM duration based on current request audio bytes
# Use current_request_audio_bytes which is already updated by audio frames
Expand All @@ -451,6 +454,22 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms"
)

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(
ten_env,
f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms",
)
return
ten_env.log_info(
f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms"
)
else:
ten_env.log_info(
f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms"
)

ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
else:
ten_env.log_warn("tts_audio_start not received before tts_audio_end")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Calculate PCM duration based on current request audio bytes
# Use current_request_audio_bytes which is already updated by audio frames
Expand All @@ -521,6 +522,22 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(
f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms"
)

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(
ten_env,
f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms",
)
return
ten_env.log_info(
f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms"
)
else:
ten_env.log_info(
f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms"
)

ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
else:
Expand Down Expand Up @@ -797,4 +814,3 @@ def test_append_interrupt(extension_name: str, config_dir: str) -> None:
assert (
error is None
), f"Test failed: {error.error_message() if error else 'Unknown error'}"

Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms (actual audio duration)
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Validate audio duration: request_total_audio_duration_ms should be consistent with the length calculated from the PCM file
pcm_audio_duration_ms = self._calculate_pcm_audio_duration_ms()
Expand All @@ -262,6 +263,15 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(f"✅ [{self.test_name}] Audio duration validation passed. PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms, Diff: {audio_duration_diff}ms")
else:
ten_env.log_info(f"[{self.test_name}] Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms")

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(ten_env, f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
return
ten_env.log_info(f"✅ [{self.test_name}] Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
else:
ten_env.log_info(f"[{self.test_name}] Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms")

# Record actual elapsed time (for debugging)
ten_env.log_info(f"[{self.test_name}] Actual event duration: {actual_duration_ms:.2f}ms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms (actual audio duration)
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Validate audio duration: request_total_audio_duration_ms should be consistent with the length calculated from the PCM file
pcm_audio_duration_ms = self._calculate_pcm_audio_duration_ms()
Expand All @@ -245,6 +246,15 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(f"✅ Audio duration validation passed. PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms, Diff: {audio_duration_diff}ms")
else:
ten_env.log_info(f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms")

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(ten_env, f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
return
ten_env.log_info(f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
else:
ten_env.log_info(f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms")

# Record actual elapsed time (for debugging)
ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms (actual audio duration)
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Validate audio duration: request_total_audio_duration_ms should be consistent with the length calculated from the PCM file
pcm_audio_duration_ms = self._calculate_pcm_audio_duration_ms()
Expand All @@ -246,6 +247,15 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(f"✅ Audio duration validation passed. PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms, Diff: {audio_duration_diff}ms")
else:
ten_env.log_info(f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms")

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(ten_env, f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
return
ten_env.log_info(f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
else:
ten_env.log_info(f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms")

# Record actual elapsed time (for debugging)
ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms (actual audio duration)
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Validate audio duration: request_total_audio_duration_ms should be consistent with the length calculated from the PCM file
pcm_audio_duration_ms = self._calculate_pcm_audio_duration_ms()
Expand All @@ -247,6 +248,15 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(f"✅ Audio duration validation passed. PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms, Diff: {audio_duration_diff}ms")
else:
ten_env.log_info(f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms")

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(ten_env, f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
return
ten_env.log_info(f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms")
else:
ten_env.log_info(f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms")

# Record actual elapsed time (for debugging)
ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:

# Get request_total_audio_duration_ms
received_audio_duration_ms, _ = data.get_property_int("request_total_audio_duration_ms")
received_event_interval_ms, _ = data.get_property_int("request_event_interval_ms")

# Calculate PCM duration based on current request audio bytes
# Use current_request_audio_bytes which is already updated by audio frames
Expand All @@ -457,6 +458,22 @@ async def on_data(self, ten_env: AsyncTenEnvTester, data: Data) -> None:
ten_env.log_info(
f"Skipping audio duration validation - PCM: {pcm_audio_duration_ms}ms, Reported: {received_audio_duration_ms}ms"
)

if received_event_interval_ms > 0:
event_interval_diff = abs(received_event_interval_ms - actual_duration_ms)
if event_interval_diff > AUDIO_DURATION_TOLERANCE_MS:
self._stop_test_with_error(
ten_env,
f"Event interval mismatch. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms",
)
return
ten_env.log_info(
f"✅ Event interval validation passed. Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms, Diff: {event_interval_diff:.2f}ms"
)
else:
ten_env.log_info(
f"Skipping event interval validation - Actual: {actual_duration_ms:.2f}ms, Reported: {received_event_interval_ms}ms"
)

ten_env.log_info(f"Actual event duration: {actual_duration_ms:.2f}ms")
else:
Expand Down Expand Up @@ -596,4 +613,3 @@ def test_interleaved_requests(extension_name: str, config_dir: str) -> None:
error is None
), f"Test failed: {error.error_message() if error else 'Unknown error'}"


Loading
Loading