json - 一次调用同时从 AWS Polly 获取 mp3 和 json(节省成本)
问题描述
我在这里问了一个问题,几秒钟后我自己回答了:Get mp3 and speech mark from Amazon Polly using NodeJs
我想知道我是否必须打两个电话才能获取文本的 json 和 mp3?
let params = {
'Text': 'Hi, my name is Soley. We are building something amazing!',
'OutputFormat': 'json',
'VoiceId': 'Matthew',
'SpeechMarkTypes': ['word', 'sentence']
}
和
let params = {
'Text': 'Hi, my name is Soley. We are building something amazing!',
'OutputFormat': 'mp3',
'VoiceId': 'Matthew'
}
似乎 polly ui https://us-east-1.console.aws.amazon.com/polly/home/SynthesizeSpeech也分开做?
^ 没有 mp3 的下载链接,请求 json 时只需播放按钮。
解决方案
SynthesizeSpeech API 只能接受一个参数作为输出格式,所以是的,你必须调用它两次。
OutputFormat
The format in which the returned output will be encoded.
For audio stream, this will be mp3, ogg_vorbis, or pcm.
For speech marks, this will be json.
When pcm is used, the content returned is audio/pcm in a signed 16-bit,
1 channel (mono), little-endian format.
Type: String
Valid Values: json | mp3 | ogg_vorbis | pcm
Required: Yes
https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html
推荐阅读
- mysql - Time column value change without touching it
- vb.net - 如何读取通过 GetFiles 函数找到的文件的文件属性?
- r - 使用一个向量中的值来更改 R 中另一个向量中的值(for 循环)
- react-navigation - 如何使用反应导航删除双标头?
- html - 如何在附图中制作像这样的粘性/固定侧导航?
- javascript - 当使用 DOMNodeInserted 在控制台中正确显示时,为什么元素的 id 未定义?
- java - 这个 TestNg SoftAssert 的替代方案如何?
- python - 在 Numpy 中有效地计算欧几里德分布矩阵?
- webpack - 不能在电子锻造中使用静态文件
- pycharm - Pycharm 无法从 TightVnc 查看器打开