欢迎来到258分享网,纯净的网络源码分享基地!

258资源分享网

全部作品
全部作品
网站源码
微信源码
素材特效
源码插件
视频教程
建站学院
热门搜索: 织梦  农业种植  农业  安全设置  官方
258资源分享 > 建站学院 > 微信开发 > 微信小程序 java服务端记

推荐下载

HTML5响应式自适应网咯设计

2020-05-12   浏览:738

高端HTML5响应式企业通用网

2020-05-06   浏览:520

html5响应式外贸网站英文版

2020-05-08   浏览:509

HTML5自适应律师工作室类网

2020-04-04   浏览:502

HTML5影视传媒文化公司类网

2020-05-12   浏览:497

微信小程序 java服务端记

发布时间:2020-11-16  

1、文件上传,使用springmvc一直不想,后来看到别人有一样的情况改成了serverlet就可以了

2、因为要进行语音识别成文字,上传的语音文件是silk格式,需要用到讯飞的语音识别所以必须转成wav,用到了kn007大神的这个工具https://github.com/kn007/silk-v3-decoder才搞定过程比较坎坷

3、还想把返回结果转换成语音文件给小程序进行播放,结果...........silk是有了,但是一直播放不了,因为小程序的silk似乎需要特定的参数格式才行,最后转了个war给前端,让它播放

4、期间使用ffmpeg进行各种格式转换,ffmpeg的参数设置也挺恶心的,下面留一个可用的例子

[java] view plain copy

 

    public static void convertAudio(String sourcePath,int sourceHZ,String targetPath,int targetHZ){  

        Properties props=System.getProperties(); //获得系统属性集      

        String osName = props.getProperty("os.name"); //操作系统名称  

        String command = null;  

        if(osName.contains("Windows")){  

//          ffmpeg -y -f s16le -ar 24000 -ac 1 -i "$1.pcm" -f wav -ar 16000 -b:a 16 -ac 1 "${1%.*}.$2"  

            command = "C:\\ffmpeg.exe -y -f s16le -ar "+sourceHZ+" -i "+sourcePath+" -f wav -ar "+targetHZ+" -b:a 8 -ac 1 "+targetPath;           

        }else{  

            command = "/usr/local/ffmpeg/bin/ffmpeg -y -f s16le -ar "+sourceHZ+" -ac 1 -i "+sourcePath+" -f wav -ar "+targetHZ+" -b:a 8 -ac 1 "+targetPath;  

        }  

        System.out.println("格式转换:"+command);  

        ShellExec.execShell(command);  

    }  

      

    public static void pcmToSilk(String pcmPath,String silkPath) throws InterruptedException{  

        //首先 pcm转换成8000的wav,然后wav转成silk  

//      ShellExec.convertAudio(pcmPath, 16000, pcmPath+".wav", 16000);  

//      Thread.sleep(1000);  

//      ShellExec.convertAudio(pcmPath+".wav", 16000, silkPath, 8000);  

          

  

        ShellExec.convertAudio(pcmPath, 16000, silkPath, 8000);  

    }  

      

    public static void pcmToWav(String pcmPath,String wavPath){  

        Properties props=System.getProperties(); //获得系统属性集      

        String osName = props.getProperty("os.name"); //操作系统名称  

        String command = null;  

        if(osName.contains("Windows")){  

            command = "C:\\ffmpeg.exe -f s16le -ar 16000 -i "+pcmPath+" -f wav -ar 16000 -b:a 8 -ac 1 "+wavPath;              

        }else{  

本文标签

:备案管家服务帮您把复杂流程变简单,解决您在进行网站备案过程中遇到的效率低下和成功率不高的问题。个人300/2个域名,企业500/5个域名,qq1650004.