how can I configure the gpt realtime model to only...
# ask-ai
w
how can I configure the gpt realtime model to only speak english?
t
Thanks for reaching out, Nathan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To set up the GPT real-time model to chat only in English within LiveKit, you’ll want to tweak a few settings for the Speech-to-Text (STT) and Text-to-Speech (TTS) parts, plus give the language model clear instructions: • STT Configuration: Just set the
language
parameter to
"en"
in your STT plugin. For example, with OpenAI STT, it looks like this:
stt = openai.STT(language="en")
. • TTS Configuration: Make sure your TTS plugin is also set with
language="en"
. For instance, with ElevenLabs TTS:
tts = elevenlabs.TTS(language="en")
. • Language Model Instructions: Give the model a friendly heads-up like: "You are a helpful assistant. Respond only in English, regardless of input language." Doing this will help keep everything running smoothly in English only. If you want a hand with setting it up or have any questions, just let me know—I’m here to help! Sources: livekit-plugins/livekit-plugins-neuphonic/livekit/plugins/neuphonic/models.... | CLOVA STT integration guide | LiveKit Docs | pipeline-tts/elevenlabs_change_language.py | Speechify TTS integration guide | LiveKit Docs | LiveKit turn detector plugin | LiveKit Docs
w
when I switched to open ai realtimemodel, my agent's transcription_node function stopped getting called. How can I fix that?
t
Hey there! Could you share a bit more about your setup? Specifically: • Are you using a custom implementation for the
transcription_node
function? • What specific configurations or parameters are you using with the OpenAI real-time model? • Have you noticed any error messages or logs when the function stopped being called? Knowing these details will really help us figure out what’s going on and find a solution together.
w
this is my configuration: session = AgentSession[StoryState]( userdata=StoryState(), llm=openai.realtime.RealtimeModel( modalities=["text"] ), tts=cartesia.TTS( model="sonic-2", voice="62305e79-9d39-4643-b003-5e0b096fe4f4", # madison happy language="en", _api_key_=os.getenv("CARTESIA_API_KEY") ), vad=silero.VAD.load(), _user_away_timeout_=16.0, _use_tts_aligned_transcript_=True ) no errors
t
Hey there! So, the issue happens because the OpenAI RealtimeModel doesn’t provide incremental Speech-to-Text (STT) results while the user is speaking. Instead, it waits until the end of the turn to generate transcripts, which means the
transcription_node
function doesn’t get triggered during speech. No worries though! To fix this, you just need to add a separate STT plugin in your
AgentSession
setup. This plugin will handle real-time transcription on its own and send incremental updates into the pipeline, making sure the
transcription_node
is called exactly when you want it to be. Here’s a quick example of how you can set it up:
Copy code
from livekit.agents import AgentSession
from livekit.plugins.openai import realtime, stt as openai_stt

session = AgentSession(
    llm=realtime.RealtimeModel(),  # For conversation and response generation
    stt=openai_stt.STT(use_realtime=False),  # For streaming user transcription
    # other components (vad, tts, etc.) as needed
)
This way, you’re using the OpenAI RealtimeModel for generating responses, and a separate STT plugin to handle real-time transcription smoothly. If you want, I’m here to help you get this all set up—just let me know! Sources: LiveKit turn detector plugin | LiveKit Docs
w
I updated it to use this STT. stt=openai.STT( model="whisper-1", _api_key_=os.getenv("OPENAI_API_KEY"), language="en", _use_realtime_=False ), and this is my transcription_node code: async def transcription_node( self, _text_: AsyncIterable[str | TimedString], _model_settings_: ModelSettings ) -> AsyncGenerator[str | TimedString, None]: """Override transcription node to send timing information to client.""" logger.info("🦁 Transcription node entering") # Process chunks and send timing info async for chunk in text: if isinstance(chunk, TimedString): # Send timing information to the client using built-in timing logger.info(f"🦁 Sending transcription timing: {chunk}") await self.send_transcription_timing({ "text": str(chunk), "start_time": chunk.start_time, "end_time": chunk.end_time }) yield chunk I noticed it only gets called when the agent starts talking but then stops
t
Hey there! The issue happens because OpenAI STT with
use_realtime=False
runs in non-realtime mode, which means it waits until the whole audio segment is processed before giving you the final transcription. So, the
transcription_node
only fires once after the entire transcription is ready, not continuously while you’re speaking. Here’s how you can tackle this: • Make sure VAD is set up: Add a VAD provider (like
silero.VAD.load()
) to your
AgentSession
. This helps detect when someone is speaking and splits the audio properly. • Double-check your audio input flow: Make sure audio frames keep flowing into the STT pipeline. You can use logging to see that audio is being sent through as expected. • Turn on debug logging: Try setting environment variables like
LK_OPENAI_DEBUG=1
so you can peek at the STT requests and responses for more insight. • Think about using realtime mode: If you want continuous transcription updates, switching to
use_realtime=True
with OpenAI’s Realtime API will give you those incremental results. Feel free to reach out if you want a hand with any of these steps or need more troubleshooting help — I’m here for you! Sources: Pipeline nodes and hooks | LiveKit Docs | livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime... | LiveKit turn detector plugin | LiveKit Docs