Speech
Text to Speech
Generates speech from text with one of your voices and returns the whole clip in a single response.
POST
/
v2
/
Speech
Text to Speech
curl --request POST \
--url https://api.nlpearl.ai/v2/Speech \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "Your appointment is confirmed for Thursday at ten.",
"voiceId": "1cf704d389adfc067d749a51",
"modelId": "nlpearl-v2-preview",
"pace": "medium",
"tier": "standard",
"outputFormat": "mp3_44100_128"
}
'import requests
url = "https://api.nlpearl.ai/v2/Speech"
payload = {
"text": "Your appointment is confirmed for Thursday at ten.",
"voiceId": "1cf704d389adfc067d749a51",
"modelId": "nlpearl-v2-preview",
"pace": "medium",
"tier": "standard",
"outputFormat": "mp3_44100_128"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'Your appointment is confirmed for Thursday at ten.',
voiceId: '1cf704d389adfc067d749a51',
modelId: 'nlpearl-v2-preview',
pace: 'medium',
tier: 'standard',
outputFormat: 'mp3_44100_128'
})
};
fetch('https://api.nlpearl.ai/v2/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.nlpearl.ai/v2/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' => 'Your appointment is confirmed for Thursday at ten.',
'voiceId' => '1cf704d389adfc067d749a51',
'modelId' => 'nlpearl-v2-preview',
'pace' => 'medium',
'tier' => 'standard',
'outputFormat' => 'mp3_44100_128'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.nlpearl.ai/v2/Speech"
payload := strings.NewReader("{\n \"text\": \"Your appointment is confirmed for Thursday at ten.\",\n \"voiceId\": \"1cf704d389adfc067d749a51\",\n \"modelId\": \"nlpearl-v2-preview\",\n \"pace\": \"medium\",\n \"tier\": \"standard\",\n \"outputFormat\": \"mp3_44100_128\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.nlpearl.ai/v2/Speech")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Your appointment is confirmed for Thursday at ten.\",\n \"voiceId\": \"1cf704d389adfc067d749a51\",\n \"modelId\": \"nlpearl-v2-preview\",\n \"pace\": \"medium\",\n \"tier\": \"standard\",\n \"outputFormat\": \"mp3_44100_128\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nlpearl.ai/v2/Speech")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Your appointment is confirmed for Thursday at ten.\",\n \"voiceId\": \"1cf704d389adfc067d749a51\",\n \"modelId\": \"nlpearl-v2-preview\",\n \"pace\": \"medium\",\n \"tier\": \"standard\",\n \"outputFormat\": \"mp3_44100_128\"\n}"
response = http.request(request)
puts response.read_body"<string>"{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}Authorizations
bearer_authoauth2_client_credentials
Specify the authorization token.
For more information, check out the Authorization Guide.
Body
application/json
The text to speak, in the voice's language.
Required string length:
1 - 5000The voice to use. List your voices with Get Voices.
The speech model.
Available options:
nlpearl-v2-preview How fast the voice speaks.
Available options:
very_slow, slow, medium, fast, very_fast Your place in the queue when the service is busy. priority goes ahead of waiting standard requests and is charged at the Priority rate only when it did.
Available options:
standard, priority Codec, sample rate and bitrate of the audio, for example mp3_44100_128, pcm_16000 or ulaw_8000.
Available options:
pcm_8000, pcm_16000, pcm_22050, pcm_24000, pcm_44100, pcm_48000, wav_8000, wav_16000, wav_22050, wav_24000, wav_44100, wav_48000, ulaw_8000, alaw_8000, mp3_22050_32, mp3_44100_32, mp3_44100_64, mp3_44100_96, mp3_44100_128, mp3_44100_192, opus_48000_32, opus_48000_64, opus_48000_96, opus_48000_128, opus_48000_192 Response
The audio file.
The response is of type file.
⌘I
Text to Speech
curl --request POST \
--url https://api.nlpearl.ai/v2/Speech \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "Your appointment is confirmed for Thursday at ten.",
"voiceId": "1cf704d389adfc067d749a51",
"modelId": "nlpearl-v2-preview",
"pace": "medium",
"tier": "standard",
"outputFormat": "mp3_44100_128"
}
'import requests
url = "https://api.nlpearl.ai/v2/Speech"
payload = {
"text": "Your appointment is confirmed for Thursday at ten.",
"voiceId": "1cf704d389adfc067d749a51",
"modelId": "nlpearl-v2-preview",
"pace": "medium",
"tier": "standard",
"outputFormat": "mp3_44100_128"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
text: 'Your appointment is confirmed for Thursday at ten.',
voiceId: '1cf704d389adfc067d749a51',
modelId: 'nlpearl-v2-preview',
pace: 'medium',
tier: 'standard',
outputFormat: 'mp3_44100_128'
})
};
fetch('https://api.nlpearl.ai/v2/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.nlpearl.ai/v2/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' => 'Your appointment is confirmed for Thursday at ten.',
'voiceId' => '1cf704d389adfc067d749a51',
'modelId' => 'nlpearl-v2-preview',
'pace' => 'medium',
'tier' => 'standard',
'outputFormat' => 'mp3_44100_128'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.nlpearl.ai/v2/Speech"
payload := strings.NewReader("{\n \"text\": \"Your appointment is confirmed for Thursday at ten.\",\n \"voiceId\": \"1cf704d389adfc067d749a51\",\n \"modelId\": \"nlpearl-v2-preview\",\n \"pace\": \"medium\",\n \"tier\": \"standard\",\n \"outputFormat\": \"mp3_44100_128\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.nlpearl.ai/v2/Speech")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Your appointment is confirmed for Thursday at ten.\",\n \"voiceId\": \"1cf704d389adfc067d749a51\",\n \"modelId\": \"nlpearl-v2-preview\",\n \"pace\": \"medium\",\n \"tier\": \"standard\",\n \"outputFormat\": \"mp3_44100_128\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nlpearl.ai/v2/Speech")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Your appointment is confirmed for Thursday at ten.\",\n \"voiceId\": \"1cf704d389adfc067d749a51\",\n \"modelId\": \"nlpearl-v2-preview\",\n \"pace\": \"medium\",\n \"tier\": \"standard\",\n \"outputFormat\": \"mp3_44100_128\"\n}"
response = http.request(request)
puts response.read_body"<string>"{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}
