我正在开发一个 cocos creator 游戏,它同时构建了 android 和 IOS 版本。我需要在该应用程序中添加“文本到语音”功能。但是我尝试了很多来找到文本到语音的 API,但它们都不能与 Android/IOS 应用程序一起使用。
以下解决方案也仅适用于 Web 浏览器。
所以我决定使用 Google Cloud - 文本到语音 API,但经过大量尝试,我决定向大家询问......
根据我对 Google Cloud 的理解,我们提供了以下详细信息。
请求网址:https ://texttospeech.googleapis.com/v1beta1/text:synthesize
请求正文:
{
"audioConfig": {
"audioEncoding": "LINEAR16",
"pitch": 0,
"speakingRate": 1
},
"input": {
"text": "Hello world"
},
"voice": {
"languageCode": "en-US",
"name": "en-US-Wavenet-D"
}
}
我想我必须使用上述信息编写 HTTP Post 请求才能获得翻译。我写了示例服务器请求,但没有给出好的结果。请看下面..
sendServerReq : function(){
var restChannel = cc.loader.getXMLHttpRequest();
restChannel.open("POST", 'https://texttospeech.googleapis.com/v1beta1/text:synthesize', true);
restChannel.setRequestHeader("Content-Type", "application/json");
var jsonObj = {
"audioConfig": {
"audioEncoding": "LINEAR16",
"pitch": 0,
"speakingRate": 1
},
"input": {
"text": "おはようございます"
},
"voice": {
"languageCode": "ja-JP",
"name": "ja-JP-Standard-B"
}
};
var response = restChannel.send(jsonObj);
},
你能告诉我如何使用谷歌云来实现“文本到语音”功能,或者是否有任何免费的 API 可以在 COCCOS Creator Android/IOS 应用程序中获取文本到语音功能。
非常感谢
我需要的是在我的游戏应用程序中添加文本到语音功能
sendServerReq : function(){
var restChannel = cc.loader.getXMLHttpRequest();
restChannel.open("POST", 'https://texttospeech.googleapis.com/v1beta1/text:synthesize', true);
restChannel.setRequestHeader("Content-Type", "application/json");
var jsonObj = {
"audioConfig": {
"audioEncoding": "LINEAR16",
"pitch": 0,
"speakingRate": 1
},
"input": {
"text": "おはようございます"
},
"voice": {
"languageCode": "ja-JP",
"name": "ja-JP-Standard-B"
}
};
var response = restChannel.send(jsonObj);
},
- 那是一个错误。
/v1beta1/text:synthesize
在此服务器上找不到请求的 URL