{"id":151,"date":"2017-02-14T22:08:35","date_gmt":"2017-02-14T22:08:35","guid":{"rendered":"https:\/\/voip-communications.net\/vcw\/?page_id=151"},"modified":"2018-01-11T11:32:12","modified_gmt":"2018-01-11T17:32:12","slug":"tts-api","status":"publish","type":"page","link":"https:\/\/voip-communications.net\/vcw\/tts\/tts-api\/","title":{"rendered":"TTS API"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignright wp-image-190 size-thumbnail\" src=\"https:\/\/voip-communications.net\/vcw\/wp-content\/uploads\/2017\/02\/api-150x150.png\" width=\"150\" height=\"150\" \/><div class='alert alert-success'>PRICE: US$0.00000 per character in the text to speech<\/div><br \/>\nOur TTS API gives you access to the TTS Engine.<\/p>\n<ul id=\"ttsApiTabs\" class=\"nav nav-tabs\">\n<li class=\"active\"><a href=\"#ttsSpeech\" data-toggle=\"tab\">SPEECH<\/a><\/li>\n<\/ul>\n<div class=\"tab-content\">\n<div id=\"ttsSpeech\" class=\"tab-pane active\">\n<p>Speech, process the text to audio<\/p>\n<h3>URL:<\/h3>\n<p>https:\/\/voip-communications.net\/api-v2\/index.php\/tts\/speech<\/p>\n<h3>Method:<\/h3>\n<p>POST<\/p>\n<h3>Authentication:<\/h3>\n<p>Basic<\/p>\n<h3>Parameters:<\/h3>\n<ul>\n<li><strong>voice <span style=\"color: #ff0000;\">(required)<\/span><\/strong>: possible values: <table>\n\t<thead>\n\t\t<tr>\n\t\t\t<th>Code<\/th>\n\t\t\t<th>Gender<\/th>\n\t\t\t<th>Language<\/th>\n\t\t\t<tr><\/tr>\n\t\t<\/tr>\n\t<\/thead>\n\t<tbody>\n\t\t\t<\/tbody>\n<\/table><\/li>\n<li><strong>text <span style=\"color: #ff0000;\">(required)<\/span><\/strong>: text to be processed by out TTS Engine<\/li>\n<li><strong>audio_format<\/strong> <strong><span style=\"color: #ff0000;\">(required)<\/span><\/strong>: possible values:\n<ul>\n<li>Ogg: Ogg format with the opus codec, default sample rate 48000 Hz<\/li>\n<li>WAV: Waveform Audio File Format, default sample rate 22050 Hz<\/li>\n<li>FLAC: Free Lossless Audio Codec, default sample rate 22050 Hz<\/li>\n<li>MP3: Mp3 audio format with 22050 Hz sample rate<\/li>\n<\/ul>\n<\/li>\n<li>sample_rate (optional): if you want the audio file to be generated with a different sample rate from it defaults, just indicate the new sample rate as a integer number.<\/li>\n<li><strong>return_type<\/strong> <strong><span style=\"color: #ff0000;\">(required)<\/span><\/strong>: possible values:\n<ul>\n<li>URL: return the URL of the generated file<\/li>\n<li>FILE: return the audio file<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>HTTP Response Codes:<\/h3>\n<ul>\n<li>200: Success<\/li>\n<li>400: Invalid request data<\/li>\n<li>402: Insufficient\u00a0funds<\/li>\n<li>401: Invalid api credentials<\/li>\n<li>405: Invalid\u00a0request method<\/li>\n<\/ul>\n<h3>Response data:<\/h3>\n<p>if return_type was URL, you will get the next json object:<\/p>\n<pre>{\r\n \"file_url\": \"https:\/\/voip-communications.net\/tts_files\/20171004161656-17-338.WAV\",\r\n \"voice\": \"en-US_AllisonVoice\",\r\n \"audio_format\": \"WAV\",\r\n \"sample_rate\": \"8000\"\r\n}<\/pre>\n<p>if return_type was FILE, you will get the generated file (binary)<\/p>\n<hr \/>\n<h3>Curl Example:<\/h3>\n<pre>curl -u YOUR_API_KEY:YOUR_API_PASSWORD \r\n     --data\"voice=VOICECODE&amp;text=TEXT_TO_SPEECH&amp;audio_format=AUDIO_FORMAT&amp;return_type=FILE\"\r\n     --output OUTPUT_FILE_NAME\r\n     https:\/\/voip-communications.net\/API\/index.php\/tts\/speech<\/pre>\n<hr \/>\n<h3>PHP Example:<\/h3>\n<pre>$service_url = \"https:\/\/voip-communications.net\/api-v2\/index.php\/tts\/speech\";\r\n$curl = curl_init($service_url);\r\ncurl_setopt($curl, CURLOPT_USERPWD, \"YOUR_API_KEY:YOUR_API_PASSWORD\");\r\ncurl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\r\n$post_fields = array(\"voice\" =&gt; \"VOICE_CODE\",\r\n                     \"audio_format\" =&gt; \"WAV\",\r\n                     \"text\" =&gt; \"TEXT TO SPEECH\",\r\n                     \"return_type\" =&gt; \"URL\");\r\ncurl_setopt($curl, CURLOPT_POST, true);\r\ncurl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post_fields));\r\n$curl_response = curl_exec($curl);\r\nif ($curl_response !== false) {\r\n    $http_code = curl_getinfo($curl,CURLINFO_HTTP_CODE);\r\n    if ($http_code == \"200\") {\r\n        $result = json_decode($curl_response,true);\r\n        $audio_file = $result[\"file_url\"];\r\n    }\r\n}\r\ncurl_close($curl);<\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Our TTS API gives you access to the TTS Engine. SPEECH Speech, process the text to audio URL: https:\/\/voip-communications.net\/api-v2\/index.php\/tts\/speech Method: POST Authentication: Basic Parameters: voice (required): possible values: text (required): text to be processed by out TTS Engine audio_format (required): possible values: Ogg: Ogg format with the opus codec, default sample rate 48000 Hz WAV: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":26,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/151"}],"collection":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":31,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/151\/revisions"}],"predecessor-version":[{"id":805,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/151\/revisions\/805"}],"up":[{"embeddable":true,"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/pages\/26"}],"wp:attachment":[{"href":"https:\/\/voip-communications.net\/vcw\/wp-json\/wp\/v2\/media?parent=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}