• 大小: 5.46MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-23
  • 语言: Java
  • 标签: java  讯飞  

资源简介

主要实现的是java平台的音频转文字,默认的是普通话,先上传到讯飞的服务器,得到data,再result读取data,之后再通过json解析,得到你需要的内容

资源截图

代码片段和文件信息

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(Speec

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1454  2017-04-27 09:31  ProjectTest\.classpath

     文件        387  2017-04-27 09:31  ProjectTest\.project

     文件       2453  2017-04-27 09:31  ProjectTest\bin\com\iflytek\JSonParser.class

     文件       2835  2017-04-27 09:31  ProjectTest\bin\com\iflytek\Test.class

     文件        171  2017-04-27 09:31  ProjectTest\bin\com\iflytek\Test2$Test1.class

     文件       1616  2017-04-27 09:31  ProjectTest\bin\com\iflytek\Test2.class

     文件        934  2017-04-27 09:31  ProjectTest\bin\com\iflytek\Test3.class

     文件       2775  2017-04-27 09:31  ProjectTest\bin\com\iflytek\Test4.class

     文件     409289  2017-04-27 09:31  ProjectTest\lib\fastjson-1.2.2.jar

     文件      34638  2017-04-27 09:31  ProjectTest\lib\json-jena-1.0.jar

     文件    2731714  2017-04-27 09:31  ProjectTest\lib\lfasr.jar

     文件    1230508  2017-04-27 09:31  ProjectTest\lib\libmsc32.so

     文件    1191031  2017-04-27 09:31  ProjectTest\lib\libmsc64.so

     文件     141499  2017-04-27 09:31  ProjectTest\lib\Msc.jar

     文件    1250816  2017-04-27 09:31  ProjectTest\lib\msc32.dll

     文件    1487872  2017-04-27 09:31  ProjectTest\lib\msc64.dll

     文件       3156  2017-04-27 09:31  ProjectTest\src\com\iflytek\Test2.java

     目录          0  2017-04-27 09:31  ProjectTest\bin\com\iflytek

     目录          0  2017-04-27 09:32  ProjectTest\src\com\iflytek

     目录          0  2017-04-27 09:31  ProjectTest\bin\com

     目录          0  2017-04-27 09:31  ProjectTest\src\com

     目录          0  2017-04-27 09:31  ProjectTest\.settings

     目录          0  2017-04-27 09:31  ProjectTest\bin

     目录          0  2017-04-27 09:31  ProjectTest\lib

     目录          0  2017-04-27 09:31  ProjectTest\src

     目录          0  2017-04-27 09:31  ProjectTest

----------- ---------  ---------- -----  ----

              8493148                    26


评论

共有 条评论