Istruzioni API per Text to Speech

, 08-09-2025

L'API è disponibile solo dopo aver finanziato il tuo account.

Voci API JSON https://speechgen.io/index.php?r=api/voices.

Ci sono 2 opzioni di doppiaggio vocale disponibili tramite API:

1 opzione - doppiaggio rapido di testi brevi.
2 opzione - impostazione di un'attività di doppiaggio.

Esempi di integrazione

Scopri come semplificare la creazione di contenuti vocali integrando SpeechGen.io con il servizio di automazione MAKE. Questa guida copre l'automazione dei processi text-to-speech, rendendo più semplice ed efficiente la generazione di contenuti vocali per varie applicazioni.

1 opzione - doppiaggio rapido di testi brevi

URL per la variante 1: https://speechgen.io/index.php?r=api/text

Il testo viene inviato all'API, ottieni risultati immediati.

Questa opzione ha un limite massimo di 2000 caratteri. E anche un massimo di 2 cambi di voce. Se i limiti vengono superati, otterrai un errore (status = -1).

Formato della richiesta

$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, ];

Parametri obbligatori:

'token' - 'SekretKeyInYourProfile' 'email' - 'yourMail@gmail.com' 'voice' - 'Voce' 'text' - 'Testo per Text to Speech'

Parametri opzionali:

'format' - format of the resulting file, by default = mp3, possible values ( 'mp3', 'wav', 'ogg') 'speed' - playback speed, by default 1, (range from 0.1 to 2.0) 'pitch'- voice pitch, by default 0, (range from -20 to 20) 'emotion' - emotion of voice , by default 'good', possible values ( 'good', 'evil', 'neutral'). 'pause_sentence' - The size of the pause between sentences in milliseconds. 'pause_paragraph' - The size of the pause between paragraphs in milliseconds. 'bitrate'=>48000 - Bitrate from 8000 to 192000 Hz.

Emozione Non disponibile per tutte le voci, guarda qui.

La risposta arriva in JSON:

{ "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" }

Descrizione:

"id" - ID univoco della voce "status" - stato attuale del doppiaggio. Disponibile da 3 valori: 0 - in elaborazione 1 - completato con successo -1 - errore "file" - percorso del file audio, disponibile se status= 1 "file_cors" - percorso del file audio CORS "error" - testo dell'errore, in caso di, se status = -1 "parts" - numero di doppiaggi "parts_done" - numero di parti completate "duration" - durata del file audio in secondi, disponibile se status = 1 "format" - formato del file audio "balans" - limite di saldo "cost" - costi del doppiaggio. (aumenta man mano che le parti vocali vengono doppiate)

Esempio di doppiaggio di testo breve in PHP variante 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/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);

Opzione 2 è impostare un'attività di doppiaggio per il testo.

URL per l'opzione 2: https://speechgen.io/index.php?r=api/longtext

Passaggio 1: Il testo viene inviato all'API e si ottiene un ID univoco della voce (id).
Passaggio 2:  Richiedi il risultato del doppiaggio inviando l'identificatore di doppiaggio (id).

Questo metodo non ha limitazioni e consente il doppiaggio di testi fino a 1.000.000 di caratteri. Il doppiaggio avviene in ordine di priorità (primo arrivato, primo servito) e può richiedere da 1 a diversi minuti, a seconda della lunghezza del testo.

Formato della richiesta

$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, ];

Parametri obbligatori:

'token' - 'SekretKeyInYourProfile' 'email' - 'yourMail@gmail.com' 'voice' - 'Voce' 'text' - 'Testo'

Parametri opzionali:

'format' - format of the resulting file, by default = mp3, possible values( 'mp3', 'wav', 'ogg') 'speed' - speed, by default 1, (range from 0.1 to 2.0) 'pitch'- voice pitch, by default 0, (range from -20 to 20) 'emotion' - emotional coloration, by default 'good', possible values ( 'good', 'evil', 'neutral'). 'pause_sentence' - The size of the pause between sentences in milliseconds. 'pause_paragraph' - The size of the pause between paragraphs in milliseconds. 'bitrate'=>48000 - Bitrate from 8000 to 192000 Hz.

Non disponibile per tutte le voci, guarda qui.

La risposta arriva in JSON:

{ "id":"4153594", "status":"0", "parts":"5", "parts_done":"0", "format":"mp3", "error":"", "balans":"3331.2720000314", "cost":"0.00" }

Descrizione:

"id" - ID univoco della voce "status" - stato attuale del doppiaggio. Disponibile da 2 valori: 1 - attività aggiunta con successo -1 - errore "error" - testo dell'errore, in caso di, se status = -1 "parts" - numero di doppiaggi "parts_done" - numero di parti completate "format" - formato del file audio "balans" - il saldo dei limiti dell'account "cost" - costi del doppiaggio. (aumenta man mano che le parti vocali vengono doppiate)

Passaggio 2. Dopo aver creato un'attività e ottenuto un identificatore (id), è necessario inviare una richiesta a https://speechgen.io/index.php?r=api/result, per conoscere il risultato.

Formato della richiesta

$data = [ 'token'=>'SekretKeyInYourProfile', 'email'=>'yourMail@gmail.com', 'id'=>4153594, ];

Parametri obbligatori:

'token' - SekretKeyInYourProfile 'email' - yourMail@gmail.com 'id' - ID univoco della voce ottenuto nel passaggio 1

La risposta arriva in JSON:

{ "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" }

Descrizione:

"id" - ID univoco della voce "status" - stato attuale del doppiaggio. Disponibile da 3 valori: 0 - in corso 1 - completato con successo -1 - errore "file" - percorso del file audio, disponibile se status = 1 "error" - testo dell'errore, in caso di, se status = -1 "parts" - numero di doppiaggi "parts_done" - numero di parti completate "duration" - durata del file audio in secondi, disponibile se status = 1 "format" - formato del file audio "balans" - il saldo dei limiti dell'account "cost" - costi del doppiaggio. (aumenta man mano che le parti vocali vengono doppiate) "cuts" - Array di frammenti, se il tag "cut" è usato nel testo

Esempio di doppiaggio di testo breve in PHP variante 2

//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); }

Utilizziamo i cookie per assicurarti la migliore esperienza sul nostro sito web. Ulteriori informazioni: Informativa sulla privacy

Accetta i cookie