You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Google Cloud文本转语音API-Studio语音遇400错误求助

【更新】

Studio语音仍无法被识别,尚未找到解决方案,错误信息如下:
输入图片描述

【原问题】

尝试使用en-US-Studio-O语音,但添加该语音及其他非标准语音时出现400错误,也已尝试使用非beta端点(v1)。

var untext = response["generations"][0]["text"];
console.info(text); 
var text = "<speak>" + untext + "</speak>";

const apiKey = "redacted"; // Replace with your Google Cloud API key

const apiUrl = `https://texttospeech.googleapis.com/v1beta1/text:synthesize?key=${apiKey}`;
const requestData = {
    input: { 'ssml': text },
    voice: { languageCode: "en-US", name: "en-US-Standard-G", ssmlGender: "NEUTRAL" },
    audioConfig: { audioEncoding: "MP3" },
};

$.ajax({
    url: apiUrl,
    method: "POST",
    data: JSON.stringify(requestData),
    contentType: "application/json",
    success: function (data) {
        const audioContent = data.audioContent;
        const audioUrl = `data:audio/mpeg;base64,${audioContent}`;
        $("#audioElement").attr("src", audioUrl);
        const audio = new Audio(audioUrl);
        audio.play();
    },
    error: function () {
        alert("Error occurred while processing the text.");
    },
});

该语音本应像标准语音一样正常发声,但未能实现。

内容的提问来源于stack exchange,提问作者Reece Atkinson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 06:47:21