</fieldset> <br> <?php if (isset($_POST['appKey'])) { // Let's display what's been provided for Form data so we can see what will be passed // to the HTTP client interface echo "<fieldset><legend>Response Data</legend>\r\n\t\t\t<table border=1 width=80%>\r\n\t\t\t<tr><td colspan=2>Submitted Data</td></tr>\r\n\t\t\t<tr><td>App ID</td><td>{$appId}</td></tr>\r\n\t\t\t<tr><td>App Key</td><td>{$appKey}</td></tr>\r\n\t\t\t<tr><td>Device ID</td><td>{$deviceId}</td></tr>\r\n\t\t\t<tr><td>Language</td><td>{$language}</td></tr>\r\n\t\t\t<tr><td>Codec</td><td>{$codec}</td></tr>\r\n\t\t\t<tr><td>Language Model</td><td>{$languageModel}</td></tr>\r\n\t\t\t<tr><td>Results Format</td><td>{$resultsFormat}</td></tr>\r\n\t\t\t<tr><td>Audio File</td><td>" . implode("<br>", $audioFile) . "</td></tr>\r\n\t\t\t</table><br>"; // If an audio file was submitted, get it's size so we can set the Content-Length header property $contentLength = strlen($audioFilename) > 0 ? $audioFile['size'] : 0; if (!$contentLength) { echo "<br><br>Please provide an audio file<br><br>"; } else { // Get the audio data contained in the uploaded file $audio = $contentLength > 0 ? file_get_contents($audioFile['tmp_name']) : null; // Build our HTTP Request $url = buildRequestString($appId, $appKey, $deviceId); $header = buildHttpHeader($codec, $resultsFormat, $language, $languageModel, $contentLength); // Submit our Dictation or WebSearch Request $m = executeAsrRequest($url, $header, $audio); // For the purposes of this sample/demo, we're just dumping the response to the web page. // In practice, you'll be parsing the Response Code, Response Status, Session Id, and message body (dictation text results) // to determine your application's specific business logic processResults($m); //echo "<br><br>Response: " . var_export($m, true); } echo "</fieldset>"; } ?> </div> </center>
function testAll($selection, $appId, $appKey, $id, $codec, $text) { global $voices; $testResults = array(); foreach ($voices as $v) { // We need to reset the script timer for each TTS request, otherwise the script engine will time out... set_time_limit(25); /* * v[0]: Language Name * v[1]: Language Code (this is the value that actually gets passed to the interface) * v[2]: Voice (a language may have multiple voices available...) */ // This function builds the URI with GET parameters $url = buildRequestString($selection, $appId, $appKey, $id, $v[2], $v[1], $codec, $text); // This function will execute the HTTP Request and pass back the response $m = executeTtsRequest($url); // Save each response to a results array that can be processed later for display $testResults[] = processTestResults($m, $v[1], $v[2]); } // Loop through the result set and display them on the page displayTestResults($testResults); }