Git Product home page Git Product logo

Comments (9)

xiangyuecn avatar xiangyuecn commented on July 1, 2024

自行检查音频内容是否是16位pcm,把base64保存起来,解码成二进制文件

拖进页面播放测试,8位 16位参数都试试
https://xiangyuecn.gitee.io/recorder/assets/工具-裸PCM转WAV播放测试.html

from recorder.

xiaoxiaoqian1217 avatar xiaoxiaoqian1217 commented on July 1, 2024

自行检查音频内容是否是16位pcm,把base64保存起来,解码成二进制文件

拖进页面播放测试,8位 16位参数都试试 https://xiangyuecn.gitee.io/recorder/assets/工具-裸PCM转WAV播放测试.html

感谢感谢,按照你说的解码成了二进制文件,拖进页面播放可以朗读出文字,之前是完全朗读不出来, 下面是我保存成文件测试的代码

function saveBase64AsFile(base64Str, fileName) {
        const byteChars = atob(base64Str);
        const byteNums = new Array(byteChars.length);
        for (let i = 0; i < byteChars.length; i++) {
            byteNums[i] = byteChars.charCodeAt(i);
        }
        const byteArray = new Uint8Array(byteNums);
        const file = new File([byteArray], fileName, { type: 'audio/octet-stream' });
        // 保存文件
        saveFile(file);
    }

image
看起来测试是成功的, 不知道是我代码哪里写的有问题

from recorder.

xiangyuecn avatar xiangyuecn commented on July 1, 2024

不支持双声道,简单点把 每4个字节 去掉后两个字节 转成单声道

from recorder.

xiaoxiaoqian1217 avatar xiaoxiaoqian1217 commented on July 1, 2024

不支持双声道,简单点把 每4个字节 去掉后两个字节 转成单声道

怎么转呀,这个是要算法同事转成单身道还是我们自己转,可以简单给下思路吗

from recorder.

xiangyuecn avatar xiangyuecn commented on July 1, 2024

1 1 2 2 1 1 2 2 1 1 2 2
每4个字节,只取前两个字节1 1,后两个字节2 2丢掉

from recorder.

xiaoxiaoqian1217 avatar xiaoxiaoqian1217 commented on July 1, 2024

1 1 2 2 1 1 2 2 1 1 2 2 每4个字节,只取前两个字节1 1,后两个字节2 2丢掉

方便提供下相关JS代码实现dem吗

from recorder.

xiangyuecn avatar xiangyuecn commented on July 1, 2024

https://xiangyuecn.gitee.io/recorder/assets/工具-裸PCM转WAV播放测试.html

这个页面源码里面有

from recorder.

xiaoxiaoqian1217 avatar xiaoxiaoqian1217 commented on July 1, 2024

image

我把采样率改成了44100 ,16bitRate单声道,没有杂音,但是语速特别块,比之前 16000, 16bitRate 双声道 清晰很多,且没有杂音, 不知道能不能调整朗读的语速

from recorder.

xiaoxiaoqian1217 avatar xiaoxiaoqian1217 commented on July 1, 2024

来反馈了,最后找到问题所在了, 算法同事给我返回的base64数据编码的pcm是浮点型的数据, 但是库中使用的是Int16Array操作的pcm,导致播放的音频有电流声, 不知道博主能不能考虑下支持浮点型。

from recorder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.