Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/agents/realtime/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
def calculate_audio_length_ms(format: RealtimeAudioFormat | None, audio_bytes: bytes) -> float:
if format and isinstance(format, str) and format.startswith("g711"):
return (len(audio_bytes) / 8000) * 1000
return (len(audio_bytes) / 24 / 2) * 1000
return (len(audio_bytes) / 24000 / 2) * 1000
Comment on lines 6 to +9

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update tests for corrected PCM duration

Switching the PCM branch to divide by 24000 instead of 24 fixes the sample‑rate bug but also changes every computed duration by 1/1000. The existing tests still assert values based on the old 24 constant (e.g., tests/realtime/test_openai_realtime.py::test_calculate_audio_length_ms_pure_function expects 48 bytes to equal 1000 ms, and tests/realtime/test_playback_tracker.py uses the same assumption), so the suite will now fail and callers relying on those expectations may still treat 48 bytes as one second. The tests and any hard‑coded comments need to be updated to use 24 kHz math (len(bytes) / (24000 * 2) * 1000) to keep the build green and ensure downstream logic matches the corrected behavior.

Useful? React with 👍 / 👎.