model = openai.realtime.RealtimeModel( voi...
# ask-ai
r
model = openai.realtime.RealtimeModel( voice="shimmer", temperature=0.8, _input_audio_transcription_=None, model="gpt-4o-realtime-preview-2025-06-03", modalities=["text"], _turn_detection_=TurnDetection(type="server_vad", threshold=0.45, _silence_duration_ms_=500), ) can I add 800h zto this
t
Thanks for reaching out, Rhythm. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just to make sure I’m on the same page, could you please clarify what you mean by "add 800h zto this"? Are you talking about adding a feature, a parameter, or something else to the code snippet you shared?
r
8000 hertz input audio - can i add that custimzitaion ot hts
t
Hey! Could you let me know which RealtimeModel implementation you're using (like OpenAI, Google, AWS)? That way, I can give you the best advice on setting up your 8000 Hz input audio. Thanks! Sources: plugins/openai/src/realtime/realtime_model.ts | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti...
r
penai
Openai
t
Hey there! Just a quick heads-up: the OpenAI RealtimeModel in LiveKit expects audio at a fixed sample rate of 24000 Hz, so it doesn’t directly support 8000 Hz input. But no worries—you can easily resample your 8000 Hz audio to 24000 Hz before sending it over. Here’s a friendly example using LiveKit’s
AudioResampler
in Python to help you out:
Copy code
from livekit import rtc

# Create a resampler to convert from 8000 Hz to 24000 Hz
resampler = rtc.AudioResampler(
    input_rate=8000,
    output_rate=24000,
    num_channels=1,
    quality=rtc.AudioResamplerQuality.MEDIUM
)

# Resample your 8000 Hz audio frames
def resample_audio_frame(audio_frame_8khz):
    resampled_frames = resampler.push(audio_frame_8khz)
    return resampled_frames
After resampling, you can go ahead and send the audio to the RealtimeModel just like usual. If you run into any hiccups or want to chat more about this, I’m here to help—just let me know! Sources: plugins/openai/src/realtime/api_proto.ts | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | livekit-rtc/livekit/rtc/audio_resampler.py | RealtimeModel | LiveKit Agents