我们有录音记录,两人在不同的频道上讲话。我正在尝试node.js 这里的正式文档。首先,我得到了一个错误,即有效载荷大小超过了最大限制。
ubuntu@ip-xxxx:~/nodejs-docs-samples/speech$ node recognize.js async /home/ubuntu/output.wav
(node:18306) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Request payload size exceeds the limit: 10485760 bytes.然而,文档只是提到了记录长度的限制,而不是文件大小的限制。这是链接
有什么解决办法吗?
此外,我尝试使用更小的文件大小并获得了配置错误:
ubuntu@ip-xxx:~/nodejs-docs-samples/speech$ node recognize.js async /home/ubuntu/output2.wav
(node:18291) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Invalid Configuration, Does not match Wav File Header.
Wav Header Contents:
Encoding: LINEAR16
Channels: 2
Sample Rate: 16000.
Request Contents:
Encoding: linear16
Channels: 1
Sample Rate: 16000.我不确定API是否允许使用2声道音频输入,因为我在文档中找不到任何这样的配置。但是,我发现了此链接,建议将音频分成单独的频道,并单独使用它们。以编程方式进行此操作的推荐方法是什么?
发布于 2017-02-09 18:16:05
我最终采取了这种方法
sox将文件拆分到通道下面是一个帮助函数,用于将文件拆分为通道
function splitFileToChannels (fileName) {
let output = {
channel1: `${fileName}_channel1.wav`,
channel2: `${fileName}_channel2.wav`
};
let channel1Command = `sox ${fileName} ${fileName}_channel1.wav remix 1`;
let channel2Command = `sox ${fileName} ${fileName}_channel2.wav remix 2`;
return Promise.all([
childProcess.execAsync(channel1Command),
childProcess.execAsync(channel2Command)
])
.then(() => {
return output;
});
}此外,我还必须先将mp3文件转换为wav格式,然后再分割到通道。
https://stackoverflow.com/questions/41996687
复制相似问题