Inference APIs

Voices and samples

Every sample is this sentence, generated through the API with default settings: “今天天气很好,下午我打算和朋友一起去公园散步。”

ListenVoice idVoiceRound-trip check
FemaleAll 21 characters understood
Female2 of 21 characters misheard
FemaleAll 21 characters understood
FemaleAll 21 characters understood
MaleAll 21 characters understood
MaleAll 21 characters understood
MaleAll 21 characters understood
MaleAll 21 characters understood

Round-trip check: we transcribed each sample with Whisper Large v3 and compared it with the text we sent. It tests whether the speech is intelligible to a machine, not whether it sounds natural to you; for that, listen. Traditional and Simplified forms of the same character were counted as the same.

Quickstart

cURL
curl https://api.inferenceapis.com/v1/audio/speech \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "hexgrad/Kokoro-82M", "voice": "zf_xiaobei", "input": "今天天气很好,下午我打算和朋友一起去公园散步。", "response_format": "mp3"}' \
  --output chinese.mp3
Python · openai SDK
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.inferenceapis.com/v1", api_key=os.environ["INFERENCE_API_KEY"])
audio = client.audio.speech.create(model="hexgrad/Kokoro-82M", voice="zf_xiaobei", input="今天天气很好,下午我打算和朋友一起去公园散步。")
audio.write_to_file("chinese.mp3")

Notes for Chinese

  • The voices are Mandarin. There is no Cantonese voice.
  • Numbers, dates and abbreviations are read as written. Spell out anything that must be pronounced a specific way.
  • Pacing follows punctuation; there is no SSML. speed changes the overall rate.

Cost and limits

Kokoro is billed at $5.20 per million Unicode characters of input. The 23-character sample above is 5.4 seconds of audio and costs $0.00012; at that rate an hour of Chinese speech is about 15,000 characters, or roughly $0.08. Each character counts once, however many bytes it takes to encode. A request accepts up to 20,000 characters; for longer text, split on sentence boundaries and join the audio. A paragraph returns in under a second in our measurement. Orpheus is English-only, so Chinese always uses Kokoro.

Other languages: English · Japanese · Spanish · French · Hindi · Italian · Portuguese

Speech-to-text in Chinese

The reverse direction: Whisper Large v3 transcribed our Chinese test clips with 9.5% character error. See Chinese speech-to-text.