General instructions for voice interface
ShangHai Do provides a unified speech generation interface. There are four speech generation models available: MiniMax dubbing models minimax-speech-2.8-turbo and minimax-speech-2.8-hd, and Qwen’s qwen-audio-3.1-tts-flash and qwen-audio-3.1-tts-next. The following model is called using the site address and site token:
POST /v1/audio/speech
The request needs to use the token you created at ShangHai Do and carry the Bearer token in the Authorization request header. After success, the audio binary file will be returned directly, not JSON; when calling using the command line, please use -o to save the file.
Preparation before calling
The following example uses two environment variables: SHANHAI_BASE_URL is the root address of this site, do not add /v1; SHANHAI_API_KEY is the token you created on ShangHai Do.
In macOS, Linux, or a Bash-enabled terminal:
export SHANHAI_BASE_URL="https://shanghaido.com"
export SHANHAI_API_KEY="替换为你的ShangHai Do令牌"
In Windows PowerShell:
$env:SHANHAI_BASE_URL = "https://shanghaido.com"
$env:SHANHAI_API_KEY = "替换为你的ShangHai Do令牌"
The multi-line curl example in this article is written in Bash; Windows users can use the Python example on the model details page, or run it in a terminal that supports Bash.
model how to choose
| What needs to be generated | Model name | How to specify the character’s voice |
|---|---|---|
| Quickly generate text dubbing, adjust emotions and pronunciation | minimax-speech-2.8-turbo |
Use voice timbre number; you can also clone your own voice on the voice page. |
| Text dubbing that pays more attention to sound details | minimax-speech-2.8-hd |
Use voice tone number; you can also clone your own voice on the voice page. |
| Read text, control timbre, tone, speaking speed and pronunciation | qwen-audio-3.1-tts-flash |
Use the voice timbre number available on this site. |
| Character talking, multi-person dialogue, sound effects or environmental sounds | qwen-audio-3.1-tts-next |
Submit reference audio and use @voice1 and other references in the text description. |
Sound design model minimax-voice-design is currently unavailable and cannot be called on this site; please do not confuse it with the above two MiniMax dubbing models that can clone sounds.
General parameters
true in the parameter table means on, false means off; integers cannot contain decimals, and numbers can contain decimals.
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
Text | Yes | Fill in the exact model name in the table above. |
input |
text or object | is | MiniMax dubbing must fill in text; two Qwen models support text or object. See the corresponding model page for detailed format. |
voice |
Text | No | MiniMax dubbing uses tone number, the page default is male-qn-qingse; Qwen Flash default longanhuan_v3.1. |
response_format |
Text | No | MiniMax Optional mp3, wav, flac, pcm, opus, pcmu_raw, pcmu_wav, the default is mp3. See each model page for Qwen format. |
speed |
Number | No | Speech speed, 0.5 ~ 2, default 1; The bigger, the faster. |
instructions |
Text | No | Reading style prompt for Qwen Flash only. MiniMax's mood and other settings are passed in through metadata. |
metadata |
Object | No | Advanced voice settings for MiniMax dubbing, see the fields and usage on the two MiniMax model pages. |
stream_format |
Text | No | Qwen can be omitted or filled in audio, and the complete file will still be returned; MiniMax must omit this parameter. |
Qwen How to write input when more parameters are needed
The text writing method is suitable for quick calls; the object writing method allows you to set the sampling rate, volume, random seed, and more functions supported by each model.
| Purpose | Fields in simple writing | Fields in object writing |
|---|---|---|
| Flash text to be read | input: "你好" |
input.text: "你好" |
| Next Voice description and lines | input: "一位女性说:你好" |
input.text_prompt: "一位女性说:你好" |
| Output format | Outermost layer response_format |
input.format |
| Speaking speed | Outermost layer speed |
input.rate |
| Flash tone | Outermost layer voice |
input.voice |
| Flash reading style | Outermost layer instructions |
input.instruction, pay attention to the odd number |
Qwen When using the object writing method, it is recommended to put the generated parameters in input and keep model in the outermost layer. If parameters for the same purpose are filled in both inside and outside, the values must be the same. Additional fields such as sample_rate, volume, seed, references must be placed within input, and will not take effect if placed in the outermost layer. The fields supported by the two models are different, and misspelled or unsupported object fields will return parameter errors. MiniMax dubbing requires input to be text, and additional settings are placed in the top-level metadata object. Qwen's object input format cannot be applied.
MiniMax Dubbing: Minimum Request
MiniMax dubbed input must be a string; do not pass in the input object used by Qwen. stream_format must be omitted when calling.
curl --fail-with-body "$SHANHAI_BASE_URL/v1/audio/speech" \
-H "Authorization: Bearer $SHANHAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "minimax-speech-2.8-turbo",
"input": "你好,欢迎使用ShangHai Do语音服务。",
"voice": "male-qn-qingse",
"response_format": "wav",
"speed": 1
}' \
-o minimax-speech.wav
Change the model name to minimax-speech-2.8-hd to use the HD model. Sound cloning requires logging into the voice generation page; for specific recording requirements, authorization, fees and validity period, see Turbo Model Description.
Qwen text-to-speech: minimum request
curl --fail-with-body "$SHANHAI_BASE_URL/v1/audio/speech" \
-H "Authorization: Bearer $SHANHAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-audio-3.1-tts-flash",
"input": "你好,欢迎使用ShangHai Do语音服务。",
"voice": "longanhuan_v3.1",
"response_format": "wav",
"speed": 1
}' \
-o speech.wav
Generate sound effects based on sound description
qwen-audio-3.1-tts-next can generate not only character speech, but also sound effects and environmental sounds. A string input describes the sound to be heard, for example:
curl --fail-with-body "$SHANHAI_BASE_URL/v1/audio/speech" \
-H "Authorization: Bearer $SHANHAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-audio-3.1-tts-next",
"input": "雨后森林中,几只小鸟清脆地鸣叫,伴随轻柔的风吹树叶声。",
"response_format": "wav"
}' \
-o sound.wav
When the same character speaks different lines, Next should use object input, submit the same reference audio in references, and reference it as @voice1 in text_prompt. Flash uses the same voice tone number. See the details page of each model for complete examples.
Next does not accept voice or top-level instructions; tone and lines are written into text_prompt. Flash's text and Next's text_prompt are different fields and cannot be mixed. The Qwen input rules above do not apply to MiniMax dubbing.
Return results
When successful, the response body is the audio file, and the response header will indicate the corresponding audio type. Client programs should save the response body directly and not parse it as JSON containing the audio address. The file extension needs to correspond to the requested format; pcm is the original audio data, and additional information such as the sampling rate needs to be specified during playback.
An error message will be returned when the request fails. The program should check the response status before saving the audio; --fail-with-body in the command line example will cause the failed request to exit with a non-zero status, and do not play the output file as audio on failure.
Precautions
- Flash tone number is case-sensitive, the default is
longanhuan_v3.1. If you need other or exclusive timbres, please contact the site’s customer service to confirm the available numbers; this site does not yet provide an interface for creating timbres. - MiniMax Two dubbing models can clone voices on the voice page after logging in. Cloning recordings, timbre numbers and corresponding usage rights are related to account creation; the page cloning process cannot be used as a public token interface.
- Next There are up to 3 reference audios, each up to 30 seconds and no more than 10 MB. Supports WAV, MP3, OGG Opus; submit with public network address or Base64 content with format prefix. For specific examples, see model details.
- Flash’s
bit_rateis only for Opus; Next’sbit_rateis only for MP3 fixed bit rate. The encoding parameters of the two are not interchangeable. - The advanced parameters of MiniMax are passed in through
metadata; do not repeatedly set the same parameter in the top layer andmetadataat the same time. This interface returns audio files; the subtitles saved on the MiniMax page do not belong to the JSON return content of the public token interface. - currently returns complete audio files, and does not provide return while generating. Qwen's
stream_format: "audio"does not change this; MiniMax must omitstream_format.
model details
minimax-speech-2.8-turbo、minimax-speech-2.8-hd、minimax-voice-design、qwen-audio-3.1-tts-flash、qwen-audio-3.1-tts-next
sound design name
minimax-speech is for voice design and requires confirmation of service availability and account permissions before integration. It is not an abbreviation for a regular text-to-speech model. For regular narration, use minimax-speech-2.8-hd or minimax-speech-2.8-turbo. Voice design and cloning a voice from an uploaded recording are separate operations.
encountered a problem
If you encounter problems with calling or configuration, please contact the site customer service and provide the model name, error time and error information to facilitate troubleshooting.