This method returns text-to-speech (TTS) as a sound file in the μ-law (u-law) format. (An additional license key is required for this method. Please contact Esendex to activate a TTS License Key.)
Syntax
GetTTSInULAW(TextToSay, VoiceID, 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 |
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 being 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: GetTTSInULAWResponse
Description: The result of the text-to-speech file in μ-law (u-law) 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;
byte ttsRate = 10;
byte ttsVolume = 100;
var soundFile = await client.GetTTSInULAWAsync(textToSay, voiceId, ttsRate, ttsVolume, YOUR_LICENSE_KEY);
try
{
var fs = new FileStream(@"C:UsersPublictts-sound.ulaw", FileMode.Create, FileAccess.Write);
fs.Write(soundFile.GetTTSInULAWResult, 0, soundFile.GetTTSInULAWResult.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
tts_rate = 10
tts_volume = 100
license_key = "00000000-0000-0000-0000-000000000000"
sound_file = client.service.GetTTSInULAW(
text_to_say, voice_id, tts_rate, tts_volume, license_key
)
with open(r"C:UsersPublictts-sound.ulaw", "wb") as io:
io.write(sound_file)
GET Request
GET /NotifyWS/PhoneNotify.asmx/GetTTSInULAW?TextToSay=string&VoiceID=string&TTSrate=string&TTSvolume=string&LicenseKey=string HTTP/1.1
Host: ws.esendex.us
POST Request
POST /NotifyWS/PhoneNotify.asmx/GetTTSInULAW HTTP/1.1
Host: ws.esendex.us
Content-Type: application/x-www-form-urlencoded
Content-Length: length
TextToSay=string&VoiceID=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/GetTTSInULAW"
<?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>
<GetTTSInULAW xmlns="https://ws.esendex.us/NotifyWS/">
<TextToSay>string</TextToSay>
<VoiceID>int</VoiceID>
<TTSrate>unsignedByte</TTSrate>
<TTSvolume>unsignedByte</TTSvolume>
<LicenseKey>string</LicenseKey>
</GetTTSInULAW>
</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>
<GetTTSInULAWResponse xmlns="https://ws.esendex.us/NotifyWS/">
<GetTTSInULAWResult>base64Binary</GetTTSInULAWResult>
</GetTTSInULAWResponse>
</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>
<GetTTSInULAW xmlns="https://ws.esendex.us/NotifyWS/">
<TextToSay>string</TextToSay>
<VoiceID>int</VoiceID>
<TTSrate>unsignedByte</TTSrate>
<TTSvolume>unsignedByte</TTSvolume>
<LicenseKey>string</LicenseKey>
</GetTTSInULAW>
</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>
<GetTTSInULAWResponse xmlns="https://ws.esendex.us/NotifyWS/">
<GetTTSInULAWResult>base64Binary</GetTTSInULAWResult>
</GetTTSInULAWResponse>
</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>