使用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
相关产品推荐
相关产品推荐

