I've started experiencing extreme latency with the...
# ask-ai
w
I've started experiencing extreme latency with the tts model. What happens is I see the text output streaming along with audio output, but then halfway through the response, the audio cuts out and the text keeps going. The text finishes and then something like 20 sec or more later, the audio starts again. This seems to be a recent issue. Using the Python SDK
t
Thanks for reaching out, Spencer. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're facing audio cutout and latency issues with the TTS model in the Python SDK. These problems can come from a few different places, but don’t worry—we can work through them together! Here are some helpful steps you can try to troubleshoot and hopefully resolve the issue: 1. Check Your Instance Type: If you’re using AWS t3/t4 burstable instances, sometimes CPU credits can run out and cause throttling. Switching to non-burstable instances like m5 or c5 can provide more consistent performance. 2. Use Streaming Mode: Make sure you’re using the
stream()
method for real-time audio generation, rather than
synthesize()
, which waits to process the full text before generating audio. 3. Latency Configuration: If your TTS provider offers latency modes (like normal or balanced), try setting it to a lower latency option. 4. Adjust Timeout Settings: Increasing the timeout parameter in your API calls can help avoid premature termination, especially for longer responses. 5. Real-Time Audio Processing: Double-check that your code processes and emits audio chunks as they come in, instead of buffering the entire response first. 6. Monitor Metrics: Using telemetry metrics such as time-to-first-byte (TTFB) can help pinpoint where delays might be happening. To make sure I’m guiding you in the right direction, could you please confirm a few things for me? • Are you currently using the
stream()
method for real-time audio? • Is your infrastructure running on burstable instances, and have you had a chance to check the CPU credit balance? • Have you tried testing with different TTS providers to see if the issue still occurs? Feel free to share any details you have—I’m here to help you get this sorted out! Sources: pipeline-tts/tts_comparison/README.md | How to Handle Speech Interruptions More Naturally | Troubleshooting Latency and Timeout Errors with Turn Detection on AWS | livekit-plugins/livekit-plugins-inworld/livekit/plugins/inworld/tts.py
w
how do I tell if I'm using stream()? Also I'm using the openai TTS.
t
Let's take a look together to see if you're using the
stream()
method in your Python SDK implementation: 1. Check Your Code: Try to find a call to
stream()
in your TTS implementation. If you're working with OpenAI TTS, it might be wrapped with a
StreamAdapter
to enable streaming. 2. Programmatically Verify: You can use this little snippet to check if the
stream()
method is available:
Copy code
if hasattr(tts_instance, 'stream'):
    print("The stream() method is available.")
else:
    print("The stream() method is not available.")
If it turns out you're not using
stream()
, the audio might only be generated after the entire text is processed, which can sometimes lead to delays. Please feel free to reach out if you'd like help with this or need guidance on setting up OpenAI TTS for streaming. I'm here to help! Sources: livekit-plugins/livekit-plugins-inworld/livekit/plugins/inworld/tts.py