1. Go to this page and download the library: Download uzulla/voicetext-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uzulla / voicetext-api example snippets
\Uzulla\WebApi\VoiceText\Request as VTR;
use \Uzulla\WebApi\VoiceText\Query as VTQ;
// setup
\Uzulla\WebApi\VoiceText\Query::$defaultApiKey = 'YOUR API KEY';
// build query
$query = new VTQ;
$query->text = 'hello';
// request
$res = VTR::getResponse($query);
if($res->isSuccess()){
$downloaded_wav_file_name = $res->tempFileName;
}else{
echo "request fail.";
var_dump($res);
}
// ...
// param details, see official api doc https://cloud.voicetext.jp/webapi/docs/api
$query = new VTQ;
$query->text = 'こんにちは';
$query->speaker = 'haruka';
$query->emotion = 'happiness';
$query->emotion_level = 2;
$query->pitch = 100;
$query->speed = 100;
$query->volume = 100;
$error_list = $query->validate();
if(!empty($error_list)){
// query is invalid (local validation). use correct data.
var_dump($error_list); // array(1) { 'emotion' => string(35) "specify speaker not support emotion" }
}else{
// request
$res = VTR::getResponse($query);
if($res->isSuccess()){
$downloaded_wav_file_name = $res->tempFileName;
}else{
echo "request fail.";
var_dump($res);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.