The transcription shows non-conversational part to...
# ask-ai
c
The transcription shows non-conversational part too. I'm using voice agents with gemini realtime model
**Acknowledge Minimal Input**
I see the user provided a single period. It feels like a very brief input, not a query, but a signal to continue. Previously, I greeted them and checked if they were ready. I'll re-initiate the background phase by asking them once more if they are ready to begin.
It looks like we're ready to begin. Are you ready to start with some background questions?
t
Thanks for reaching out, Aditya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding about the transcription showing non-conversational parts and your handling of a minimal input ("."), while using voice agents with the Gemini realtime model. Could you clarify two quick things so I can give targeted guidance? 1. Do you want the transcript to exclude non-conversational audio (silence, system prompts, breaths, agent internal notes), or do you want to mark/label those segments in the transcript? 2. Where are you receiving the transcription output now —: from LiveKit's built-in transcription pipeline, from Gemini's realtime output streamed into your app, or from a downstream service you run after capture? With those answers I’ll suggest specific filtering/configuration steps you can apply (real-time rules, post-processing heuristics, or labeling approaches).
c
1. I just want to remove the agent internal notes. 2. I think it's from Gemini, this is my agent init:
session = AgentSession(
3.
llm=google.beta.realtime.RealtimeModel(
4.
model="gemini-2.5-flash-native-audio-preview-09-2025",
5.
instructions=instructions,
6.
language="en-US",
7.
temperature=0.8,
8.
voice="Puck",
9.
max_output_tokens=350,
10.
_gemini_tools=[],
11.
tool_behavior=types.Behavior.NON_BLOCKING,
12.
tool_response_scheduling=types.FunctionResponseScheduling.SILENT,
13.
input_audio_transcription=types.AudioTranscriptionConfig(),
14.
output_audio_transcription=types.AudioTranscriptionConfig(),
15.
# Enable context window compression to manage history
16.
context_window_compression=types.ContextWindowCompressionConfig(
17.
trigger_tokens=14000,
18.
sliding_window=types.SlidingWindow(
19.
target_tokens=8000,
20.
)
21.
)
22.
),
23.
allow_interruptions=True,
24.
user_away_timeout=60,
25.
)
t
Thanks — you're asking how to remove the agent internal notes from Gemini's realtime transcription. Good news: you can suppress them. Add a
thinking_config
that disables thoughts to your
RealtimeModel
init. Example change:
Copy code
llm=google.beta.realtime.RealtimeModel(
    model="gemini-2.5-flash-native-audio-preview-09-2025",
    instructions=instructions,
    language="en-US",
    temperature=0.8,
    voice="Puck",
    max_output_tokens=350,
    _gemini_tools=[],
    tool_behavior=types.Behavior.NON_BLOCKING,
    tool_response_scheduling=types.FunctionResponseScheduling.SILENT,
    input_audio_transcription=types.AudioTranscriptionConfig(),
    output_audio_transcription=types.AudioTranscriptionConfig(),
    context_window_compression=types.ContextWindowCompressionConfig(
        trigger_tokens=14000,
        sliding_window=types.SlidingWindow(target_tokens=8000),
    ),
    thinking_config=types.ThinkingConfig(
        include_thoughts=False,
    ),
)
This prevents the model's internal "thinking" or tool-call notes from appearing in the transcript while keeping the spoken outputs intact. If you'd like, I can also suggest a lightweight post-processing filter (regex or event-based) in case you want to both suppress in realtime and keep an internal log of those thoughts. Would you prefer that? Sources: Gemini Live API plugin | LiveKit docs | Real-time AI Models & Streaming | livekit/livekit_composite | DeepWiki
c
is it enabled by default on gemini 2.5 flash 09 2025?
t
Yes — for the
gemini-2.5-flash-native-audio-preview-09-2025
model, the model's internal "thinking" notes are included by default. Disable them by setting
thinking_config=types.ThinkingConfig(include_thoughts=False)
in your
RealtimeModel
init (as shown earlier).
c
It's working now, it sometimes give half sentences like this "The sentence after "Please describe your approach" was the end of the question. Please describe your approach to solving this problem. You do not need to repeat the question. Would"
t
Thanks — you're seeing partial/interim transcriptions from Gemini realtime. Quick summary and next steps: • Why it happens: Gemini Live streams interim results; partial sentences can arrive before the model finalizes them and cannot be intercepted or filtered when using the model's built-in realtime audio mode. • Short fixes: ◦ If the partials are in the user transcript, switch to text-only LLM mode and use an external STT (AssemblyAI/Deepgram/etc.) so you can buffer/validate full sentences before sending them to the LLM. ◦ If the partials are in the agent's spoken output, post-process the agent text (e.g., in a
tts_node
) to trim incomplete trailing fragments. • Recommendation: I can provide a concise example of a custom
stt_node
that buffers until a full sentence (heuristics: punctuation, min words, VAD gap) before forwarding, or a
tts_node
snippet to clean agent output. Which would you like? Sources: Gemini Live API plugin | LiveKit docs | Realtime model plugins | LiveKit Docs | Pipeline nodes and hooks | LiveKit docs
c
a
tts_node
snippet to clean agent output
t
Below is a concise Python
tts_node
example that trims incomplete trailing fragments from the agent's generated text before yielding it to the TTS engine. It detects likely incomplete endings (no terminal punctuation or trailing short fragments) and removes them so the spoken output doesn't stop mid-sentence.
Copy code
import re
from livekit.agent import Agent

# Helper: returns True if text looks like a complete sentence
def is_complete_sentence(text):
    text = text.strip()
    if not text:
        return False
    # Ends with terminal punctuation
    if re.search(r'[.!?]"?$' , text):
        return True
    # Very short (likely not a full spoken sentence)
    if len(text.split()) < 3:
        return False
    return False

# Helper: trim trailing fragment after last terminal punctuation
def trim_to_last_sentence(text):
    # Find last terminal punctuation and keep everything up to it.
    m = re.search(r'(.+[.!?])[^.!?]*\s*$', text, re.DOTALL)
    if m:
        return m.group(1).strip()
    # No terminal punctuation — if long enough, return as-is, else return empty
    if len(text.split()) >= 6:
        return text.strip()
    return ""

class MyAgent(Agent):
    async def tts_node(self, text, model_settings):
        # Pre-clean common artifacts (whitespace, repeated spaces)
        text = re.sub(r'\s+', ' ', (text or "")).strip()

        # If it's already a complete sentence, yield directly
        if is_complete_sentence(text):
            async for chunk in Agent.default.tts_node(self, text, model_settings):
                yield chunk
            return

        # Otherwise try to trim trailing incomplete fragment
        cleaned = trim_to_last_sentence(text)
        if not cleaned:
            # As a fallback, keep up to a safe word limit to avoid very short fragments
            words = text.split()
            cleaned = " ".join(words[:max(0, min(len(words),  max(6, len(words)//2)))])
            cleaned = cleaned.strip()

        if cleaned:
            async for chunk in Agent.default.tts_node(self, cleaned, model_settings):
                yield chunk
        else:
            # If nothing safe remains, yield nothing (silence) to avoid half-sentence speech
            return
If you want, I can: • Tune the heuristics (word thresholds, punctuation rules) to your voice/style. • Provide a version that logs the removed fragments for debugging. Which would you prefer?