curl --request POST \
--url https://api.studio.us.phrase.com/v1/tts/speech \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"text": "Phrase is hosted with SQL.",
"voiceId": "49b2c280-1604-4fa9-8f79-30c08f87edd5",
"engine": "eleven_v3",
"pronunciations": [
{
"source": "Phrase",
"target": "freɪz",
"notation": "ipa"
}
]
}
'import requests
url = "https://api.studio.us.phrase.com/v1/tts/speech"
payload = {
"text": "Phrase is hosted with SQL.",
"voiceId": "49b2c280-1604-4fa9-8f79-30c08f87edd5",
"engine": "eleven_v3",
"pronunciations": [
{
"source": "Phrase",
"target": "freɪz",
"notation": "ipa"
}
]
}
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({
text: 'Phrase is hosted with SQL.',
voiceId: '49b2c280-1604-4fa9-8f79-30c08f87edd5',
engine: 'eleven_v3',
pronunciations: [{source: 'Phrase', target: 'freɪz', notation: 'ipa'}]
})
};
fetch('https://api.studio.us.phrase.com/v1/tts/speech', 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.studio.us.phrase.com/v1/tts/speech",
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([
'text' => 'Phrase is hosted with SQL.',
'voiceId' => '49b2c280-1604-4fa9-8f79-30c08f87edd5',
'engine' => 'eleven_v3',
'pronunciations' => [
[
'source' => 'Phrase',
'target' => 'freɪz',
'notation' => 'ipa'
]
]
]),
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.studio.us.phrase.com/v1/tts/speech"
payload := strings.NewReader("{\n \"text\": \"Phrase is hosted with SQL.\",\n \"voiceId\": \"49b2c280-1604-4fa9-8f79-30c08f87edd5\",\n \"engine\": \"eleven_v3\",\n \"pronunciations\": [\n {\n \"source\": \"Phrase\",\n \"target\": \"freɪz\",\n \"notation\": \"ipa\"\n }\n ]\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.studio.us.phrase.com/v1/tts/speech")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Phrase is hosted with SQL.\",\n \"voiceId\": \"49b2c280-1604-4fa9-8f79-30c08f87edd5\",\n \"engine\": \"eleven_v3\",\n \"pronunciations\": [\n {\n \"source\": \"Phrase\",\n \"target\": \"freɪz\",\n \"notation\": \"ipa\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.studio.us.phrase.com/v1/tts/speech")
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 \"text\": \"Phrase is hosted with SQL.\",\n \"voiceId\": \"49b2c280-1604-4fa9-8f79-30c08f87edd5\",\n \"engine\": \"eleven_v3\",\n \"pronunciations\": [\n {\n \"source\": \"Phrase\",\n \"target\": \"freɪz\",\n \"notation\": \"ipa\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyGenerate speech
Speak a text with an engine and a voice and get the audio back. The text is at most 500 characters. Pronunciation is corrected the way dubbing does it: inline pronunciations and the sets in pronunciationIds are applied, and each engine gets them in the form it takes (see pronunciationMode of GET /v1/tts/engines). Nothing is saved. At most 30 requests a minute per account, and at most 100,000 characters a day for your whole organization (the voice preview and text-to-speech tool of Studio count against the same budget; it resets at 00:00 UTC); more are refused with 429. It uses no credits, but an organization that has used up its credits (balance.state is BLOCKED) is refused with 403, like the text-to-speech tool of Studio.
curl --request POST \
--url https://api.studio.us.phrase.com/v1/tts/speech \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"text": "Phrase is hosted with SQL.",
"voiceId": "49b2c280-1604-4fa9-8f79-30c08f87edd5",
"engine": "eleven_v3",
"pronunciations": [
{
"source": "Phrase",
"target": "freɪz",
"notation": "ipa"
}
]
}
'import requests
url = "https://api.studio.us.phrase.com/v1/tts/speech"
payload = {
"text": "Phrase is hosted with SQL.",
"voiceId": "49b2c280-1604-4fa9-8f79-30c08f87edd5",
"engine": "eleven_v3",
"pronunciations": [
{
"source": "Phrase",
"target": "freɪz",
"notation": "ipa"
}
]
}
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({
text: 'Phrase is hosted with SQL.',
voiceId: '49b2c280-1604-4fa9-8f79-30c08f87edd5',
engine: 'eleven_v3',
pronunciations: [{source: 'Phrase', target: 'freɪz', notation: 'ipa'}]
})
};
fetch('https://api.studio.us.phrase.com/v1/tts/speech', 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.studio.us.phrase.com/v1/tts/speech",
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([
'text' => 'Phrase is hosted with SQL.',
'voiceId' => '49b2c280-1604-4fa9-8f79-30c08f87edd5',
'engine' => 'eleven_v3',
'pronunciations' => [
[
'source' => 'Phrase',
'target' => 'freɪz',
'notation' => 'ipa'
]
]
]),
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.studio.us.phrase.com/v1/tts/speech"
payload := strings.NewReader("{\n \"text\": \"Phrase is hosted with SQL.\",\n \"voiceId\": \"49b2c280-1604-4fa9-8f79-30c08f87edd5\",\n \"engine\": \"eleven_v3\",\n \"pronunciations\": [\n {\n \"source\": \"Phrase\",\n \"target\": \"freɪz\",\n \"notation\": \"ipa\"\n }\n ]\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.studio.us.phrase.com/v1/tts/speech")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Phrase is hosted with SQL.\",\n \"voiceId\": \"49b2c280-1604-4fa9-8f79-30c08f87edd5\",\n \"engine\": \"eleven_v3\",\n \"pronunciations\": [\n {\n \"source\": \"Phrase\",\n \"target\": \"freɪz\",\n \"notation\": \"ipa\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.studio.us.phrase.com/v1/tts/speech")
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 \"text\": \"Phrase is hosted with SQL.\",\n \"voiceId\": \"49b2c280-1604-4fa9-8f79-30c08f87edd5\",\n \"engine\": \"eleven_v3\",\n \"pronunciations\": [\n {\n \"source\": \"Phrase\",\n \"target\": \"freɪz\",\n \"notation\": \"ipa\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Body
The text to speak.
Text to speak, at most 500 characters (the limit of the text-to-speech tool of Studio).
500Response
The audio.
The response is of type file.
Was this page helpful?