Voice Broadcast API
GetTTSInMP3
This method returns text-to-speech (TTS) as a sound file in the MP3 format. This method returns an MP3 encoded in a 32, 64, or 128 kbit/s bit rate. (An additional license key is required for this method. Please contact Esendex to activate a TTS License Key.)
Syntax
GetTTSInMP3(TextToSay, VoiceID, BitRate, TTSrate, TTSvolume, LicenseKey)
Request Parameters
Parameter Name | Description | Data Type | Required | Sample Value |
---|---|---|---|---|
TextToSay | The text-to-speech text or combination of text-to-speech and script to be read. | String | True | Hello, this is a sample call from Phone Notify. |
VoiceID | The text-to-speech voice ID. | Integer | True | 2 |
BitRate | The bit rate for the MP3 file, in kbit/s. Valid bit rates are 32, 64, and 128. | Integer | True | 128 |
TTSrate | The speed that text-to-speech (TTS) will use when speaking the text. The value ranges from 0 to 20 (10 being normal). This can also be controlled within the TextToSay parameter. | Byte | True | 10 |
TTSvolume | The volume that text-to-speech (TTS) will use when speaking the text. The value ranges from 0 to 100 (100 is the default). This can also be controlled within the TextToSay parameter. | Byte | True | 100 |
LicenseKey | Your license key. | String | True | 00000000-0000-0000-0000-000000000000 |
Response
Returns: GetTTSInMP3Response
Description: The result of the text-to-speech file in MP3 format.
Code Samples
You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.
- C#
- Python
- GET Request
- POST Request
- SOAP 1.1 Request
- SOAP 1.1 Response
- SOAP 1.2 Request
- SOAP 1.2 Response
- XML Response
C#
/* https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl was added as a Service Reference and given the name WSDL */
using WSDL;
var client = new PhoneNotifySoapClient(PhoneNotifySoapClient.EndpointConfiguration.PhoneNotifySoap);
var textToSay = "Hello, this is a test sound.";
int voiceId = 1;
int bitRate = 128;
byte ttsRate = 10;
byte ttsVolume = 100;
var soundFile = await client.GetTTSInMP3Async(textToSay, voiceId, bitRate, ttsRate, ttsVolume, YOUR_LICENSE_KEY);
try
{
var fs = new FileStream(@"C:\Users\Public\tts-sound.mp3", FileMode.Create, FileAccess.Write);
fs.Write(soundFile.GetTTSInMP3Result, 0, soundFile.GetTTSInMP3Result.Length);
fs.Close();
Console.WriteLine("Sound file saved.");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Python
import zeep
client = zeep.Client(wsdl="https://ws.esendex.us/notifyws/phonenotify.asmx?wsdl")
text_to_say = "Hello, this is a test sound."
voice_id = 1
bit_rate = 128
tts_rate = 10
tts_volume = 100
license_key = "00000000-0000-0000-0000-000000000000"
sound_file = client.service.GetTTSInMP3(
text_to_say, voice_id, bit_rate, tts_rate, tts_volume, license_key
)
with open(r"C:\Users\Public\tts-sound.mp3", "wb") as io:
io.write(sound_file)
GET Request
GET /NotifyWS/PhoneNotify.asmx/GetTTSInMP3?TextToSay=string&VoiceID=string&BitRate=string&TTSrate=string&TTSvolume=string&LicenseKey=string HTTP/1.1
Host: ws.esendex.us
POST Request
POST /NotifyWS/PhoneNotify.asmx/GetTTSInMP3 HTTP/1.1
Host: ws.esendex.us
Content-Type: application/x-www-form-urlencoded
Content-Length: length
TextToSay=string&VoiceID=string&BitRate=string&TTSrate=string&TTSvolume=string&LicenseKey=string
SOAP 1.1 Request
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://ws.esendex.us/NotifyWS/GetTTSInMP3"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetTTSInMP3 xmlns="https://ws.esendex.us/NotifyWS/">
<TextToSay>string</TextToSay>
<VoiceID>int</VoiceID>
<BitRate>int</BitRate>
<TTSrate>unsignedByte</TTSrate>
<TTSvolume>unsignedByte</TTSvolume>
<LicenseKey>string</LicenseKey>
</GetTTSInMP3>
</soap:Body>
</soap:Envelope>
SOAP 1.1 Response
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetTTSInMP3Response xmlns="https://ws.esendex.us/NotifyWS/">
<GetTTSInMP3Result>base64Binary</GetTTSInMP3Result>
</GetTTSInMP3Response>
</soap:Body>
</soap:Envelope>
SOAP 1.2 Request
POST /NotifyWS/PhoneNotify.asmx HTTP/1.1
Host: ws.esendex.us
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetTTSInMP3 xmlns="https://ws.esendex.us/NotifyWS/">
<TextToSay>string</TextToSay>
<VoiceID>int</VoiceID>
<BitRate>int</BitRate>
<TTSrate>unsignedByte</TTSrate>
<TTSvolume>unsignedByte</TTSvolume>
<LicenseKey>string</LicenseKey>
</GetTTSInMP3>
</soap12:Body>
</soap12:Envelope>
SOAP 1.2 Response
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetTTSInMP3Response xmlns="https://ws.esendex.us/NotifyWS/">
<GetTTSInMP3Result>base64Binary</GetTTSInMP3Result>
</GetTTSInMP3Response>
</soap12:Body>
</soap12:Envelope>
XML Response
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<base64Binary xmlns="https://ws.esendex.us/NotifyWS/">base64Binary</base64Binary>
Let’s start sending, together.