网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序 java服務端記

發布時間:2018-04-21 10:18 所屬欄目:小程序開發教程

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
 
  1.     public static void convertAudio(String sourcePath,int sourceHZ,String targetPath,int targetHZ){  
  2.         Properties props=System.getProperties(); //獲得系統屬性集      
  3.         String osName = props.getProperty("os.name"); //操作系統名稱  
  4.         String command = null;  
  5.         if(osName.contains("Windows")){  
  6. //          ffmpeg -y -f s16le -ar 24000 -ac 1 -i "$1.pcm" -f wav -ar 16000 -b:a 16 -ac 1 "${1%.*}.$2"  
  7.             command = "C:\\ffmpeg.exe -y -f s16le -ar "+sourceHZ+" -i "+sourcePath+" -f wav -ar "+targetHZ+" -b:a 8 -ac 1 "+targetPath;           
  8.         }else{  
  9.             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;  
  10.         }  
  11.         System.out.println("格式轉換:"+command);  
  12.         ShellExec.execShell(command);  
  13.     }  
  14.       
  15.     public static void pcmToSilk(String pcmPath,String silkPath) throws InterruptedException{  
  16.         //首先 pcm轉換成8000的wav,然后wav轉成silk  
  17. //      ShellExec.convertAudio(pcmPath, 16000, pcmPath+".wav", 16000);  
  18. //      Thread.sleep(1000);  
  19. //      ShellExec.convertAudio(pcmPath+".wav", 16000, silkPath, 8000);  
  20.           
  21.   
  22.         ShellExec.convertAudio(pcmPath, 16000, silkPath, 8000);  
  23.     }  
  24.       
  25.     public static void pcmToWav(String pcmPath,String wavPath){  
  26.         Properties props=System.getProperties(); //獲得系統屬性集      
  27.         String osName = props.getProperty("os.name"); //操作系統名稱  
  28.         String command = null;  
  29.         if(osName.contains("Windows")){  
  30.             command = "C:\\ffmpeg.exe -f s16le -ar 16000 -i "+pcmPath+" -f wav -ar 16000 -b:a 8 -ac 1 "+wavPath;              
  31.         }else{  
  32.             command = "/usr/local/ffmpeg/bin/ffmpeg -f s16le -ar 16000 -i "+pcmPath+" -f wav -ar 16000 -b:a 16 -ac 1 "+wavPath;  
  33.         }  
  34.         System.out.println("格式轉換:"+command);  
  35.         ShellExec.execShell(command);  
  36.     }  
  37.       
  38.     public static void silkToWav(String silkPath,String wavPath){  
  39.         Properties props=System.getProperties(); //獲得系統屬性集      
  40.         String osName = props.getProperty("os.name"); //操作系統名稱  
  41.         String command = null;  
  42.         if(osName.contains("Windows")){  
  43. //          ffmpeg -y -f s16le -ar 24000 -ac 1 -i "$1.pcm" -f wav -ar 16000 -b:a 16 -ac 1 "${1%.*}.$2"  
  44.             command = "C:\\ffmpeg.exe -y -f s16le -ar 8000 -ac 1 -i "+silkPath+" -f wav -ar 16000 -b:a 16 -ac 1 "+wavPath;            
  45.         }else{  
  46.             command = "/usr/local/ffmpeg/bin/ffmpeg -y -f s16le -ar 8000 -ac 1 -i "+silkPath+" -f wav -ar 16000 -b:a 16 -ac 1 "+wavPath;  
  47.         }  
  48.         System.out.println("格式轉換:"+command);  
  49.         ShellExec.execShell(command);  
  50.       
  51.     }  


易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23877.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×