您好,登錄后才能下訂單哦!
這篇文章主要介紹“小程序怎么實現(xiàn)科大訊飛接口”,在日常操作中,相信很多人在小程序怎么實現(xiàn)科大訊飛接口問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”小程序怎么實現(xiàn)科大訊飛接口”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
下面為java的訊飛語音接口開發(fā)了,直接貼代碼
package com.example.utils;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* Created by songzs on 2017/12/12.
* 封裝的轉(zhuǎn)碼工具類
*/
public class FFMPEGUtil {
public static String silk2Pcm(String inputfile,String outputfile){
List
commend.add("/usr/local/silk2pcm_tool/SILKCodec/SILK_SDK_SRC_ARM/./decoder");
commend.add(inputfile);
commend.add(outputfile);
StringBuffer test=new StringBuffer();
for(int i=0;i<commend.size();i++)< p="">
test.append(commend.get(i)+" ");
System.out.println("decoder命令:"+test+"");
exec(test);
return outputfile;
}
public static String pcm2Wav(String inputfile,String outputfile){
//ffmpeg -f s16le -ar 12k -ac 2 -i /path/to/pcm -f wav -ar 16k -ac 1 /path/to/wav
List
commend.add("ffmpeg");
commend.add("-f");
commend.add("s16le");
commend.add("-ar");
commend.add("12k");
commend.add("-ac");
commend.add("2");
commend.add("-i");
commend.add(inputfile);
commend.add("-f");
commend.add("wav");
commend.add("-ar");
commend.add("16k");
commend.add("-ac");
commend.add("1");
commend.add(outputfile);
StringBuffer test=new StringBuffer();
for(int i=0;i<commend.size();i++)< p="">
test.append(commend.get(i)+" ");
System.out.println("ffmpeg命令:"+test+"");
exec(test);
return outputfile;
}
public static String silk_remove_word(String filepath){
List
commend.add("/home/workspace/./test.sh");
commend.add(filepath);
StringBuffer test=new StringBuffer();
for(int i=0;i<commend.size();i++)< p="">
test.append(commend.get(i)+" ");
System.out.println("test命令:"+test+"");
exec(test);
return filepath;
}
private static void exec(StringBuffer test){
try {
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(test.toString());
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ( (line = br.readLine()) != null) ;
} catch (Exception e) {
e.printStackTrace();
}
}
}
到此,關(guān)于“小程序怎么實現(xiàn)科大訊飛接口”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。