Skip to content

FunAudioLLM-CosyVoice-300M

Brief: Convert text to speech using the FunAudioLLM-CosyVoice-300M model.


Overview

  • Method: POST
  • Path: /v1/audio/speech
  • Content-Type: application/json

Authentication

  • Header: Authorization: Bearer <token>
  • Optional Header: Accept: */*

Request Body Parameters

ParameterTypeRequiredDescription
modelstringYesModel name, set to FunAudioLLM-CosyVoice-300M
inputstringYesText to convert into speech
voicestringYesVoice style, such as alloy, echo, fable, onyx, nova, shimmer
extra_bodyobjectNoAdditional settings object for custom voice parameters
extra_body.voice_urlstringNoCustom voice file URL, for example https://example.com/path/to/voice.pt

curl Example

bash
curl -X POST "https://api.gpt.ge/v1/audio/speech" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxx" \
  -H "Accept: */*" \
  -d '{
    "model": "FunAudioLLM-CosyVoice-300M",
    "input": "Hello, I am the v3 TTS assistant. Thank you for using our API service!",
    "voice": "alloy",
    "extra_body": {
      "voice_url": "https://example.com/path/to/voice.pt"
    }
  }'

JavaScript (fetch) Example

javascript
fetch('https://api.gpt.ge/v1/audio/speech', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer sk-xxxx',
    'Accept': '*/*'
  },
  body: JSON.stringify({
    model: 'FunAudioLLM-CosyVoice-300M',
    input: 'Hello, I am the v3 TTS assistant. Thank you for using our API service!',
    voice: 'alloy',
    extra_body: {
      voice_url: 'https://example.com/path/to/voice.pt'
    }
  })
}).then(r => r.blob()).then(console.log);

Python (requests) Example

python
import requests

response = requests.post(
    'https://api.gpt.ge/v1/audio/speech',
    headers={
        'Content-Type': 'application/json',
        'Authorization': 'Bearer sk-xxxx',
        'Accept': '*/*'
    },
    json={
        'model': 'FunAudioLLM-CosyVoice-300M',
        'input': 'Hello, I am the v3 TTS assistant. Thank you for using our API service!',
        'voice': 'alloy',
        'extra_body': {
            'voice_url': 'https://example.com/path/to/voice.pt'
        }
    }
)
print(response.status_code)
print(response.content[:20])

Response Example (200)

text
<binary audio data returned directly, such as MP3 or WAV file content>

Note: The response usually returns the audio file content directly in the selected audio format.