I am testing a STT - LLM - TTS solution to get bet...
# ask-ai
g
I am testing a STT - LLM - TTS solution to get better stability than the realtime models. I get it to work fine, but feel that the latency is a bit too high, 1,5 - 2 sec for each turn of the agent to start with makes it feel robotic and not "real" How can i improve latency. I am testing in local but plan to run using Cloud Agents. stt = openai.STT(model="gpt-4o-transcribe", language="sv", llm=openai.LLM(model="gpt-5", _reasoning_effort_="minimal", verbosity="low", ), tts = google.beta.GeminiTTS( model="gemini-2.5-pro-preview-tts" vad=silero.VAD.load(), Important that it works for swedish
t
Thanks for reaching out, Jens. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help improve latency in your STT-LLM-TTS pipeline for Swedish, here are some friendly suggestions you might find useful: • Speech-to-Text (STT): I recommend using Google Cloud STT with Swedish language support (language code: "sv-SE"). It’s great for faster and more accurate streaming recognition. Setting a 20ms frame size can really help minimize latency. • Language Model (LLM): Choosing real-time models like OpenAI's "gpt-4o-realtime-preview" instead of sequential ones can make a noticeable difference in processing speed. • Text-to-Speech (TTS): For Google Gemini TTS, try using a model such as "gemini-2.5-pro-preview-tts" and feel free to explore different voice options to find the best balance between quality and speed. • Streaming Architecture: Implementing streaming where incremental transcriptions are processed in real-time, rather than waiting for full speech segments, can really enhance responsiveness. If you'd like, I’m here to help you configure these models or explore other combinations that might work even better for your latency needs. Just let me know!
g
Help me with setting up a streaming achitecture and how to set up the google cloud STT
t
To set up a streaming architecture and configure Google Cloud STT for Swedish, let’s walk through the steps together: Streaming Architecture for STT-LLM-TTS Pipelines • STT Node: This is where Google Cloud STT comes in handy to transcribe your audio frames into text. It supports streaming recognition and works well with the Swedish language. • LLM Node: Next, you’ll process the transcribed text using a real-time language model like OpenAI's "gpt-4o-realtime-preview" to get faster responses. • TTS Node: Then, convert the LLM’s text responses back into audio using Google Gemini TTS models such as "gemini-2.5-pro-preview-tts". • Streaming Configuration: For smooth streaming, use a 20ms frame size to keep latency low and enable interim results so you get real-time feedback. Configuring Google Cloud STT for Swedish Here’s a simple example to get you started:
Copy code
from livekit.plugins.google import STT

stt = STT(
    languages="sv-SE",  # Swedish language code
    detect_language=True,
    interim_results=True,
    punctuate=True,
    model="latest_long",
    sample_rate=16000
)
Key Configuration Parameters: • `languages`: Set this to "sv-SE" for Swedish. • `detect_language`: Turn this on to let the system automatically detect the language. • `interim_results`: This helps by giving you results as they come in, so you get immediate feedback. • `punctuate`: Automatically adds punctuation to make the transcriptions clearer. • `model`: Use "latest_long" for the best recognition performance. Authentication Setup: To get everything running, you’ll need to provide your Google Cloud credentials. You can do this in a few ways: • Using a
credentials_info
dictionary • Providing a
credentials_file
path • Or using Application Default Credentials Streaming Usage: When you’re ready to start streaming, here’s how you create a session:
Copy code
stream = stt.stream(language="sv-SE")
If you’d like, I’m here to help you with implementing this pipeline or configuring any specific parts. Just let me know what you need! Sources: Live Conversations with AI using ChatGPT and WebRTC | livekit-plugins/livekit-plugins-gladia/livekit/plugins/gladia/stt.py | Pipeline nodes and hooks | LiveKit Docs | Live Conversations with AI using ChatGPT and WebRTC
g
Explain the stream function?
t
The
stream()
function in Google Cloud STT is designed to create a real-time streaming transcription session, allowing you to process audio continuously. Let me walk you through how to use and configure it: Basic Usage:
Copy code
from livekit.plugins.google import STT

# Create STT instance
stt = STT(
    languages=["sv-SE"],  # Swedish language code
    model="latest_long",
    interim_results=True
)

# Create streaming session
stream = stt.stream()

# Push audio frames and consume speech events
stream.push_frame(audio_frame)
async for event in stream:
    if event.type == SpeechEventType.FINAL_TRANSCRIPT:
        print(event.alternatives[0].text)
Key Features: • Languages: You can specify language codes like "sv-SE" for Swedish to tailor the transcription to your needs. • Interim Results: This lets you receive real-time feedback by returning interim transcriptions, which can be really helpful. • Session Management: The system automatically handles session timeouts (up to 240 seconds) and reconnects seamlessly for you. • Frame Size: You can choose between 20ms or 100ms frame sizes to balance latency and accuracy according to your preference. • Dynamic Updates: The stream options, such as languages and interim results, can be updated while the session is running. Authentication: To get started, just provide your Google Cloud credentials via a JSON file, dictionary, or environment variable. Advanced Features: • Enable word-level timestamps and confidence scores for more detailed transcription data. • Voice activity detection (VAD) can be used to improve streaming performance. • Errors are handled gracefully with built-in retry and reconnection logic, so you don’t have to worry about interruptions. If you'd like, I’m here to help you further with implementing this function or optimizing it to fit your specific use case. Just let me know! Sources: Live Conversations with AI using ChatGPT and WebRTC | Speech-to-text (STT) models | LiveKit Docs | livekit-plugins/livekit-plugins-rtzr/livekit/plugins/rtzr/stt.py | Google Cloud STT plugin guide | LiveKit Docs
g
Can i work with streaming setup also for Open ai STT? stt = openai.STT(model="gpt-4o-transcribe", language="sv",
t
OpenAI STT, including the "gpt-4o-transcribe" model, doesn’t currently support streaming transcription in its JavaScript implementation. For other implementations, like Python, there isn’t a clear confirmation about streaming capabilities yet. If real-time transcription is something you really need, I’d suggest trying Google Cloud STT, which does support streaming and works well with Swedish. Please feel free to reach out if you'd like any help setting that up—I’m here to assist! Sources: plugins/openai/src/stt.ts
g
I do not get the Google models to do the transcription. I have authenticated throough the CLI but nothing happens with the transcription
t
If you’re having trouble with Google Cloud STT transcription not working after CLI authentication, don’t worry—let’s walk through some common issues and easy steps to get things back on track: • Authentication: Make sure your application can access the credentials. CLI authentication usually sets up Application Default Credentials for you, but you can also set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable to point directly to your JSON credentials file. • Project ID: Double-check that the right Google Cloud project is being recognized. If it’s not, you can specify the project ID explicitly in your configuration. • Location: If you’re working in a specific region, verify that the
location
parameter matches your Google Cloud setup. Otherwise, the default is "global." • API Permissions: It’s important to confirm that your authenticated account has the proper permissions to use the Speech-to-Text API. • Timeouts: Sometimes network conditions can affect things, so check if the default connection timeout is enough for your setup. If you’re seeing any specific error messages, please share them with me—I’m here to help you understand and fix whatever’s going on! Sources: livekit-agents/livekit/agents/voice/agent_activity.py | Google Cloud STT plugin guide | LiveKit Docs