08-09-2025 , 16-09-2025
APIはアカウントに資金をチャージした後のみ利用可能です。
JSON APIボイスはこちら:https://speechgen.io/index.php?r=api/voices。
APIで利用できるテキスト読み上げオプションは2つあります:
オプション1 - 短いテキストのクイック読み上げ。
オプション2 - 読み上げタスクの設定。
SpeechGen.ioと自動化サービスMAKEを連携させて、音声コンテンツ作成を効率化する方法をご覧ください。このガイドでは、テキスト読み上げプロセスを自動化し、さまざまなアプリケーション向けの音声コンテンツ生成をより簡単かつ効率的に行う方法を説明します。
オプション1のURL:https://speechgen.io/index.php?r=api/text
このオプションでは、最大2000文字の制限があります。また、ボイス変更は最大2回までです。制限を超えるとエラー(status = -1)が発生します。
$data = [
'token'=>'SekretKeyInYourProfile',
'email'=>'yourMail@gmail.com',
'voice'=>'John',
'text'=>"Text for text to Speech",
'format'=>'mp3',
'speed'=>1.1,
'pitch'=>0.8,
'emotion'=>'good',
'pause_sentence'=>300,
'pause_paragraph'=>400,
'bitrate'=>48000,
];
'token' - 'SekretKeyInYourProfile'
'email' - 'yourMail@gmail.com'
'voice' - 'ボイス名'
'text' - 'テキスト読み上げ用のテキスト'
'format' - 結果ファイルの形式。デフォルトはmp3。可能な値( 'mp3', 'wav', 'ogg')
'speed' - 再生速度。デフォルトは1。(0.1から2.0の範囲)
'pitch'- 声のピッチ。デフォルトは0。(-20から20の範囲)
'emotion' - 声の感情。デフォルトは'good'。可能な値( 'good', 'evil', 'neutral')。
'pause_sentence' - 文間のポーズの長さ(ミリ秒)。
'pause_paragraph' - 段落間のポーズの長さ(ミリ秒)。
'bitrate'=>48000 - ビットレート(8000から192000 Hz)。
感情はすべてのボイスで利用できるわけではありません。こちらでご確認ください。
{
"id":"4153594",
"status":"0",
"file":"result.mp3",
"file_cors":"result_cors.mp3",
"parts":"5",
"parts_done":"2",
"duration":"0",
"format":"mp3",
"error":"",
"balans":"3331.2720000314",
"cost":"0.06"
}
"id" - ユニークなボイスID
"status" - 現在の読み上げステータス。3つの値があります:
0 - 処理中
1 - 正常に完了
-1 - エラー
"file" - 音声ファイルパス。status= 1 の場合に利用可能
"file_cors" - 音声ファイルパス CORS
"error" - エラーテキスト。status = -1 の場合
"parts" - 読み上げ部分の数
"parts_done" - 完了した部分の数
"duration" - 音声ファイルの長さ(秒)。status = 1 の場合に利用可能
"format" - 音声ファイルの形式
"balans" - 残高制限
"cost" - 読み上げ費用。(ボイス部分が読み上げられるにつれて増加します)
$data = [
'token' => '123456',
'email' => 'mail@mail.com',
'voice' => 'John',
'text' => "Text",
'format' => 'mp3',
'speed' => 1.1,
'pitch' => 0,
'emotion' => 'good',
];
$url = "https://speechgen.io/index.php?r=api/text";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
var_dump($response);
$response = json_decode($response, true);
if (curl_errno($ch)) {
var_dump("Connection error with text recognition server, " . curl_error($ch));
} else {
var_dump($response);
if ($response["status"] == 1) {
//Copy
echo " ok " . $response["file"];
copy($response["file"], 'Filename.' . $response["format"]);
} else {
//Error, no voiceover possible
echo $response["error"];
}
}
curl_close($ch);
ステップ1:APIにテキストを送信し、ユニークなボイスID(id)を取得します。
ステップ2:読み上げ識別子(id)を送信して、ダビングの結果をリクエストします。
この方法には制限がなく、最大1,000,000文字までのテキストダビングが可能です。ダビングは優先順位(先着順)で行われ、テキストの長さに応じて1分から数分かかる場合があります。
$data = [
'token'=>'SekretKeyInYourProfile',
'email'=>'yourMail@gmail.com',
'voice'=>'John',
'text'=>"Text",
'format'=>'mp3',
'speed'=>1.1,
'pitch'=>0.8,
'emotion'=>'good',
'pause_sentence'=>300,
'pause_paragraph'=>400,
'bitrate'=>48000,
];
'token' - 'SekretKeyInYourProfile'
'email' - 'yourMail@gmail.com'
'voice' - 'ボイス名'
'text' - 'テキスト'
'format' - 結果ファイルの形式。デフォルトはmp3。可能な値( 'mp3', 'wav', 'ogg')
'speed' - 速度。デフォルトは1。(0.1から2.0の範囲)
'pitch'- 声のピッチ。デフォルトは0。(-20から20の範囲)
'emotion' - 声の感情。デフォルトは'good'。可能な値( 'good', 'evil', 'neutral')。
'pause_sentence' - 文間のポーズの長さ(ミリ秒)。
'pause_paragraph' - 段落間のポーズの長さ(ミリ秒)。
'bitrate'=>48000 - ビットレート(8000から192000 Hz)。
すべてのボイスで利用できるわけではありません。こちらでご確認ください。
{
"id":"4153594",
"status":"0",
"parts":"5",
"parts_done":"0",
"format":"mp3",
"error":"",
"balans":"3331.2720000314",
"cost":"0.00"
}
"id" - ユニークなボイスID
"status" - 現在の読み上げステータス。2つの値があります:
1 - タスクが正常に追加されました
-1 - エラー
"error" - エラーテキスト。status = -1 の場合
"parts" - 読み上げ部分の数
"parts_done" - 完了した部分の数
"format" - 音声ファイルの形式
"balans" - 口座制限の残高
"cost" - 読み上げ費用。(ボイス部分が読み上げられるにつれて増加します)
ステップ2。タスクを作成し、識別子(id)を取得した後、結果を確認するためにhttps://speechgen.io/index.php?r=api/resultにリクエストを送信する必要があります。
$data = [
'token'=>'SekretKeyInYourProfile',
'email'=>'yourMail@gmail.com',
'id'=>4153594,
];
'token' - SekretKeyInYourProfile
'email' - yourMail@gmail.com
'id' - ステップ1で取得したユニークなボイスID
{
"id":"4153594",
"status":"0",
"file":"result.mp3",
"cuts":["result_1.mp3","result_2.mp3",...],
"parts":"5",
"parts_done":"0",
"format":"mp3",
"error":"",
"balans":"3331.2720000314",
"cost":"0.00"
}
"id" - ユニークなボイスID
"status" - 現在の読み上げステータス。3つの値があります:
0 - 処理中
1 - 正常に完了
-1 - エラー
"file" - 音声ファイルパス。status = 1 の場合に利用可能
"error" - エラーテキスト。status = -1 の場合
"parts" - 読み上げ部分の数
"parts_done" - 完了した部分の数
"duration" - 音声ファイルの長さ(秒)。status = 1 の場合に利用可能
"format" - 音声ファイルの形式
"balans" - 口座制限の残高
"cost" - 読み上げ費用。(ボイス部分が読み上げられるにつれて増加します)
"cuts" - フラグメントの配列。「cut」タグがテキストで使用されている場合
//STEP 1
$data = [
'token' => '123456',
'email' => 'mail@mail.com',
'voice' => 'John',
'text' => "Text",
'format' => 'mp3',
'speed' => 1.1,
'pitch' => 0,
'emotion' => 'good',
];
$url = "https://speechgen.io/index.php?r=api/longtext";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
var_dump($response);
$response = json_decode($response, true);
$resultId = 0;
if (curl_errno($ch)) {
var_dump("Error in connecting to the text recognition server, " . curl_error($ch));
} else {
var_dump($response);
if ($response["status"] == 1) {
//Copy
echo " ok " . $response["file"];
copy($response["file"], 'FileName.' . $response["format"]);
} elseif ($response["status"] == 0) {
//Remember the voice ID, and ask for the result later
$resultId = $response["id"];
} else {
//Error, no voiceover possible
echo $response["error"];
}
}
curl_close($ch);
//STEP 2
// Every minute we make a query-check of the result
if($resultId){
$data = [
'token'=>'123456',
'email'=>'mail@mail.com',
'id'=>$resultId,
];
$url = "https://speechgen.io/index.php?r=api/result";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
var_dump($response);
$response = json_decode($response,true);
if (curl_errno($ch)) {
var_dump("Error in connecting to the text recognition server, ".curl_error($ch));
}else{
var_dump($response);
if($response["status"] == 1){
//Copy
echo " ok ".$response["file"];
copy($response["file"], 'FileMane.' . $response["format"]);
}elseif($response["status"] == 0){
//Not ready yet, we will ask for the result later
echo "In process...";
}else{
//Error, no voiceover possible
echo $response["error"];
}
}
curl_close($ch);
}