1、微信小程序录音,提交到服务器(此时音频格式为silk);
2、利用silk-v3-decoder(https://github.com/kn007/silk-v3-decoder), 把silk 转换成pcm格式 (silk/decoder /data/test.silk /data/1.pcm);
3、 用 ffmpeg 把 44100 采样率 单声道 16bts pcm 文件转 16000采样率 16bits 位深的单声道pcm文件
ffmpeg -y -f s16le -ac 1 -ar 44100 -i test44.pcm -acodec pcm_s16le -f s16le -ac 1 -ar 1600016k.pcm (获得pcm文件)
ffmpeg -y -f s16le -ar 24000 -ac 1 -i /data/1.pcm -f wav -ar 16000 -b:a 16 -ac 1 /data/1.wav (获得wav文件)
4、调用网络api 转换 pcm , 就能获取网络转换后的 文字
⑵ 基于webrtc以及nodejs的P2P实时视频demo
吐槽, 你的分类错了, 导致不能贴代码。
github:
priologic/easyrtc
webRTC/webRTC.io
自己开发推荐使用/easyrtc
只是玩玩 对于webRTC.io使用简单
npm install webrtc.io
Client
<video id="local" autoplay="autoplay"></video>
<video id="remote" autoplay="autoplay"></video>
<script src="/webrtc.io.js"></script>
<script>
// note: make sure hostname available to all connecting clients
// (ie. probably not `localhost`)
rtc.connect('ws://yourserveraddress:8001');
rtc.createStream({"video": true, "audio":false}, function(stream){
// get local stream for manipulation
rtc.attachStream(stream, 'local');
});
rtc.on('add remote stream', function(stream){
// show the remote video
rtc.attachStream(stream, 'remote');
});
// more rtc callbacks are available
</script>
Server
var webRTC = require('webrtc.io').listen(8001);
//then a bunch of callbacks are available