Convert from PCM to WAV. Is it Possible?

前端 未结 3 1928
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-29 15:18

I have an application for iPAD. This application records the voice of the microphone. The audio formats of the item must be PCM, MP3 and WAV files. The MP3 file I get it sta

3条回答
  •  Happy的楠姐
    2020-12-29 15:31

    I was working on a system where it accepts only wav files, but the one I was receiving from amazon Polly was pcm, so finally did this and got my issue resolved. Hope it helps someone. This is an example of nodejs.

    
        // https://github.com/TooTallNate/node-wav
        const FileWriter = require('wav').FileWriter
        
        let audioStream = bufferToStream(res.AudioStream);
        var outputFileStream = new FileWriter(`${outputFileFolder}/wav/${outputFileName}.wav`, {
                                    sampleRate: 8000,
                                    channels: 1
                                });
        audioStream.pipe(outputFileStream);
        
        function bufferToStream(binary) {
            const readableInstanceStream = new Stream.Readable({
                read() {
                    this.push(binary);
                    this.push(null);
                }
            });
            return readableInstanceStream;
        }
    

提交回复
热议问题