Hello Dears
Model: Openai API Realtime mini or realtime 1.5
IMPORTANT: It is an existential problem (happened since the beginning with realtime model also - this is not something new. )
Problem Desc:
- Caller Calls in one language example English
- Language is detected (As English) and turn completes in the language English.
- Caller Speaks again in the SAME language as before (English)
- Realtime model detects another language. (very unpredictable) and turns in a different language.
Solution (The solution We were forced to do): (The only way we could get predictability)
Call the Language Detection TOOL {set_detected_language} with EACH TURN.
And now we have a good release and it is stable. Great. We released and it’s in production. So It is working.
====
But at this stage, I am not happy with just stability or just “its working”.
I made a count of a standard call (4 min, couple of turns, vector storage question and answers") - nothing fancy and purely realistic. Imagine an example of a hotel or booking.com with questions like “how much is the room, do you have a pool, do you have breakfast”, very simple utterances.
And counted how many tokens we are wasting just by firing this tool. The result is shocking.
Every time the caller spoke, our code injected a system message:
“Update the participant’s current language before continuing.” – which forces a full response cycle just to call set_detected_language(“English”) and get back “Language set to: English”.
For this standard call, it happened 13 times in this call, always returning the same result.
Each cycle costed:
- 1 response_created +
- function_call round-trip +
- function_call_output +
- another response_created.
That is roughly 1,400 tokens of overhead per turn just for this one pattern.
Across 13 turns I consumed: 18,200 tokens.
18k out of 32k is more than 50%!!! how can I sustain this behavior?
The design intent is correct — detect language once. But I am forced to re-detects on every single turn regardless of whether the language has changed or was already known otherwise the realtime model WILL drift and start to detect languages without control.
And if I remove this? What will happen?
You can for example speak PERFECT English and if the caller’s name happens to be of Arabic descent example “Amir”, then realtime switches to Arabic. Or if the caller is Sofia, you would get Russian. Sarvesh speaking perfect English, might get hindu back. Take my word for it. Its a problem. And yes, I tried at length in the prompt telling the model “DO NOT CHANGE BASED ON ONE WORD OR ONE NAME OR ONE UTTERANCE” etc etc. Useless.
Or it might catch some dialect - example Perfect english, with a little Italian accent - Will switch to Italian or Spanish right off the bat.
Are there ways to overcome this, or plans to improve the language detection in the future?
Thanks so much guys and keep up the great work!!
God bless