Can I use Qwen TTS model? If yes, how can I use it...
# ask-ai
f
Can I use Qwen TTS model? If yes, how can I use it?
t
Thanks for reaching out, Baymurat. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks for reaching out! I wanted to let you know that the Qwen TTS model isn’t supported in LiveKit at the moment. Qwen is available as a Large Language Model (LLM) for inference, but not for text-to-speech (TTS) purposes. If you're interested in using TTS models, LiveKit offers support for several great providers like Cartesia, ElevenLabs, Rime, Inworld, and PlayAI. You can easily set these up by passing their identifiers to the
tts
argument in your
AgentSession
configuration. Here’s a quick example:
Copy code
session = AgentSession(
    llm="openai/gpt-4o-mini",
    tts="cartesia/sonic-2:9626c31c-bec5-4cca-baa8-f8ba9e84c8bc",  # Example with Cartesia
    stt="assemblyai/universal-streaming:en"
)
If you’d like, I’m here to help you set up any specific TTS model or answer any questions you have—just let me know! Sources: Qwen LLM | LiveKit Docs | examples/voice_agents/realtime_load_chat_history.py | tools/server/README.md | Models | LiveKit Docs
f
How can I add a custom TTS model?
t
I'd be happy to help you add a custom TTS model in LiveKit! You can do this by overriding the
tts_node
in your agent to seamlessly integrate your own TTS system. This approach lets you use a custom TTS engine, apply pronunciation rules, and manage audio processing just the way you need. Here's a simple overview to get you started: 1. Create a custom class that extends
tts.TTS
. 2. Implement the necessary methods like
synthesize()
or
stream()
to connect with your model. 3. Override the
tts_node
in your agent pipeline to utilize your custom TTS instance. 4. If you'd like, you can also use SSML or preprocessing hooks for better pronunciation control. Here's an example to illustrate:
Copy code
class CustomTTS(tts.TTS):
    def __init__(self, model_path, voice_id):
        super().__init__(capabilities=tts.TTSCapabilities(streaming=True), sample_rate=24000)
        self.model_path = model_path
        self.voice_id = voice_id

    def synthesize(self, text):
        # Implement your custom synthesis logic here
        pass

class Agent(VoiceAgent):
    async def tts_node(self, text, model_settings):
        custom_tts = CustomTTS(model_path="path/to/model", voice_id="custom_voice")
        async for text_chunk in text:
            audio_stream = custom_tts.synthesize(text_chunk)
            async for audio_frame in audio_stream:
                yield audio_frame
If you'd like, I can walk you through implementing a specific custom TTS backend or assist with any particular part of your setup. Just let me know how I can support you best! Sources: Pipeline nodes and hooks | LiveKit Docs | livekit-agents/livekit/agents/voice/agent.py | agents/src/inference/tts.ts | Text-to-speech (TTS) models | LiveKit Docs | LMNT TTS plugin guide | LiveKit Docs
f
t
To integrate Qwen3-TTS-Flash into LiveKit, you can create a custom TTS plugin. Here’s a step-by-step guide to help you through the process: 1. Deploy Qwen3-TTS-Flash: You’ll want to host it on Hugging Face Inference API or Spaces. Make sure to get the API URL and your authentication token ready. 2. Create a Custom TTS Plugin: Extend the
tts.TTS
class in LiveKit to connect with the Hugging Face API. You’ll implement methods like
synthesize()
to send text input and receive audio output. 3. Ensure Audio Format Compatibility: LiveKit expects PCM audio at 24kHz. If the API returns a different format, you can convert it in real-time or request PCM output to keep everything smooth. 4. Register and Use the Plugin: Use your custom TTS instance in your agent pipeline. For example:
Copy code
class Qwen3TTSTTS(tts.TTS):
    def __init__(self, api_key, endpoint_url):
        super().__init__(capabilities=tts.TTSCapabilities(streaming=False), sample_rate=24000)
        self.api_key = api_key
        self.endpoint_url = endpoint_url

    def synthesize(self, text):
        # Implement API call to Hugging Face here
        pass

# Use in agent
async def entrypoint(job):
    tts_plugin = Qwen3TTSTTS(api_key="your_hf_token", endpoint_url="https://api-inference.huggingface.co/models/qwen/Qwen3-TTS-Flash")
    job.agent.output_audio.add_all([tts_plugin])
If you’d like, I’m here to walk you through deploying the model on Hugging Face or help with implementing the plugin. Just let me know how I can assist! Sources: Text-to-speech (TTS) models | LiveKit Docs | livekit-plugins/livekit-plugins-baseten/livekit/plugins/baseten/tts.py | common/arg.cpp