首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >音频和DeepSpeech

音频和DeepSpeech
EN

Stack Overflow用户
提问于 2021-03-17 06:01:36
回答 1查看 301关注 0票数 0

我测试了wav文件的DeepSpeech,它工作正常。当我尝试使用音频流,它不能识别一个单词时,我的深度语音就会出现问题。音频流是PCM48 The立体声,带符号的16位小端。我一直在尝试将流转换为其他格式,如sampleRate和频道,但都没有成功。我在nodejs上使用DeepSpeech

代码语言:javascript
运行
复制
 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);
        });
EN

回答 1

Stack Overflow用户

发布于 2021-03-18 22:44:09

您正在尝试将流提供给需要wav文件的方法...

请改用modelStream.feedAudioContent();Check the example.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66664022

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档