<?php

// iSpeech PHP Script (2013-04-09), version 0.6 (beta)
// Requires the cURL PHP extension
// Designed for cloud-based speech synthesis and speech recognition
// For more information, visit: http://www.ispeech.org/api
require_once 'ispeech.php';
$SpeechSynthesizer = new SpeechSynthesizer();
$SpeechSynthesizer->setParameter('server', 'http://api.ispeech.org/api/rest');
$SpeechSynthesizer->setParameter('apikey', 'developerdemokeydeveloperdemokey');
$SpeechSynthesizer->setParameter('text', 'yes');
$SpeechSynthesizer->setParameter('format', 'wav');
$SpeechSynthesizer->setParameter('voice', 'usenglishfemale');
$SpeechSynthesizer->setParameter('output', 'rest');
$result = $SpeechSynthesizer->makeRequest();
if (is_array($result)) {
    //error occurred
    echo '<pre>' . htmlentities(print_r($result, true), null, 'UTF-8');
} else {
    echo file_put_contents('testing.wav', $result) . ' bytes saved';
}
예제 #2
0
    $SpeechRecognizer->setParameter("audio", base64_encode(file_get_contents($filename)));
    $result = $SpeechRecognizer->makeRequest();
} else {
    if (strtolower($action) == 'recognize') {
        $SpeechRecognizer = new SpeechRecognizer();
        $SpeechRecognizer->setParameter("server", "http://api.ispeech.org/api/rest");
        $SpeechRecognizer->setParameter("apikey", "developerdemokeydeveloperdemokey");
        $SpeechRecognizer->setParameter("freeform", "3");
        $SpeechRecognizer->setParameter("content-type", "wav");
        $SpeechRecognizer->setParameter("language", "en-US");
        $SpeechRecognizer->setParameter("output", "json");
        //send an Audio recording for Speech Recognition
        $SpeechRecognizer->setParameter("audio", base64_encode(file_get_contents($filename)));
        $result = $SpeechRecognizer->makeRequest();
    } else {
        $SpeechSynthesizer = new SpeechSynthesizer();
        $SpeechSynthesizer->setParameter("server", "http://api.ispeech.org/api/rest");
        $SpeechSynthesizer->setParameter("apikey", "developerdemokeydeveloperdemokey");
        // 38a2f9160fdb5acaa03bdf161dd89e4e
        $SpeechSynthesizer->setParameter("text", $text);
        $SpeechSynthesizer->setParameter("format", "wav");
        $SpeechSynthesizer->setParameter("voice", "usenglishfemale");
        $SpeechSynthesizer->setParameter("output", "rest");
        $result = $SpeechSynthesizer->makeRequest();
    }
}
?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>iSpeech API</title>
</head>