이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

음성 합성(TTS)

Feature Overview

In Cascade (three-stage) mode, Text-to-Speech (TTS) operates as the third stage in the conversation pipeline, providing the AI chatbot's voice. It receives streaming text responses from the LLM, synthesizes speech in real time, and pushes audio back to the TRTC room for playback—with support for interruption.
The TTS stage follows a Provider + Params integration model and supports the following options:
TRTC Native TTS (trtc, default): Fully integrated and ready to use, no third-party setup required. Recommended for most use cases.
Third-party TTS (minimax / azure): Suitable for scenarios that require specific voice timbres or vendor-specific audio quality.
Custom TTS (custom): Integrate your own TTS solution or private TTS deployments using the OpenAI TTS standard protocol.
Note:
In S2S (end-to-end) mode, audio is generated directly by the end-to-end model. The TTS stage is not used and TTSConfig does not need to be configured.

Configuration Structure

To configure TTS for an AI conversation task, include a TTSConfig object:
Field Name
Required
Type
Description
Provider
Yes
String
TTS provider identifier: trtc (default) / minimax / azure / custom.
Params
Yes
String
Provider-specific parameters, formatted as a JSON string.

TRTC Native TTS

Params Field Description (Provider = trtc)

Field Name
Type
Required
Description
Model
String
Yes
Voice model (only "flow_02_turbo" is supported).
VoiceId
String
Yes
Voice ID. Each language requires a specific voice ID. See VoiceId Voice Description for details.
Speed
Float
No
Speech rate. Default: 1.0.
Volume
Float
No
Volume, range 0.0–2.0. Default: 1.0.
Pitch
Float
No
Pitch (in semitones). Default: 0.0.

VoiceId Voice Description

Each supported language requires a corresponding Voice ID. Available voices:
Language
Male Voice
Female Voice
Chinese (zh)
v-male-s5NqE0rZ
v-female-R2s4N9qJ
English (en)
v-male-X6h4TvP9
v-female-P6q9LmR2
Japanese (ja)
v-male-J3n8DxK2
v-female-J3k7NxR2
Cantonese (yue)
v-male-D7p4XcL2
v-female-C5t1QxH9
Indonesian (id)
v-male-B5f2CnS3
v-female-W5n8HgB2
Thai (th)
v-male-B5f2CnS3
v-female-W5n8HgB2
Vietnamese (vi)
v-male-B5f2CnS3
v-female-W5n8HgB2
Malay (ms)
v-male-Q6p8ZxL3
v-female-C8k4NxL6
Note:
Indonesian (id), Thai (th), and Vietnamese (vi) share the same set of voices.

Configuration Example

"TTSConfig": {
"Provider": "trtc",
"Params": "{\"Model\":\"flow_02_turbo\",\"VoiceId\":\"v-female-R2s4N9qJ\",\"Speed\":1.0}"
}

Third-party TTS Integration

To use a third-party TTS provider, set Provider to minimax or azure and provide the vendor-specific parameters (authentication, model, voice, speech rate, etc.) in Params. Refer to the vendor's documentation for parameter details. For other TTS providers, contact sales.

Minimax Integration Example (Provider = minimax)

For full details, see Minimax Official Documentation.
Configuration Example:
"TTSConfig": {
"Provider": "minimax",
"Params": "{\"provider\":\"minimax\",\"api_key\":\"<your-api-key>\",\"model\":\"speech-2.6-hd\",\"url\":\"https://api.minimaxi.com/v1/t2a_v2\",\"voice_setting\":{\"voice_id\":\"male-qn-qingse\"}}"
}

Azure Integration Example (Provider = azure)

Params Field Description:
Field Name
Meaning
subscription_key
SecretKey.
url
API endpoint.
voice
Voice ID.
lang
Language.
rate
Speech rate.
volume
Volume.
pitch
Pitch.
style
Emotional style.
For more information, see Microsoft Official Documentation.
Configuration Example:
"TTSConfig": {
"Provider": "azure",
"Params": "{\"voice\":\"zh-CN-XiaoxiaoNeural\",\"subscription_key\":\"<your-subscription-key>\",\"url\":\"https://southeastasia.api.cognitive.microsoft.com\"}"
}

Custom TTS Integration (Provider = custom)

You can integrate your own TTS service, private deployment, or third-party solution as the speech synthesis module for AI conversations. The protocol is based on the OpenAI TTS standard, with extensions for real-time streaming (such as PCM streaming output and sample rate/channel controls).

Protocol Specification

Item
Requirement
Request Method
HTTP POST
Request Path
/v1/audio/speech (OpenAI TTS standard path)
Request Format
JSON Body
Authentication
Authorization: Bearer {api_key} (api_key is passed via Params)
Response Format
HTTP 200 + PCM audio binary stream (Chunked Transfer Encoding)
Audio Format
Signed 16-bit Little-Endian PCM

Params Field Description (Provider = custom)

Field Name
Type
Required
Description
url
String
Yes
TTS service HTTP endpoint.
api_key
String
No
Authentication key (used as Authorization: Bearer).
model
String
Yes
Model identifier (e.g., cosyvoice-v1).
voice
String
No
Voice ID.
speed
Float
No
Speech rate, range: 0.25–4.0. Default: 1.0.
sample_rate
Integer
No
Sample rate: 8000 / 16000 (default) / 24000 / 48000.
channel
Integer
No
Channel:
1 (default, mono);
2 (stereo).
custom_headers
Object
No
Custom request headers.
custom_fields
Object
No
Vendor extension parameters (black box passthrough).

Configuration Example

"TTSConfig": {
"Provider": "custom",
"Params": "{\"url\":\"https://your-tts-service/v1/audio/speech\",\"api_key\":\"<your-api-key>\",\"model\":\"cosyvoice-v1\",\"voice\":\"your-voice-id\",\"speed\":1.0,\"sample_rate\":16000,\"channel\":1}"
}

Integration Points

1. On the TRTC side, only the JSON validity of Params is checked; field semantics are not parsed. The custom TTS adapter in the AI backend handles field mapping.
2. We recommend implementing streaming output in your TTS service to minimize initial packet delay and ensure a smooth conversation experience.
3. Custom TTS services must return HTTP 200 with PCM binary stream (Chunked) as specified. Any non-200 response is treated as a synthesis failure.

Audio Push to Room

The backend pushes synthesized TTS audio into the TRTC room using a push bot, specified via AgentConfig.TTSPushRoomParams:
Field Name
Required
Type
Description
UserId
Yes
String
User ID for the push bot (length: 1–120). UserSig is auto-generated by backend.
"AgentConfig": {
"UserId": "ai-bot-001",
"TTSPushRoomParams": { "UserId": "tts-bot-001" }
}
Note:
The conversation bot (AgentConfig.UserId) and the push bot (TTSPushRoomParams.UserId) must use different User IDs. Clients can subscribe to the push bot’s audio stream to listen to AI responses.

Playback Content Control

In addition to LLM response text, the following content is also synthesized and played by TTS:
Content
Configuration Location
Description
Welcome Message
DialogConfig.WelcomeMessage
Automatically played when the host enters the room.
Silence Follow-up
DialogConfig.SilenceFollowUpText
Bot proactively prompts after a silence timeout.
LLM Failure Fallback
LLMConfig.FailureMessage
Played if the LLM invocation fails to avoid conversation interruption.
Bracket Content Filtering
AgentConfig.FilterBracketsContent
Filters action/emotion markers (e.g., (smile), [happy]) so TTS doesn't read them aloud. See LLM Configuration > Output Control for details.

Notes

1. TTS configuration does not support hot updates: Once a task is created, TTSConfig cannot be modified. To change the voice or provider, end the current task and create a new one.
2. Only required in Cascade mode: In S2S mode, audio is generated directly by the end-to-end model; TTSConfig is not needed.
3. Voice and language must match: VoiceId must correspond to the conversation language. Mismatched language and voice may result in synthesis failures or unnatural pronunciation.
4. Interruption support: If an interruption command (automatic/manual/keyword-based) is received during TTS playback, playback stops immediately and the queue is cleared. See Client Interruption Command for details.