I’m using the real time openai model, the llm unde...
# ask-ai
p
I’m using the real time openai model, the llm understands what I’m saying but the text transcript of my speech is sometimes way off, and even comes back in random languages, how can we fix this for more accurate text transcript
t
Thanks for reaching out, Scott. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To make your text transcripts more accurate in real-time with OpenAI models, you can turn on the Realtime Transcription API by setting
use_realtime=True
in the OpenAI STT plugin. This way, you get streaming transcript updates and final transcriptions, which really helps with both accuracy and getting quick feedback. Here are a few friendly tips to boost your transcription: • Enable Realtime Transcription: Use the OpenAI Realtime STT API to handle both interim and final transcriptions smoothly. • Configure Voice Activity Detection (VAD): Tweak settings like
threshold
and
silence_duration_ms
to better detect when someone’s speaking. • Apply Noise Reduction: Choose options like
near_field
or
far_field
depending on your mic to cut down background noise. • Enable Language Detection: Turn on
detect_language=True
and add prompts if you want to guide the transcription quality even more. Here’s a simple example to get you started:
Copy code
stt = openai.STT(
    use_realtime=True,
    turn_detection=openai.realtime.ServerVadOptions(
        threshold=0.5,
        prefix_padding_ms=300,
        silence_duration_ms=200
    )
)
This setup helps you get accurate, real-time transcription while staying nicely within OpenAI’s tools. If you have any questions or want a hand with this, just let me know—I’m here to help! Sources: agent/main.py | LiveKit turn detector plugin | LiveKit Docs | Realtime model integrations | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py
p
In using the nodejs v1 agent module. Can you give me snippet of how that would look
t
Hey! Just to make sure I’m on the right track, are you asking about Node.js version 1.x (the early release) or the LiveKit Agents framework v1.x? Let me know so I can give you the best example that fits what you need. Sources: agents/src/llm/realtime.ts
p
The new JS version for agents
t
Here’s a handy example to help you enable real-time transcription using the new JavaScript version of the LiveKit Agents framework with the OpenAI Realtime API:
Copy code
import { RealtimeModel } from '@livekit/agents-plugin-openai';

const model = new RealtimeModel({
    apiKey: process.env.OPENAI_API_KEY, // Just pop in your OpenAI API key here
    voice: 'alloy', // Optional: Choose a voice like 'alloy' or 'shimmer'
    turnDetection: {
        threshold: 0.5, // Tweak this to make turn detection more or less sensitive
        prefixPaddingMs: 300, // Adds a little buffer before speech starts
        silenceDurationMs: 200 // How long silence lasts to mark end of speech
    }
});

// Here’s how you can start transcription
model.startTranscription({
    audioStream: yourAudioStream, // Swap this with your actual audio stream
    onTranscription: (result) => {
        console.log('Transcription result:', result);
    },
    onError: (error) => {
        console.error('Transcription error:', error);
    }
});
This snippet shows you how to set up the
RealtimeModel
with your OpenAI API key, pick your voice and turn detection settings, and handle the transcription results or any errors. If you want me to walk you through any part of it or need a hand, just let me know!
p
We are using the openai realtime model session though. const session = new voice.AgentSession({ llm: new openai.realtime.RealtimeModel({ voice: 'coral', }), });
t
Hey there! If you want to set up the OpenAI RealtimeModel in an AgentSession for real-time transcription, here’s a simple example to get you started:
Copy code
import { openai } from '@livekit/agents-plugin-openai';

const session = new voice.AgentSession({
  llm: new openai.realtime.RealtimeModel({
    voice: 'coral', // Choose the voice you like
    inputAudioTranscription: { model: 'gpt-4o-mini-transcribe' }, // Turn on transcription
  }),
});
This setup will let you enjoy real-time transcription using the OpenAI Realtime API. The
inputAudioTranscription
option is where you pick the transcription model, and the
voice
parameter lets you customize the voice style. If you have any questions or want to tweak this further, just give me a shout—I’m here to help! Sources: livekit-agents/README.md | Realtime model integrations | LiveKit Docs | agent/main.py | plugins/openai/src/realtime/api_proto.ts | OpenAI Realtime API integration guide | LiveKit Docs
p
Is the transcription model more accurate than the realtime model
t
The OpenAI RealtimeModel is built to provide quick, real-time transcription as part of a bigger multimodal system. On the other hand, transcription-only models like Whisper focus mainly on getting speech-to-text accuracy just right, especially for offline or batch tasks. So, while those transcription-only models might give you better accuracy in controlled settings, they don’t offer the real-time speed that the RealtimeModel does. If what you really need is top-notch transcription accuracy and don’t have to worry about real-time processing, a transcription-only model could be a great fit. But if you’re working on something that needs fast, real-time results, the RealtimeModel offers a nice balance between accuracy, low latency, and smooth integration. Feel free to reach out if you want to chat more or need help figuring out what works best for your situation! Sources: Live Conversations with AI using ChatGPT and WebRTC | tests/test_tts.py