Gemini 2.5 Flash TTS Texto para fala
curl --request POST \
--url https://api.highwayapi.ai/v3/gemini-2.5-flash-tts \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"contents": {
"role": "<string>",
"parts": {
"text": "<string>"
}
},
"generation_config": {
"temperature": 123,
"speech_config": {
"voice_config": {
"prebuilt_voice_config": {
"voice_name": "<string>"
}
},
"language_code": "<string>",
"multi_speaker_voice_config": {
"speaker_voice_configs": [
{
"speaker": "<string>",
"voice_config": {
"prebuilt_voice_config": {
"voice_name": "<string>"
}
}
}
]
}
}
}
}
'import requests
url = "https://api.highwayapi.ai/v3/gemini-2.5-flash-tts"
payload = {
"contents": {
"role": "<string>",
"parts": { "text": "<string>" }
},
"generation_config": {
"temperature": 123,
"speech_config": {
"voice_config": { "prebuilt_voice_config": { "voice_name": "<string>" } },
"language_code": "<string>",
"multi_speaker_voice_config": { "speaker_voice_configs": [
{
"speaker": "<string>",
"voice_config": { "prebuilt_voice_config": { "voice_name": "<string>" } }
}
] }
}
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
contents: {role: '<string>', parts: {text: '<string>'}},
generation_config: {
temperature: 123,
speech_config: {
voice_config: {prebuilt_voice_config: {voice_name: '<string>'}},
language_code: '<string>',
multi_speaker_voice_config: {
speaker_voice_configs: [
{
speaker: '<string>',
voice_config: {prebuilt_voice_config: {voice_name: '<string>'}}
}
]
}
}
}
})
};
fetch('https://api.highwayapi.ai/v3/gemini-2.5-flash-tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.highwayapi.ai/v3/gemini-2.5-flash-tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
'role' => '<string>',
'parts' => [
'text' => '<string>'
]
],
'generation_config' => [
'temperature' => 123,
'speech_config' => [
'voice_config' => [
'prebuilt_voice_config' => [
'voice_name' => '<string>'
]
],
'language_code' => '<string>',
'multi_speaker_voice_config' => [
'speaker_voice_configs' => [
[
'speaker' => '<string>',
'voice_config' => [
'prebuilt_voice_config' => [
'voice_name' => '<string>'
]
]
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.highwayapi.ai/v3/gemini-2.5-flash-tts"
payload := strings.NewReader("{\n \"contents\": {\n \"role\": \"<string>\",\n \"parts\": {\n \"text\": \"<string>\"\n }\n },\n \"generation_config\": {\n \"temperature\": 123,\n \"speech_config\": {\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n },\n \"language_code\": \"<string>\",\n \"multi_speaker_voice_config\": {\n \"speaker_voice_configs\": [\n {\n \"speaker\": \"<string>\",\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n }\n }\n ]\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.highwayapi.ai/v3/gemini-2.5-flash-tts")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"contents\": {\n \"role\": \"<string>\",\n \"parts\": {\n \"text\": \"<string>\"\n }\n },\n \"generation_config\": {\n \"temperature\": 123,\n \"speech_config\": {\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n },\n \"language_code\": \"<string>\",\n \"multi_speaker_voice_config\": {\n \"speaker_voice_configs\": [\n {\n \"speaker\": \"<string>\",\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n }\n }\n ]\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.highwayapi.ai/v3/gemini-2.5-flash-tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"contents\": {\n \"role\": \"<string>\",\n \"parts\": {\n \"text\": \"<string>\"\n }\n },\n \"generation_config\": {\n \"temperature\": 123,\n \"speech_config\": {\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n },\n \"language_code\": \"<string>\",\n \"multi_speaker_voice_config\": {\n \"speaker_voice_configs\": [\n {\n \"speaker\": \"<string>\",\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n }\n }\n ]\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"audioContent": "<string>",
"usageMetadata": {
"totalTokenCount": 123,
"promptTokenCount": 123,
"candidatesTokenCount": 123
}
}Áudio
Gemini 2.5 Flash TTS Texto para fala
POST
/
v3
/
gemini-2.5-flash-tts
Gemini 2.5 Flash TTS Texto para fala
curl --request POST \
--url https://api.highwayapi.ai/v3/gemini-2.5-flash-tts \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"contents": {
"role": "<string>",
"parts": {
"text": "<string>"
}
},
"generation_config": {
"temperature": 123,
"speech_config": {
"voice_config": {
"prebuilt_voice_config": {
"voice_name": "<string>"
}
},
"language_code": "<string>",
"multi_speaker_voice_config": {
"speaker_voice_configs": [
{
"speaker": "<string>",
"voice_config": {
"prebuilt_voice_config": {
"voice_name": "<string>"
}
}
}
]
}
}
}
}
'import requests
url = "https://api.highwayapi.ai/v3/gemini-2.5-flash-tts"
payload = {
"contents": {
"role": "<string>",
"parts": { "text": "<string>" }
},
"generation_config": {
"temperature": 123,
"speech_config": {
"voice_config": { "prebuilt_voice_config": { "voice_name": "<string>" } },
"language_code": "<string>",
"multi_speaker_voice_config": { "speaker_voice_configs": [
{
"speaker": "<string>",
"voice_config": { "prebuilt_voice_config": { "voice_name": "<string>" } }
}
] }
}
}
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
contents: {role: '<string>', parts: {text: '<string>'}},
generation_config: {
temperature: 123,
speech_config: {
voice_config: {prebuilt_voice_config: {voice_name: '<string>'}},
language_code: '<string>',
multi_speaker_voice_config: {
speaker_voice_configs: [
{
speaker: '<string>',
voice_config: {prebuilt_voice_config: {voice_name: '<string>'}}
}
]
}
}
}
})
};
fetch('https://api.highwayapi.ai/v3/gemini-2.5-flash-tts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.highwayapi.ai/v3/gemini-2.5-flash-tts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
'role' => '<string>',
'parts' => [
'text' => '<string>'
]
],
'generation_config' => [
'temperature' => 123,
'speech_config' => [
'voice_config' => [
'prebuilt_voice_config' => [
'voice_name' => '<string>'
]
],
'language_code' => '<string>',
'multi_speaker_voice_config' => [
'speaker_voice_configs' => [
[
'speaker' => '<string>',
'voice_config' => [
'prebuilt_voice_config' => [
'voice_name' => '<string>'
]
]
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.highwayapi.ai/v3/gemini-2.5-flash-tts"
payload := strings.NewReader("{\n \"contents\": {\n \"role\": \"<string>\",\n \"parts\": {\n \"text\": \"<string>\"\n }\n },\n \"generation_config\": {\n \"temperature\": 123,\n \"speech_config\": {\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n },\n \"language_code\": \"<string>\",\n \"multi_speaker_voice_config\": {\n \"speaker_voice_configs\": [\n {\n \"speaker\": \"<string>\",\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n }\n }\n ]\n }\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.highwayapi.ai/v3/gemini-2.5-flash-tts")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"contents\": {\n \"role\": \"<string>\",\n \"parts\": {\n \"text\": \"<string>\"\n }\n },\n \"generation_config\": {\n \"temperature\": 123,\n \"speech_config\": {\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n },\n \"language_code\": \"<string>\",\n \"multi_speaker_voice_config\": {\n \"speaker_voice_configs\": [\n {\n \"speaker\": \"<string>\",\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n }\n }\n ]\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.highwayapi.ai/v3/gemini-2.5-flash-tts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"contents\": {\n \"role\": \"<string>\",\n \"parts\": {\n \"text\": \"<string>\"\n }\n },\n \"generation_config\": {\n \"temperature\": 123,\n \"speech_config\": {\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n },\n \"language_code\": \"<string>\",\n \"multi_speaker_voice_config\": {\n \"speaker_voice_configs\": [\n {\n \"speaker\": \"<string>\",\n \"voice_config\": {\n \"prebuilt_voice_config\": {\n \"voice_name\": \"<string>\"\n }\n }\n }\n ]\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"audioContent": "<string>",
"usageMetadata": {
"totalTokenCount": 123,
"promptTokenCount": 123,
"candidatesTokenCount": 123
}
}Converte texto em fala com base na interface generateContent do Vertex AI. O formato do corpo da solicitação é totalmente consistente com a API oficial do Vertex AI. Oferece suporte a dois modos: síncrono (uma solicitação, uma resposta) e streaming (uma solicitação, resposta em streaming). A saída está no formato LINEAR16 PCM (24kHz, mono, 16-bit signed little-endian), sem cabeçalho WAV.
Cabeçalhos da solicitação
string
obrigatório
Valores enumerados:
application/jsonstring
obrigatório
Formato de autenticação Bearer: Bearer {{API Key}}.
Corpo da solicitação
object
obrigatório
Ocultar properties
Ocultar properties
string
padrão:"user"
obrigatório
Função, fixa como userValores opcionais:
userobject
obrigatório
Ocultar properties
Ocultar properties
string
obrigatório
Conteúdo de texto a ser sintetizado em fala. A API Vertex AI combina o prompt e o texto em um único campo, no formato ’: ’, por exemplo, ‘Say the following in a curious way: OK, so… tell me about this AI thing.’. O tamanho total é de no máximo 8000 bytes; áudios que excederem 655 segundos serão truncados. Oferece suporte a tags de marcação inline: [sigh]、[laughing]、[uhm]、[sarcasm]、[robotic]、[shouting]、[whispering]、[extremely fast]、[short pause]、[medium pause]、[long pause]Limite de comprimento: 0 - 8000
object
obrigatório
Ocultar properties
Ocultar properties
number
padrão:2
Parâmetro de temperatura, controla a aleatoriedade e a criatividade da geração de fala. Valores mais altos geram mais criatividade e diversidade; valores mais baixos são mais previsíveis e focados. Intervalo válido (0.0, 2.0], valor recomendado 2.0Intervalo de valores: [0, 2]
object
obrigatório
Ocultar properties
Ocultar properties
object
Configuração de fala para uma pessoa. Escolha uma entre esta e multi_speaker_voice_config
Ocultar properties
Ocultar properties
object
Ocultar properties
Ocultar properties
string
Nome da voz predefinida (sem diferenciação entre maiúsculas e minúsculas). 30 vozes disponíveis (inclui vozes masculinas e femininas)Valores opcionais:
Achernar, Achird, Algenib, Algieba, Alnilam, Aoede, Autonoe, Callirrhoe, Charon, Despina, Enceladus, Erinome, Fenrir, Gacrux, Iapetus, Kore, Laomedeia, Leda, Orus, Pulcherrima, Puck, Rasalgethi, Sadachbia, Sadaltager, Schedar, Sulafat, Umbriel, Vindemiatrix, Zephyr, Zubenelgenubistring
obrigatório
Código de idioma (formato BCP-47, sem diferenciação entre maiúsculas e minúsculas). Idiomas GA: ar-EG, bn-BD, nl-NL, en-IN, en-US, fr-FR, de-DE, hi-IN, id-ID, it-IT, ja-JP, ko-KR, mr-IN, pl-PL, pt-BR, ro-RO, ru-RU, es-ES, ta-IN, te-IN, th-TH, tr-TR, uk-UA, vi-VN. Idiomas Preview incluem cmn-CN (chinês mandarim) e outros 63Valores opcionais:
af-ZA, am-ET, ar-001, ar-EG, az-AZ, be-BY, bg-BG, bn-BD, ca-ES, ceb-PH, cmn-CN, cmn-TW, cs-CZ, da-DK, de-DE, el-GR, en-AU, en-GB, en-IN, en-US, es-419, es-ES, es-MX, et-EE, eu-ES, fa-IR, fi-FI, fil-PH, fr-CA, fr-FR, gl-ES, gu-IN, he-IL, hi-IN, hr-HR, ht-HT, hu-HU, hy-AM, id-ID, is-IS, it-IT, ja-JP, jv-JV, ka-GE, kn-IN, ko-KR, kok-IN, la-VA, lb-LU, lo-LA, lt-LT, lv-LV, mai-IN, mg-MG, mk-MK, ml-IN, mn-MN, mr-IN, ms-MY, my-MM, nb-NO, ne-NP, nl-NL, nn-NO, or-IN, pa-IN, pl-PL, ps-AF, pt-BR, pt-PT, ro-RO, ru-RU, sd-IN, si-LK, sk-SK, sl-SI, sq-AL, sr-RS, sv-SE, sw-KE, ta-IN, te-IN, th-TH, tr-TR, uk-UA, ur-PK, vi-VNobject
Configuração de fala para múltiplas pessoas. Escolha uma entre esta e voice_config. Observação: gemini-2.5-flash-lite-preview-tts não oferece suporte à síntese com múltiplas pessoas
Ocultar properties
Ocultar properties
object[]
Lista de configurações de voz dos falantes
Ocultar properties
Ocultar properties
string
obrigatório
Alias do falante, deve ser composto apenas por caracteres alfanuméricos, sem espaços. Deve corresponder ao identificador do falante em contents.parts.text
object
obrigatório
Ocultar properties
Ocultar properties
object
Ocultar properties
Ocultar properties
string
Nome da voz predefinida (sem diferenciação entre maiúsculas e minúsculas). 30 vozes disponíveis (inclui vozes masculinas e femininas)Valores opcionais:
Achernar, Achird, Algenib, Algieba, Alnilam, Aoede, Autonoe, Callirrhoe, Charon, Despina, Enceladus, Erinome, Fenrir, Gacrux, Iapetus, Kore, Laomedeia, Leda, Orus, Pulcherrima, Puck, Rasalgethi, Sadachbia, Sadaltager, Schedar, Sulafat, Umbriel, Vindemiatrix, Zephyr, ZubenelgenubiInformações da resposta
string
Conteúdo de áudio codificado em Base64. O formato é LINEAR16 PCM (24kHz, mono, 16-bit signed little-endian), sem cabeçalho WAV. O cliente pode usar ffmpeg para converter: ffmpeg -f s16le -ar 24k -ac 1 -i input.raw output.wav
⌘I