Repeated TTS Errors and Audio Playback Delays with Fish Audio in LiveKit Agents via inference

Hi LiveKit Community,

I’m experiencing two recurring issues with my LiveKit voice agent and would appreciate your help identifying the root causes. Only change that i did recently was enabling PII in livekit observability settings.

I’m using LiveKit Agents with Python and LiveKit Inference, with Fish Audio as the TTS provider and fishaudio/drama-3 and s2.1 pro as the model.

Issue 1: TTS Generation Errors

I have been encountering repeated TTS errors throughout this week. The session trace indicates an APIError during TTS generation, and the agent does not appear to complete the speech-generation process successfully.

Session trace: https://cloud.livekit.io/projects/p_3scf9tt1e2i/sessions/RM_dqR6BcCd23e8/observability?mode=trace&t=1793189226717

Issue 2: Audio Playback Delays and Unexpected Cutoffs

In another session, the audio was unexpectedly cut off during playback and then resumed after a delay. This resulted in an interrupted and inconsistent audio experience.

Session observability link: https://cloud.livekit.io/projects/p_3scf9tt1e2i/sessions/RM_FZAhwEXQjJVb/observability?mode=transcript&t=1793191240745

Environment Details

  • Framework: LiveKit Agents
  • Language: Python
  • TTS Provider: Fish Audio via LiveKit Inference
  • Model: fishaudio/drama-3as well as with s2.1pro
  • Error Type: APIError

Could someone help investigate what might be causing these two issues? I’d like to understand whether the TTS errors and playback interruptions could be related to provider-side issues, inference latency, streaming behavior, or another problem in the LiveKit pipeline.

Since these issues have occurred multiple times this week, any guidance on troubleshooting steps or relevant logs to inspect would be greatly appreciated.

Thank you!

Thanks for sharing those sessions, I took a look at both of them.

I don’t see an obvious common root cause and it looks like the second case was using s2.1-pro, so a different model from the first.

The obvious place to start looking, since this is Inference, is between ourselves and Fish Audio, but I don’t see anything in our internal monitoring that points to this being a more general issue, either with ourselves or with Fish Audio.

That exception details redacted error is frustrating, isn’t it.

Was it a clear cut ‘it was working fine before, then once I disabled PII in agent observability, it started happening’. I haven’t seen that before, but it’s worth asking.

Well i cant say that is purely because of PII in agent observability, and i cant disable it now for security reasons, also it happens for both models drama/s2.1 pro, so i am really not sure what could be issue here.

https://cloud.livekit.io/projects/p_3scf9tt1e2i/sessions/RM_QbhzZRiMNxjA/observability?mode=metrics

Here’s another one, if it helps. Since this happens 4-5 times a day, it severely damages trust for the users experiencing it.

Logs has different error for those sessions. `TTS failed after partial audio was already sent to the user, skip retrying.`

Another one

https://cloud.livekit.io/projects/p_3scf9tt1e2i/sessions/RM_ZfnYot6gmRSQ/observability?mode=trace&t=1793219899083

Let me set up some tests to try and reproduce this

I spent a fair bit of time this morning trying to reproduce this. I wasn’t able to reproduce the issues either by invoking the TTS directly, or by running LiveKit agent simulations with a similar set up to yours.

The root cause is a stall from Fish audio, either mid-generation, or it never starts generating - our gateway then times out.

Everything I’m seeing is pointing towards this being a transient Fish audio issue where a very small percentage of requests are stalling, not something in our gateway, and not something specific to your project. It looks like there was a spike yesterday, but I don’t see anything on Fish’s status page. That’s probably why this hit you for those two sessions yesterday.

If I see a similar spike during US business hours today, I’ll follow up with our gateway team.

I’ll also copy Claude’s analysis below, which is sort of interesting, but nothing definitive:

Fish Audio stopped streaming partway through an utterance (or never started), and our gateway ended the request after its stall timeout. This happens to a small fraction of Fish requests across all customers, and your rate matched everyone else’s.

You can’t stop the provider stalling, but you can make recovery much smoother:

  1. Recover the cut-off sentence. When a stall happens partway through a reply, the SDK can’t retry, because audio has already played. Listen for the session’s error event. When it’s a non-recoverable TTS error, have the agent pick up where it left off, for example with session.generate_reply(instructions="Your last reply was cut off. Briefly finish what you were saying."). That turns a cut-off and long silence into a short hiccup.
  2. Avoid [long pause] on drama-3. Newer SDK versions deliberately map long pauses to [pause] for drama-3, because [long pause] can produce many seconds of silence. In your prompt, use [pause] instead, or let the SDK’s expressive mode generate the markup.
  3. Upgrade from 1.8.8. Newer releases include improvements to Fish Audio markup handling, among other fixes.

Hi, thanks for looking into this. A transient stall on Fish’s side makes sense.

One thing on the recovery suggestion: with a FallbackAdapter, a stream that dies after partial audio never reaches session.on("error"). The adapter treats the instance as having served the request. The only signal is the "TTS failed after partial audio" log line, and the reply is stored as complete and not interrupted. So generate_reply recovery can’t trigger, and the LLM believes it said everything.

I’ll also copy Claude’s analysis below from what i can get so far to forward to your team:

  1. Gateway: retry or fail over when no audio has been sent yet. A stall before the first byte is safe to retry.
  2. Gateway: a shorter or configurable time-to-first-byte timeout. What’s the current stall timeout?
  3. SDK: mark the ChatMessage/SpeechHandle as interrupted (or emit an event) when TTS fails after partial audio.
  4. SDK: have FallbackAdapter forward inner-instance error events. Right now it forwards only metrics.
  5. Traces: show the provider error type and whether the stream never started or stalled mid-stream.

Thanks.

I checked our monitoring over the past 24 hours and things look much better, which would also explain why I also couldn’t reproduce this yesterday.

Sorry, that’s on me. Claude’s previous first point was daft, so I’d deleted it before sending, but I should also have deleted that one.

I think it did solved for us, from last 2 days i cant see any issues, probably some issues on fishaudio, but its worth to check/fix livekit side as livekit should recover from such error or retry instead of skip partial tts error that just goes silent after mid.

@darryncampbell it happened again on 31st oct. i had turn off redaction for some time to capture full error.

https://cloud.livekit.io/projects/p_3scf9tt1e2i/sessions/RM_H97JLMrRPAXk/observability?mode=metrics

I hope this will help to fix the issue, will turn on redaction again

I should have realised this before, but you are using an agent fallback adapter I believe, not an Inference fallback adapter. More info here: Fallback strategies | LiveKit Documentation but essentially the Inference fallback adapter would have been able to recover more efficiently and cleanly on both 28/Oct and 31/Oct:

Behavior

The Inference Fallback Adapter treats any error as a reason to try the next provider in the chain, including errors during session creation, connection, and mid-stream. If the primary provider fails partway through streaming a response, the service switches to the next model and restarts the request from the beginning. The service only stops trying providers when all configured models have failed or the client disconnects.

The downside is you can’t specify your plugin recovery in the Inference fallback, i.e. the s2.1-pro-free model, though honestly that is probably not a bad thing as if this was a transient issue on Fish side, I would expect it to impact both the plugin and Inference. I would recommend using a different provider for your fallback - the change of voice might be slightly jarring (depending on voice choices), but it would probably be more reliable.

Thanks, that explains it. You’re right that we were only using the agent-side tts.FallbackAdapter, so a mid-stream Fish stall couldn’t recover.

We’ve now added the Inference fallback on the primary:

inference.TTS(
    model="fishaudio/s2.1-pro",
    voice=VOICE_ID,
    fallback=[
        {"model": "fishaudio/s2-pro", "voice": VOICE_ID},
        {"model": "fishaudio/drama-3", "voice": VOICE_ID},
    ],
)

We’ve kept the agent-side adapter as a last resort for when Inference itself can’t be reached. It goes straight to Fish through the plugin.

We’ve stayed with Fish models for now to keep the same voice.

Two quick questions:

  1. Does a fallback model use the same voice ID as the primary when both are Fish models?
  2. Will the agent see an event or metric when Inference switches to a fallback model, so we can track how often it happens?

It will use whichever voice ID you specify for that model in the fallback array. Some TTS providers tie their voices to a model but Fish does not, so you should be OK using the same ID (however, it’s definitely worth testing each combination individually, which I’m sure you have done). That wouldn’t mean the voice would sound identical with each model, but it should sound similar.

Of course, this setup would not be resilient if Fish Audio becomes unavailable for whatever reason, but you understand that :slight_smile:

I thought it did, but it seems I was mistaken. There is an open PR that would return this information: Expose TTS fallback controls and activation events (LKINF-495) by russellmartin-livekit · Pull Request #7185 · livekit/agents · GitHub . It’s been open a while but there’s a lot of very recent activity.

Thanks, i will see if this solves our issues and will keep eye on this PR to see if merged so we can track fallbacks switch