package com.iflytek;
import javax.swing.JTextArea;
import com.iflytek.cloud.speech.RecognizerListener;
import com.iflytek.cloud.speech.SpeechConstant;
import com.iflytek.cloud.speech.SpeechRecognizer;
import com.iflytek.cloud.speech.SpeechUtility;
import com.iflytek.voicecloud.client.LfasrClient;
import com.iflytek.voicecloud.model.LfasrType;
import com.iflytek.voicecloud.model.Message;
import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;
public class Test2 {
public interface Test1 {
}
public static void main(String[] args) throws Exception {
//上传音频文件
//upload();
//获取转写文字结果
//您上传该音频文件获取的相应data,如"e2adac4c46334a52a9fd7fb1b4483b0d"
//result("");
//result("df79481df32644f185a93c29bc168da8");
//result("1801094108a04075b99cad1a2a3e54cd");
//result("961f3e36f6de41ccbf68b12e3e3efeea");
//result("726c9c53b9614257b4008ce141ccba37");
//result("a1557bb0392644c09fab3917826a9ffb");
//result("e205ce0563a44c21ab925c98fd53028c");
//result("df79481df32644f185a93c29bc168da8");
//result("df79481df32644f185a93c29bc168da8");
result("df79481df32644f185a93c29bc168da8");
}
public static void upload() throws Exception {
String appid =""; //您的appid,如"5848d773"
String secret_key =""; //您的secret_key,如"b849c87a8bc2c7ww68b6dfbddee6dc35"
LfasrType type = LfasrType.LFASR_STANDARD_RECORDED_AUDIO;
LfasrClient client = LfasrClient.InitClient(appid, secret_key, type);
//Message message = client.lfasr_upload("D:\\test\\record\\20170401_15162132161_1675953.wav"); //需要转写的音频文件的路径,如"E:\\20160716am-as-shenzhen-Alex.mp3"
// Message message1= client.lfasr_upload("D:\\test\\record\\20170401_13729129721_1675938.wav");
// Message message2= client.lfasr_upload("D:\\test\\record\\20170401_13734719472_1675816.wav");
// System.out.println(message);
// System.out.println(message1);
// System.out.println(message2);
// Message message= client.lfasr_upload("D:\\test\\record\\20170401_18796243844_1675991.wav");
// System.out.println(message);
}
public static void result(String taskid) throws Exception {
String appid =""; //您的appid,如"5848d773"
String secret_key =""; //您的secret_key,如"b849c87a8bc2c7ww68b6dfbddee6dc35"
LfasrType type = LfasrType.LFASR_STANDARD_RECORDED_AUDIO;
LfasrClient client = LfasrClient.InitClient(appid, secret_key, type);
Message message = client.lfasr_get_result(taskid);
System.out.println(message);
}
// public static SpeechRecognizer VoiceToWord(final JTextArea text) throws Exception {
// // 将“12345678”替换成您申请的APPID,申请地址:http://open.voicecloud.cn
// SpeechUtility.createUtility(SpeechConstant.APPID + "=58f6d001");
// // 1.创建SpeechRecognizer对象
// SpeechRecognizer mIat = SpeechRecognizer.createRecognizer();
// // 2.设置听写参数,详见《iFlytek MSC Reference Manual》SpeechConstant类
// mIat.setParameter(SpeechConstant.DOMAIN, "null");
// mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
// mIat.setParameter(SpeechConstant.ACCENT, "cantonese ");
// return mIat;
// }
}
- 1
- 2
- 3
前往页