curl --request POST \
--url https://api.puretalk.ai/api/v1/tts \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"voice_id": "5bc2961c-fb9b-4a3d-a257-e0c5f2f95332",
"text": "Hey there! Welcome to Los Angeles",
"output_format": "raw",
"encoding": "pcm_f32le",
"sample_rate": 16000,
"language": "en",
"voice_speed": 0,
"voice_emotion": []
}
'import requests
url = "https://api.puretalk.ai/api/v1/tts"
payload = {
"voice_id": "5bc2961c-fb9b-4a3d-a257-e0c5f2f95332",
"text": "Hey there! Welcome to Los Angeles",
"output_format": "raw",
"encoding": "pcm_f32le",
"sample_rate": 16000,
"language": "en",
"voice_speed": 0,
"voice_emotion": []
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
voice_id: '5bc2961c-fb9b-4a3d-a257-e0c5f2f95332',
text: 'Hey there! Welcome to Los Angeles',
output_format: 'raw',
encoding: 'pcm_f32le',
sample_rate: 16000,
language: 'en',
voice_speed: 0,
voice_emotion: []
})
};
fetch('https://api.puretalk.ai/api/v1/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.puretalk.ai/api/v1/tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'voice_id' => '5bc2961c-fb9b-4a3d-a257-e0c5f2f95332',
'text' => 'Hey there! Welcome to Los Angeles',
'output_format' => 'raw',
'encoding' => 'pcm_f32le',
'sample_rate' => 16000,
'language' => 'en',
'voice_speed' => 0,
'voice_emotion' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.puretalk.ai/api/v1/tts"
payload := strings.NewReader("{\n \"voice_id\": \"5bc2961c-fb9b-4a3d-a257-e0c5f2f95332\",\n \"text\": \"Hey there! Welcome to Los Angeles\",\n \"output_format\": \"raw\",\n \"encoding\": \"pcm_f32le\",\n \"sample_rate\": 16000,\n \"language\": \"en\",\n \"voice_speed\": 0,\n \"voice_emotion\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.puretalk.ai/api/v1/tts")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"voice_id\": \"5bc2961c-fb9b-4a3d-a257-e0c5f2f95332\",\n \"text\": \"Hey there! Welcome to Los Angeles\",\n \"output_format\": \"raw\",\n \"encoding\": \"pcm_f32le\",\n \"sample_rate\": 16000,\n \"language\": \"en\",\n \"voice_speed\": 0,\n \"voice_emotion\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.puretalk.ai/api/v1/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voice_id\": \"5bc2961c-fb9b-4a3d-a257-e0c5f2f95332\",\n \"text\": \"Hey there! Welcome to Los Angeles\",\n \"output_format\": \"raw\",\n \"encoding\": \"pcm_f32le\",\n \"sample_rate\": 16000,\n \"language\": \"en\",\n \"voice_speed\": 0,\n \"voice_emotion\": []\n}"
response = http.request(request)
puts response.read_body"<string>"{
"err": true,
"msg": "<string>"
}Text to Speech
Converts text to speech using specified voice and parameters
curl --request POST \
--url https://api.puretalk.ai/api/v1/tts \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"voice_id": "5bc2961c-fb9b-4a3d-a257-e0c5f2f95332",
"text": "Hey there! Welcome to Los Angeles",
"output_format": "raw",
"encoding": "pcm_f32le",
"sample_rate": 16000,
"language": "en",
"voice_speed": 0,
"voice_emotion": []
}
'import requests
url = "https://api.puretalk.ai/api/v1/tts"
payload = {
"voice_id": "5bc2961c-fb9b-4a3d-a257-e0c5f2f95332",
"text": "Hey there! Welcome to Los Angeles",
"output_format": "raw",
"encoding": "pcm_f32le",
"sample_rate": 16000,
"language": "en",
"voice_speed": 0,
"voice_emotion": []
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
voice_id: '5bc2961c-fb9b-4a3d-a257-e0c5f2f95332',
text: 'Hey there! Welcome to Los Angeles',
output_format: 'raw',
encoding: 'pcm_f32le',
sample_rate: 16000,
language: 'en',
voice_speed: 0,
voice_emotion: []
})
};
fetch('https://api.puretalk.ai/api/v1/tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.puretalk.ai/api/v1/tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'voice_id' => '5bc2961c-fb9b-4a3d-a257-e0c5f2f95332',
'text' => 'Hey there! Welcome to Los Angeles',
'output_format' => 'raw',
'encoding' => 'pcm_f32le',
'sample_rate' => 16000,
'language' => 'en',
'voice_speed' => 0,
'voice_emotion' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.puretalk.ai/api/v1/tts"
payload := strings.NewReader("{\n \"voice_id\": \"5bc2961c-fb9b-4a3d-a257-e0c5f2f95332\",\n \"text\": \"Hey there! Welcome to Los Angeles\",\n \"output_format\": \"raw\",\n \"encoding\": \"pcm_f32le\",\n \"sample_rate\": 16000,\n \"language\": \"en\",\n \"voice_speed\": 0,\n \"voice_emotion\": []\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.puretalk.ai/api/v1/tts")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"voice_id\": \"5bc2961c-fb9b-4a3d-a257-e0c5f2f95332\",\n \"text\": \"Hey there! Welcome to Los Angeles\",\n \"output_format\": \"raw\",\n \"encoding\": \"pcm_f32le\",\n \"sample_rate\": 16000,\n \"language\": \"en\",\n \"voice_speed\": 0,\n \"voice_emotion\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.puretalk.ai/api/v1/tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"voice_id\": \"5bc2961c-fb9b-4a3d-a257-e0c5f2f95332\",\n \"text\": \"Hey there! Welcome to Los Angeles\",\n \"output_format\": \"raw\",\n \"encoding\": \"pcm_f32le\",\n \"sample_rate\": 16000,\n \"language\": \"en\",\n \"voice_speed\": 0,\n \"voice_emotion\": []\n}"
response = http.request(request)
puts response.read_body"<string>"{
"err": true,
"msg": "<string>"
}Authorizations
Authorization header containing API key. You can find your API key in the dashboard under 'API Keys'.
Body
The voice ID to use for text-to-speech conversion. See the available voices documentation 👉 GET /voices/get-voices
"5bc2961c-fb9b-4a3d-a257-e0c5f2f95332"
The text to convert to speech
"Hey there! Welcome to Los Angeles"
raw, wav, mp3 pcm_f32le, pcm_s16le, mulaw, alaw, mp3 The sample rate of the audio file in Hertz (Hz). This determines the number of samples of audio carried per second. The minimum value is 8000 Hz, which is typically used for telephony. The default value is 16000 Hz, which provides a good balance between quality and file size. The maximum value is 48000 Hz, which is used for high-quality audio recordings.
8000 <= x <= 48000en, fr, de, es, pt, zh, ja, hi, it, ko, nl, pl, ru, sv, tr Adjusts the speed of the voice. Acceptable values range from -1 (slowest) to 1 (fastest), with 0 being the default normal speed.
-1 <= x <= 1Array of voice emotions to apply. Acceptable values include various levels of anger, positivity, surprise, sadness, and curiosity.
anger:lowest, anger:low, anger, anger:high, anger:highest, positivity:lowest, positivity:low, positivity, positivity:high, positivity:highest, surprise:lowest, surprise:low, surprise, surprise:high, surprise:highest, sadness:lowest, sadness:low, sadness, sadness:high, sadness:highest, curiosity:lowest, curiosity:low, curiosity, curiosity:high, curiosity:highest Response
Audio file generated successfully
The response is of type file.
Was this page helpful?