Skip to main content
This experiment demonstrates how to deploy and use a text-to-audio model (Qwen3-TTS) using Flexai’s inference serving capabilities.

Setup

The demo code for this experiment is located at code/qwen3-tts but it is advisable to follow the steps below before jumping to the full demo.

Prerequisites

Before starting, make sure you have:
  • A Flexai account with access to the platform
  • The flexai CLI installed and configured

Start the FlexAI Inference Endpoint for voice cloning

Base model capable of 3-second rapid voice clone from user audio input; can be used for fine-tuning (FT) other models. Start the FlexAI endpoint for the Qwen3-TTS-12Hz-1.7B-Base model:
This command will:
  • Create an inference endpoint named Qwen3-base
  • Use the vllm-omni runtime
  • Load the Qwen3-TTS-12Hz-1.7B-Base model from Hugging Face

Get Endpoint Information

Once the endpoint is deployed, you’ll see the API key displayed in the output. Store it in an environment variable:
Then retrieve the endpoint URL:
You’ll notice these export lines use the jq tool to extract values from the JSON output of the inspect command.If you don’t have it already, you can get jq from its official website: https://jqlang.org/

Generate Audio

Now you can clone a voice by making HTTP POST requests to your endpoint. Here is an example:

Parameters Explanation

The API accepts the following parameters:
  • inputs: The text prompt describing the text you want to generate
  • ref_text: The transcription of the reference audio file (the voice you want to clone)
  • ref_audio: A URL pointing to the reference audio file (must be in WAV format and less than 10 seconds long)
  • language: Language of the input text (set to “Auto” for automatic detection)
  • task_type: Set to “Base” for voice cloning

Start the FlexAI Inference Endpoint for using custom voice

Provides style control over target timbres via user instructions; supports 9 premium timbres covering various combinations of gender, age, language, and dialect. Start the FlexAI endpoint for the Qwen3-TTS-12Hz-1.7B-CustomVoice model:
This command will:
  • Create an inference endpoint named Qwen3-custom-voice
  • Use the vllm-omni runtime
  • Load the Qwen3-TTS-12Hz-1.7B-CustomVoice model from Hugging Face

Get Endpoint Information

Once the endpoint is deployed, you’ll see the API key displayed in the output. Store it in an environment variable:
Then retrieve the endpoint URL:

Generate Audio

Now you can create audio with the provided custom voice by making HTTP POST requests to your endpoint. Here is an example:

Parameters Explanation

The API accepts the following parameters:
  • inputs: The text prompt describing the text you want to generate
  • voice: The voice you want to use (you can list the available voices by making a GET request to the endpoint’s /v1/audio/voices path)
  • instructions: How the model should speak the text (e.g., “Speak with great enthusiasm”, “Speak like a news anchor”, etc.)
  • language: Language of the input text (set to “Auto” for automatic detection)

Demo App

The demo app allows you to easily test the endpoints you just created. You can find it in the code/qwen3-tts directory. In the same directory you will find scripts to start the inference endpoints for both the base and custom voice models. Make sure to start both endpoints before running the demo app:

Start Qwen3-TTS-12Hz-1.7B-Base model

Start Qwen3-TTS-12Hz-1.7B-CustomVoice

Start the demo app

Using pip

then you can start the demo with:

Code

app.py

requirements.txt

START/run-qwen3-tts-cloneVoice.sh

START/run-qwen3-tts-customVoice.sh

⚡ Deploy this on FlexAI

Any model, NVIDIA or AMD, live in under 60 seconds. No code changes, no infra management, hardware-agnostic.

Get started →Talk to us