商城系統(tǒng) 注冊

小程序調(diào)用科大訊飛接口

2020-09-27|HiShop
導(dǎo)讀:小程序調(diào)用科大訊飛接口必須要確定你是否在訊飛開放平臺申請開通了語音識別功能。...

 小程序調(diào)用科大訊飛接口

 小程序調(diào)用科大訊飛接口必須要確定你是否在訊飛開放平臺申請開通了語音識別功能。

  下面為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 {

小程序調(diào)用科大訊飛接口

  public static String silk2Pcm(String inputfile,String outputfile){

  List commend = new ArrayList();

  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 = new ArrayList();

  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 = new ArrayList();

  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();

  }

  }

  }

電話咨詢 預(yù)約演示 0元開店