我测试了wav文件的DeepSpeech,它工作正常。当我尝试使用音频流,它不能识别一个单词时,我的深度语音就会出现问题。音频流是PCM48 The立体声,带符号的16位小端。我一直在尝试将流转换为其他格式,如sampleRate和频道,但都没有成功。我在nodejs上使用DeepSpeech
modelStream = englishModel.createStream();
let chunks = [];
stream.on('data', chunk => {
chunks.push(chunk);
}).on('close', () => {
const buffer = Buffer.concat(chunks);
let stream = new Duplex();
stream.push(buffer);
stream.push(null);
let audioStream = new MemoryStream();
stream.pipe(Sox({
global: {
'no-dither': true,
},
output: {
bits: 16,
rate: desiredSampleRate,
channels: 1,
encoding: 'signed-integer',
endian: 'little',
compression: 0.0,
type: 'raw'
}
})).
pipe(audioStream);
audioStream.on('finish', () => {
let audioBuffer = audioStream.toBuffer();
const audioLength = (audioBuffer.length / 2) * (1 / desiredSampleRate);
console.log('audio length', audioLength);
let result = englishModel.stt(audioBuffer);
console.log('result:', result);
});发布于 2021-03-18 22:44:09
您正在尝试将流提供给需要wav文件的方法...
请改用modelStream.feedAudioContent();。Check the example.
https://stackoverflow.com/questions/66664022
复制相似问题