what is the best stt with low latency that can und...
# ask-ai
b
what is the best stt with low latency that can understand low audio, we have customers that tends not to speak loud at all and want to improve the accuracy
t
Thanks for reaching out, timothe. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
For low-latency speech-to-text (STT), Google Cloud's Speech-to-Text service is a fantastic choice, especially since LiveKit has optimized it for real-time interaction. If you're working with low-volume audio, Gladia might be a better fit because of its built-in audio enhancer that really helps improve transcription accuracy for quieter or degraded inputs. Here are a couple more options you might find helpful: • Cartesia: This offers an "ink-whisper" model that's specially designed for low-volume or whisper-like speech. • Baseten: It lets you configure Voice Activity Detection (VAD) parameters, which can be great for picking up speech even in noisy or low-audio settings. LiveKit supports multiple STT providers through its Agents SDK, so you have the flexibility to choose the one that fits your needs best. If you'd like, I’m here to help guide you through setting up any of these options—just let me know! Sources: Live Conversations with AI using ChatGPT and WebRTC | agents/src/inference/stt.ts | livekit-plugins/livekit-plugins-spitch/livekit/plugins/spitch/stt.py | Live Conversations with AI using ChatGPT and WebRTC | Live Conversations with AI using ChatGPT and WebRTC
b
min_interruption_words used to work with deeprgamm but not with cartesia anymore?
t
The
min_interruption_words
parameter is designed to work smoothly with any STT provider integrated into LiveKit, including Cartesia. It helps by setting the minimum number of words needed in a transcription to count as a valid interruption. If it’s not working as expected with Cartesia, it might be due to a configuration hiccup or a unique situation causing the difference. Please feel free to reach out if you'd like me to help you troubleshoot this further—I’m here to support you! Sources: Turn detection and interruptions | LiveKit Docs | Cartesia STT plugin guide | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py
b
agent = AgentSession( vad=ctx.proc.userdata["vad"], min_interruption_duration=1, min_interruption_words=3, stt=stt.FallbackAdapter([ cartesia.STT(model="ink-whisper", language="fr"), ]),
t
Just to let you know, the
min_interruption_words
parameter is supported in LiveKit's
AgentSession
no matter which STT provider you're using. That includes Cartesia's
ink-whisper
model when the language is set to 'fr'. If it’s not working as you expected, it might be due to a configuration or runtime hiccup. I'd be happy to help you troubleshoot this further—would you like some assistance with that? Sources: Turn detection and interruptions | LiveKit Docs | tests/test_agent_session.py
b
the cartsia stt always sends ... or ...... or ......... when not understanding a sentace clearly would it be possible not to send these audios to the llm if we detect it contains this
t
Hey there! You can easily filter out Cartesia STT transcriptions that contain patterns like '...' before sending them to the LLM by overriding the
stt_node
method in your agent class. This way, you get to intercept and clean up the transcription output in real time, which is pretty handy. Here’s a friendly example to guide you through it:
Copy code
import re
from livekit.agents import Agent
from livekit.plugins import cartesia

class FilteredSTTAgent(Agent):
    def __init__(self):
        super().__init__(
            stt=cartesia.STT(),  # Using Cartesia STT plugin
            # ... other configurations (LLM, TTS, etc.)
        )

    async def stt_node(self, chat_ctx):
        async def filtered_stream():
            # Use default STT node to get raw transcription stream
            async for event in self.default.stt_node(chat_ctx):
                # Filter out unwanted patterns like '...'
                if event.type == "final_transcript" or event.type == "interim_transcript":
                    for alt in event.alternatives:
                        # Remove ellipsis and similar patterns
                        alt.text = re.sub(r"\.{2,}", "", alt.text).strip()
                        # Optionally filter out empty transcriptions
                        if alt.text:
                            yield event
                else:
                    yield event

        return filtered_stream()
This approach helps make sure only clean and meaningful transcriptions reach the LLM. If you have any questions or want a hand setting this up, just let me know—I’m here to help! Sources: Pipeline nodes and hooks | LiveKit Docs | Cartesia STT plugin guide | LiveKit Docs | docs/index.yaml
b
and completely discard the audio?
t
I’m happy to help you with filtering out audio transcriptions that contain patterns like '...' before sending them to the LLM. You can do this by overriding the
stt_node
method in your agent. This way, you can catch transcription events and skip those that match the patterns you want to exclude. Here’s a simple example to guide you:
Copy code
async def stt_node(self, audio, model_settings):
    async for event in self.default.stt_node(audio, model_settings):
        if event.type == "final_transcript":
            text = event.alternatives[0].text.strip()

            # Define patterns to filter out
            if "..." in text:
                continue  # Skip this transcription event

        yield event  # Pass through other events
This approach will help you discard any transcriptions containing '...' so they won’t be sent to the LLM. If you’d like, I’m here to assist you further with implementing this or answering any questions you might have! Sources: Pipeline nodes and hooks | LiveKit Docs | livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/tts.py | docs/index.yaml
b
agent = AgentSession( stt,llm,tts ) await ctx.wait_for_participant() await agent.start( room=ctx.room, agent=agentPrompt, room_input_options=RoomInputOptions( #noise_cancellation=noise_cancellation.BVC(), ), room_output_options=RoomOutputOptions(transcription_enabled=False), ) #await agent.say(f"Bonjour {participant.identity}! Comment vas-tu ?", allow_interruptions=True) #await agent.say("", allow_interruptions=True) #room = rtc.Room() log_queue = asyncio.Queue() async def stt_node(self, audio, model_settings): async for event in self.default.stt_node(audio, model_settings): if event.type == "final_transcript": text = event.alternatives[0].text.strip() logger.info("message audio") # Define patterns to filter out if "..." in text: logger.info("message ... recu et retire") continue # Skip this transcription event yield event # Pass through other events
t
It looks like your implementation of the
stt_node
method is on the right track for filtering out transcriptions that contain "..." and logging those events. You’ve done a great job ensuring that any transcription with "..." is skipped and not processed further. If you run into any hiccups or want to explore tweaks like handling other patterns or making the logging even smoother, just give me a shout—I’m here to help!
b
but how can i improve the sound because the persons don't speak very loud
t
I'm here to help you improve audio quality for low-volume speech in LiveKit! Here are some friendly tips you can try: • Amplify Agent Speech Volume: You can gently boost the volume by adjusting the
tts_node
or
realtime_audio_output_node
in your agent with a volume multiplier. It’s a great way to make speech clearer. • Enable Noise and Echo Cancellation: Using WebRTC-based noise suppression and echo cancellation, or turning on Background Voice Cancellation (BVC), can really help clean up the audio and make voices stand out. • Apply Audio Processing Modules (APM): Features like automatic gain control (AGC), high-pass filtering, and noise suppression can be enabled in the agent session to enhance sound quality. • Use Client-Side Volume Control: You can also adjust the playback volume directly on the frontend with the LiveKit client SDK, giving you more control over what you hear. • Enhance Speech Quality with Text Pacing: For TTS, turning on text pacing can improve how naturally the speech flows and sounds. If you’d like, I’d be more than happy to walk you through any of these steps in detail. Just let me know! Sources: livekit-agents/livekit/agents/voice/chat_cli.py | livekit-rtc/livekit/rtc/audio_resampler.py | .cursor/rules/agent-core.mdc | Agent speech and audio | LiveKit Docs | Noise & echo cancellation | LiveKit Docs
b
how do i implement apm inside my agent
t
I'd love to help you with your audio processing needs! Could you please share which specific features you're interested in adding to your agent? For instance, are you thinking about noise suppression, echo cancellation, automatic gain control, or maybe something else? Knowing this will really help me guide you better.
b
the audio gain control
t
I'm glad you're exploring how to implement a high-pass filter in your LiveKit agent! You can achieve this using the
AudioProcessingModule
in the Python SDK. Here's a simple example to guide you:
Copy code
from livekit.rtc import apm

# Configure APM with high-pass filter enabled
audio_processor = apm.AudioProcessingModule(
    echo_cancellation=True,
    noise_suppression=True,
    high_pass_filter=True,  # Enable high-pass filter
    auto_gain_control=True
)

# Process an audio frame (must be 10 ms duration)
# audio_frame = ... # rtc.AudioFrame
# audio_processor.process_stream(audio_frame)
This setup helps by enabling the high-pass filter to reduce low-frequency noise like microphone rumble. If you have any questions or would like examples for other SDKs, please feel free to ask—I'm here to help! Sources: Enhanced noise cancellation | LiveKit Docs | stream_audio.py | livekit-rtc/livekit/rtc/_proto/audio_frame_pb2.pyi | livekit-ffi/src/livekit.proto.rs | packages/livekit-rtc/src/proto/ffi_pb.ts
I'm glad you're looking into implementing audio gain control in your LiveKit agent! You can achieve this by using the
AudioProcessingModule
(APM) to enable automatic gain control (AGC), which smartly adjusts audio levels to keep the volume consistent and clear. Here’s a friendly example in Python to help you get started:
Copy code
from livekit.rtc import apm

# Configure APM with automatic gain control enabled
audio_processor = apm.AudioProcessingModule(
    echo_cancellation=True,
    noise_suppression=True,
    high_pass_filter=True,
    auto_gain_control=True  # Enable automatic gain control
)

# Process an audio frame (must be 10 ms duration)
# audio_frame = ... # rtc.AudioFrame
# audio_processor.process_stream(audio_frame)
This setup will help ensure your audio sounds balanced and consistent. If you have any questions or need a hand with the implementation, feel free to reach out—I’m here to help!
b
but where do i put that inside of my agent?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
b
i still have a bit of an echo left because the sound of the agent is too loud