跳转到主要内容
Send a POST request to https://api.qhaigc.net/v1/voice/model to create a custom voice character from your own audio samples. Once the model is created, its name appears in GET /v1/audio/voices and can be passed as the voice parameter in POST /v1/audio/speech.
For best results, use 2–3 .wav files recorded at 16 kHz or 24 kHz in mono. Each clip should feature clear speech with minimal background noise and last at least 10 seconds.

Request

POST https://api.qhaigc.net/v1/voice/model
The request body must use multipart/form-data encoding.

Parameters

name
string
必填
A unique name for your voice character (for example, "私人助手"). This is the value you pass as voice in subsequent TTS requests.
audio_files
file[]
必填
Two or three .wav audio files used to train the voice model. Recommended sample rate: 16 kHz or 24 kHz, mono channel.
reference_texts
string[]
必填
An array of text strings that correspond one-to-one with each audio file in audio_files. These transcripts help the model learn the voice accurately.
public
string
Set to "true" to make the voice publicly available to all Qhaigc users, or "false" to keep it private (only your account can use it). Defaults to "false".
description
string
A short description of the voice character’s style or intended use.
contact_email
string
Required when public is "false". Provide an email address so that Qhaigc can contact you about your voice model if needed.

Response

model_name
string
The name of the newly created voice character, matching the name you submitted.
public
boolean
Whether the voice is publicly accessible.
description
string
The description you provided for the voice model.

Example response

{
  "model_name": "私人助手",
  "public": false,
  "description": "仅限本人使用的语音模型"
}

Code examples

import requests

url = "https://api.qhaigc.net/v1/voice/model"
headers = {"Authorization": "Bearer sk-your-api-key-here"}

files = [
    ("audio_files", ("sample1.wav", open("sample1.wav", "rb"), "audio/wav")),
    ("audio_files", ("sample2.wav", open("sample2.wav", "rb"), "audio/wav")),
]

data = {
    "name": "私人助手",
    "description": "My personal assistant voice",
    "reference_texts": [
        "你好,我是你的语音助手",
        "有什么可以帮你的",
    ],
    "public": "false",
    "contact_email": "user@example.com",
}

response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
Do not use audio samples that include copyrighted music, background noise, or multiple speakers. Poor-quality samples produce a lower-fidelity cloned voice.