1.讯飞官网提供更完整的Demo
2.我的Demo删掉了除语音识别外其余的部分,方便快速上手
3.整个项目在附件中
4.使用了lambda表达式,需要java8才能运行
5.代码如下:
package com.iflytek; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import com.iflytek.cloud.speech.RecognizerListener; import com.iflytek.cloud.speech.RecognizerResult; import com.iflytek.cloud.speech.SpeechConstant; import com.iflytek.cloud.speech.SpeechError; import com.iflytek.cloud.speech.SpeechRecognizer; import com.iflytek.cloud.speech.SpeechUtility; public class MyFrame extends JFrame { private static final long serialVersionUID = 1L; JPanel panelNorth, panelSouth; JTextArea textArea; JButton button_start, button_stop; private SpeechRecognizer mIat; public static void main(String[] args) { new MyFrame(); } public MyFrame() { initIfly(); Container con = this.getContentPane(); con.setLayout(new BorderLayout()); this.setSize(500, 300); this.setLocationRelativeTo(null); this.setResizable(true); this.setDefaultCloseOperation(3); this.setLayout(new BorderLayout()); setFrame(); this.add(panelSouth, BorderLayout.SOUTH); this.add(panelNorth, BorderLayout.NORTH); setVisible(true); } public void initIfly() { mIat = SpeechRecognizer.createRecognizer(); SpeechUtility.createUtility("appid=这里填写你的appid"); // 例如SpeechUtility.createUtility("appid=12345678"); } public void setFrame() { panelNorth = new JPanel(); panelSouth = new JPanel(); textArea = new JTextArea(30, 30); button_start = new JButton("开始"); button_start.addActionListener(e -> { setting(); textArea.setText(""); if (!mIat.isListening()) mIat.startListening(recognizerListener); else mIat.stopListening(); }); button_stop = new JButton("停止"); button_stop.addActionListener(e -> { mIat.stopListening(); iatSpeechInitUI(); }); panelNorth.add(textArea); panelSouth.add(button_start); panelSouth.add(button_stop); } void setting()// 属性设置 { final String engType = "cloud"; mIat.setParameter(SpeechConstant.ENGINE_TYPE, "cloud"); mIat.setParameter(SpeechConstant.SAMPLE_RATE, "16000");// mIat.setParameter(SpeechConstant.NET_TIMEOUT, "20000"); mIat.setParameter(SpeechConstant.KEY_SPEECH_TIMEOUT, "60000"); mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");// 语言en_us(英语) // zh_cn(中文) mIat.setParameter(SpeechConstant.ACCENT, "mandarin"); mIat.setParameter(SpeechConstant.DOMAIN, "iat"); mIat.setParameter(SpeechConstant.VAD_BOS, "5000"); mIat.setParameter(SpeechConstant.VAD_EOS, "1800"); mIat.setParameter(SpeechConstant.ASR_NBEST, "1"); mIat.setParameter(SpeechConstant.ASR_WBEST, "1"); mIat.setParameter(SpeechConstant.ASR_PTT, "0");// 标点符号 0(关) 1(开) mIat.setParameter(SpeechConstant.RESULT_TYPE, "plain"); // 返回数据格式 // plain或者jason mIat.setParameter(SpeechConstant.ASR_AUDIO_PATH, null); } private RecognizerListener recognizerListener = new RecognizerListener() { @Override public void onBeginOfSpeech() { button_start.setText("听写中..."); button_start.setEnabled(false); } @Override public void onEndOfSpeech() {} /** * 获取听写结果. 获取RecognizerResult类型的识别结果,并对结果进行累加,显示到Area里 */ @Override public void onResult(RecognizerResult results, boolean islast) { String text = results.getResultString(); textArea.append(text); text = textArea.getText(); if (islast) { iatSpeechInitUI(); } } @Override public void onVolumeChanged(int volume) {} @Override public void onError(SpeechError error) { if (null != error) { textArea.setText(error.getErrorDescription(true)); iatSpeechInitUI(); } } @Override public void onEvent(int eventType, int arg1, int agr2, String msg) {} }; public void iatSpeechInitUI() { button_start.setEnabled(true); button_start.setText("开始听写"); } }
相关推荐
详情见:Android 讯飞离线语音听写/离线语音识别SDK
科大讯飞的语音识别SDK的java版本。简单好用,使用时请到http://open.voicecloud.cn/上注册一下,过程也很简单。让你的程序能够实现语音识别。
录音后调用讯飞SDK进行解释处文本,源码.
讯飞支持的语言里面没有python,本实例参考《Linux下 python调用讯飞离线语音合成(tts)》基础上,实现了基于Python3.7的调用C语言封装的函数来间接的使用离线语音识别功能实例。
unity + 讯飞语音识别插件 webgl版本
本Demo集成了讯飞的语音听写SDK,可以高精度在线识别语音
unity讯飞SDK语音识别demo(windows平台),工程中导入自己SDK中的msc,脚本中只需要把appid改成自己的就行,不会的可以看我的博客
C#讯飞语音识别代码,讯飞语音识别,讯飞C#语音sdk,C#语音识别
语音识别开发实例demo,可以前往语音识别服务相关下载页面( http://yuyin.baidu.com/asr/download )下载开发所需的 SDK 及开发文档到本地进行集成开发。
unity写的讯飞语音识别合成与评测功能,走的是webapi,连接讯飞WebSocket服务器没有接入任何sdk,也没有多余插件,开发工具unity2019.3.6 ,真正实现了跨平台,不用在每个平台重新接入sdk这么麻烦了!
讯飞语音开放平台,开放Java源代码,语音合成与语音识别技术。
freeswitch对接讯飞语音识别模块
C#讯飞语音合成SDK-WINDOWS包C#讯飞语音合成SDK-WINDOWS包C#讯飞语音合成SDK-WINDOWS包
本工程实现的功能是根据已有的音频文件,利用讯飞的语音听写SDK,用C#实现windows平台的语音听写,实现将音频转换为文字
资源中含有使用Unity做的 讯飞语音识别+唤醒的整套Demo 使用Unity接入的讯飞语音SDK 包中含有Unity的工程、AndroidStudio的工程和成品apk
Android实战——科大讯飞语音听写SDK的使用,实现语音识别功能
JAVA语音识别,你可以利用此JAR包调用科大讯飞的语音引擎,前提是你注册一下科大讯飞的开发者
讯飞 linux 语音识别sdk