Skip to content

TTS

The TTS endpoints allow interaction with the available speech synthesis models on the SipPulse AI platform. You can get a list of all available models, generate audio from text, and download or stream the generated audio.

Endpoints

GET /tts/models

This endpoint returns a list of all available TTS models.

Query Parameters

  • status (optional): The status of the models. It can be active or inactive. The default is active.

Example Request

bash
curl -X 'GET' \
  'https://api.sippulse.ai/v1/tts/models' \
  -H 'Content-Type: application/json' \
  -H 'api-key: $SIPPULSE_API_KEY'
python
import requests

url = "https://api.sippulse.ai/v1/tts/models"
headers = {
    "Content-Type": "application/json",
    "api-key": "SIPPULSE_API_KEY"
}

response = requests.get(url, headers=headers)
print(response.json())
javascript
const url = "https://api.sippulse.ai/v1/tts/models";
const headers = {
  "Content-Type": "application/json",
  "api-key": "SIPPULSE_API_KEY",
};

fetch(url, {
  method: "GET",
  headers: headers,
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));

Example Response

json
[
  {
    "name": "azure-tts",
    "status": "active"
  }
  // ...
]

GET /tts/azure/voices

This endpoint returns a list of all available voices for the azure-tts model.

Example Request

bash
curl -X 'GET' \
  'https://api.sippulse.ai/v1/tts/azure/voices' \
  -H 'Content-Type: application/json
  -H 'api-key: $SIPPULSE_API_KEY'
python
import requests

url = "https://api.sippulse.ai/v1/tts/azure/voices"
headers = {
    "Content-Type": "application
    "api-key": "SIPPULSE_API_KEY"
}

response = requests.get(url, headers=headers)
print(response.json())
javascript
const url = "https://api.sippulse.ai/v1/tts/azure/voices";

const headers = {
  "Content-Type": "application/json",
  "api-key": "SIPPULSE_API_KEY",
};

fetch(url, {
  method: "GET",
  headers: headers,
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));

Example Response

json
[
  "af-ZA-AdriNeural",
  "af-ZA-WillemNeural",
  "am-ET-MekdesNeural",
  "am-ET-AmehaNeural",
  "ar-AE-FatimaNeural",
  "ar-AE-HamdanNeural",
  "ar-BH-LailaNeural",
  "ar-BH-AliNeural"
  //...
]

POST /tts/generate

This endpoint generates an audio file from a text using the specified model.

Request Body

json
{
  "model": "string", // Name of the model to be used
  "text": "string", // Text to be converted to speech
  "voice": "string", // Voice to be used for conversion
  "output_format": 5 // (optional) Audio output format
}

Available Voices

If the model is azure-tts, the voice field must be one of the available voices for the model. To get the list of available voices, refer to the GET /tts/azure/voices endpoint.

Output Formats

The output_format field is optional and only required if the model is azure-tts. For more information on the available output formats, refer to the Microsoft documentation.

Example Request

bash
curl -X 'POST' \
  'https://api.sippulse.ai/v1/tts/generate' \
  -H 'Content-Type: application/json' \
  -H 'api-key: $SIPPULSE_API_KEY' \
  -d '{
  "model": "azure-tts",
  "text": "Hello, welcome to SIPPulse AI",
  "voice": "en-US-AvaNeural",
  "output_format": 5
}'
python
import requests
import json

url = "https://api.sippulse.ai/v1/tts/generate"
headers = {
    "Content-Type": "application/json",
    "api-key": "SIPPULSE_API_KEY"
}
data = {
    "model": "azure-tts",
    "text": "Hello, welcome to SIPPulse AI",
    "voice": "en-US-AvaNeural",",
    "output_format": 5
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
javascript
const url = "https://api.sippulse.ai/v1/tts/generate";
const headers = {
  "Content-Type": "application/json",
  "api-key": "SIPPULSE_API_KEY",
};
const data = {
  model: "azure-tts",
  text: "Hello, welcome to SIPPulse AI",
  voice: "en-US-AvaNeural",
  output_format: 5,
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(data),
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));

Example Response

json
{
  "filename": "tts_output.mp3",
  "cache": false,
  "usage": 10,
  "unit": "characters",
  "stream": "https://api.sippulse.ai/v1/tts/stream/tts_output.mp3",
  "download": "https://api.sippulse.ai/v1/tts/download/tts_output.mp3"
}

GET /tts/download/

This endpoint allows you to download a generated audio file.

Path Parameters

  • filename (required): The name of the audio file to be downloaded.

Example Request

bash
curl -X 'GET' \
  'https://api.sippulse.ai/v1/tts/download/tts_output.mp3' \
  -H 'api-key: $SIPPULSE_API_KEY'
python
import requests

url = "https://api.sippulse.ai/v1/tts/download/tts_output.mp3"
headers = {
    "api-key": "SIPPULSE_API_KEY"
}

response = requests.get(url, headers=headers)
with open("tts_output.mp3", "wb") as f:
    f.write(response.content)
javascript
const fs = require("fs");

const url = "https://api.sippulse.ai/v1/tts/download/tts_output.mp3";
const headers = {
  "api-key": "SIPPULSE_API_KEY",
};

fetch(url, {
  method: "GET",
  headers: headers,
})
  .then((response) => response.buffer())
  .then((data) => fs.writeFileSync("tts_output.mp3", data))
  .catch((error) => console.error("Error:", error));

GET /tts/stream/

This endpoint allows you to stream a generated audio file.

Path Parameters

  • filename (required): The name of the audio file to be streamed.

Example Request

bash
curl -X 'GET' \
  'https://api.sippulse.ai/v1/tts/stream/tts_output.mp3' \
  -H 'api-key: $SIPPULSE_API_KEY'
python
import requests

url = "https://api.sippulse.ai/v1/tts/stream/tts_output.mp3"
headers = {
    "api-key": "SIPPULSE_API_KEY"
}

response = requests.get(url, headers=headers, stream=True)
with open("tts_output.mp3", "wb") as f:
    for chunk in response.iter_content(chunk_size=8192):
        f.write(chunk)
javascript
const fs = require("fs");

const url = "https://api.sippulse.ai/v1/tts/stream/tts_output.mp3";
const headers = {
  "api-key": "SIPPULSE_API_KEY",
};

fetch(url, {
  method: "GET",
  headers: headers,
})
  .then((response) =>
    response.body.pipe(fs.createWriteStream("tts_output.mp3"))
  )
  .catch((error) => console.error("Error:", error));

Conclusion

The TTS endpoints of SipPulse AI offer a powerful way to convert text into audio and integrate these functionalities into your applications. Use the provided information and examples to start exploring and implementing these features in your projects.