小程序調(diào)用科大訊飛接口
小程序調(diào)用科大訊飛接口必須要確定你是否在訊飛開(kāi)放平臺(tái)申請(qǐng)開(kāi)通了語(yǔ)音識(shí)別功能。
下面為java的訊飛語(yǔ)音接口開(kāi)發(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
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
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
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();
}
}
}
- 第 1 頁(yè)【語(yǔ)音小程序】小程序調(diào)用科大訊飛接口
- 第 2 頁(yè)【小程序調(diào)用科大訊飛接口】 小程序錄音文件上傳與訊飛語(yǔ)音識(shí)別
- 第 3 頁(yè)【小程序調(diào)用科大訊飛接口】 訊飛語(yǔ)音識(shí)別工具類