Skip to content

Typo in realtime code in calculate_audio_length_ms function #2010

@nbondoux

Description

@nbondoux

Describe the bug

The function calculate_audio_length_ms defined in realtime/_util.py has an issue:

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

if the audio is g711, it will answer a number of milllisecond; however, if the audio is 16bits 24kHz PCM, it will answer a number of microseconds.

Debug information

  • Agents SDK version: (e.g. v0.4.2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions