Unode
User GuideAPI ReferenceHelp & SupportBusiness Cooperation

OpenAI Audio

Official Documentation

Introduction

OpenAI Audio API provides three main functions:

  1. Text-to-Speech (TTS) - Convert text to natural speech
  2. Speech-to-Text (STT) - Transcribe audio to text
  3. Audio Translation - Translate non-English audio to English text

Request Examples

curl https://www.unodetech.xyz/v1/audio/speech \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Hello, world!",
    "voice": "alloy"
  }' \
  --output speech.mp3

Supported Models

  • tts-1: Standard model with fast response time
  • tts-1-hd: High-quality model with better audio quality

Supported Voices

The voice parameter accepts different voice options:

  • alloy: Balanced and natural voice
  • coral: Warm and soft, feminine, suitable for lifestyle and customer service
  • echo: Deep and stable, masculine, suitable for system prompts or explanatory text
  • fable: Light and story-like, suitable for audiobooks or storytelling
  • onyx: Deep and heavy, masculine, suitable for formal or professional scenarios
  • nova: Bright and young, feminine, suitable for lively content or creative scenarios
  • shimmer: Clear and light, feminine, suitable for short prompts or educational content
  • sage: Calm and natural, neutral, suitable for explanations or neutral narration
curl https://www.unodetech.xyz/v1/audio/transcriptions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@/path/to/file/audio.mp3" \
  -F model="whisper-1"

Response Example:

{
  "text": "Hello, world!"
}
curl https://www.unodetech.xyz/v1/audio/translations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@/path/to/file/chinese.mp3" \
  -F model="whisper-1"

Response Example:

{
  "text": "Hello, world!"
}

Request

Endpoints

Text-to-Speech

POST /v1/audio/speech

Convert text to speech.

Speech-to-Text

POST /v1/audio/transcriptions

Transcribe audio to text in the input language.

Audio Translation

POST /v1/audio/translations

Translate audio to English text.

Authentication Method

Include the following in the request header for API key authentication:

Authorization: Bearer $API_KEY

Where $API_KEY is your API key.

Request Body Parameters

Text-to-Speech

Speech-to-Text

Audio Translation

Response

Successful Response

Returns binary audio file content.

Basic JSON Format
{
  "text": "Transcribed text content"
}
Detailed JSON Format
{
  "task": "transcribe",
  "language": "english",
  "duration": 8.47,
  "text": "Complete transcribed text",
  "segments": [
    {
      "id": 0,
      "seek": 0,
      "start": 0.0,
      "end": 3.32,
      "text": "Segmented transcribed text",
      "tokens": [50364, 440, 7534],
      "temperature": 0.0,
      "avg_logprob": -0.286,
      "compression_ratio": 1.236,
      "no_speech_prob": 0.009
    }
  ]
}
{
  "text": "Translated English text"
}

Error Response

When a request encounters an issue, the API will return an error response object, with HTTP status codes in the 4XX-5XX range.

Common Error Status Codes

  • 400 Bad Request: Invalid request parameters
  • 401 Unauthorized: Invalid API key or not provided
  • 429 Too Many Requests: Exceeded API call limit
  • 500 Internal Server Error: Server internal error

Error response example:

{
  "error": {
    "message": "Unsupported file format",
    "type": "invalid_request_error",
    "param": "file",
    "code": "invalid_file_format"
  }
}

Last updated on