【发布时间】:2020-05-26 04:46:06
【问题描述】:
我使用 Node.js 服务器制作了一个简单的音频创建 Web 应用程序。我想使用 Cloud text to Speech API 创建音频,然后将该音频上传到云存储。
(我使用 Windows 10、适用于 Linux 的 Windows 子系统、Debian 10.3 和 Google Chrome 浏览器。)
这是 Node.js 服务器中的代码。
const client = new textToSpeech.TextToSpeechClient();
async function quickStart() {
// The text to synthesize
const text = 'hello, world!';
// Construct the request
const request = {
input: {text: text},
// Select the language and SSML voice gender (optional)
voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
// select the type of audio encoding
audioConfig: {audioEncoding: 'MP3'},
};
// Performs the text-to-speech request
const [response] = await client.synthesizeSpeech(request);
// Write the binary audio content to a local file
console.log(response);
我想将response 上传到云存储。
我可以直接将response 上传到云存储吗?还是我必须将response 保存在 Node.js 服务器中并上传到云存储?
我搜索了互联网,但找不到将response直接上传到云存储的方法。所以,如果你有提示,请告诉我。提前谢谢你。
【问题讨论】:
标签: node.js google-cloud-platform google-cloud-storage google-text-to-speech