没有离线语音识别

你正在使用的浏览器版本过低,将不能正常浏览和使用知乎。you have been blocked||||||||||||||||||
查看: 4932|回复: 3
在线时间207 小时经验值150 最后登录注册时间帖子阅读权限1UID934
头像被屏蔽
TA的每日心情郁闷 11:47签到天数: 1 天[LV.1]初来乍到
G币273 最后登录注册时间
提示: 作者被禁止或删除 内容自动屏蔽,只有管理员或有管理权限的成员可见
我想找一款离线语音翻译的软件,请问那个朋友能提供啊???最好可以安装词库在手机上的???
在线时间1639 小时经验值2388 最后登录注册时间帖子阅读权限100UID99830
TA的每日心情无聊 16:21签到天数: 6 天[LV.2]偶尔看看I
G币1033 最后登录注册时间
有离线语音词典。比如云词。至于离线翻译,不可能有
在线时间6 小时经验值5 最后登录注册时间帖子阅读权限10UID4693731
幼儿园, 积分 5, 距离下一级还需 10 积分
该用户从未签到
G币10 最后登录注册时间
以前用N73 那些诺基亚机子都有的,现在的都要在线翻译,呃钱噶
在线时间269 小时经验值1007 最后登录注册时间帖子阅读权限70UID1992071
学士, 积分 1007, 距离下一级还需 93 积分
TA的每日心情郁闷 09:31签到天数: 1 天[LV.1]初来乍到
G币3155 最后登录注册时间
离线的&&就这么 难找,& & 高手你们在哪啊,给个希望
浏览过的版块
Powered by基于科大讯飞的语音识别及合成声音(离线),代码简单适合像我一样的小白进行二次开发 - 开源中国社区
当前访客身份:游客 [
当前位置:
发布于 日 15时,
基于科大讯飞的语音识别及合成声音(离线),代码简单适合像我一样的小白进行二次开发。源码是从官网下载并提取出来的,适合配置在红米以上的安卓手机使用,程序依赖讯飞语音+.apk。所有源码及离线数据都打包好放在我个人网盘里:/s/1i31OESt
代码片段(6)
Iat_TtsDemo.java&~&7KB&&&&
package com.iflytek.
import android.annotation.SuppressL
import android.app.A
import android.content.SharedP
import android.os.B
import android.util.L
import android.view.V
import android.view.View.OnClickL
import android.view.W
import android.widget.EditT
import android.widget.T
import com.iflytek.cloud.ErrorC
import com.iflytek.cloud.InitL
import com.iflytek.cloud.RecognizerR
import com.iflytek.cloud.SpeechC
import com.iflytek.cloud.SpeechE
import com.iflytek.cloud.SpeechR
import com.iflytek.cloud.SpeechS
import com.iflytek.cloud.SynthesizerL
import com.iflytek.cloud.ui.RecognizerD
import com.iflytek.cloud.ui.RecognizerDialogL
import com.iflytek.speech.util.JsonP
import com.iflytek.sunflower.FlowerC
import com.iflytek.voicedemo.R;
public class Iat_TtsDemo extends Activity implements OnClickListener {
private static String TAG = "Iat_TtsDemo";
// 语音听写对象
private SpeechRecognizer mI
// 语音听写UI
private RecognizerDialog iatD
// 听写结果内容
private EditText mResultT
private SpeechSynthesizer mT
//缓冲进度
private int mPercentForBuffering = 0;
//播放进度
private int mPercentForPlaying = 0;
private Toast mT
private SharedPreferences mSharedP
@SuppressLint("ShowToast")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.ttsdemo);
initLayout();
// 初始化识别对象
mIat = SpeechRecognizer.createRecognizer(this, mInitListener);
// 初始化听写Dialog,如果只使用有UI听写功能,无需创建SpeechRecognizer
iatDialog = new RecognizerDialog(this,mInitListener);
// 初始化合成对象
mTts = SpeechSynthesizer.createSynthesizer(this, mTtsInitListener);
mSharedPreferences = getSharedPreferences("com.iflytek.setting", Activity.MODE_PRIVATE);
mToast = Toast.makeText(this,"",Toast.LENGTH_SHORT);
* 初始化Layout。
private void initLayout() {
findViewById(R.id.tts_play).setOnClickListener(this);
findViewById(R.id.iat_recognize).setOnClickListener(this);
mResultText = ((EditText)findViewById(R.id.tts_text));
public void onClick(View view) {
switch(view.getId()) {
case R.id.tts_play:
setParam(); // 开始合成
case R.id.iat_recognize:
mResultText.setText(null);// 清空显示内容
// 设置参数
Iat_setParam();
boolean isShowDialog = mSharedPreferences.getBoolean(getString(R.string.pref_key_iat_show), true);
if (isShowDialog) {
// 显示听写对话框
iatDialog.setListener(recognizerDialogListener);
iatDialog.show();
showTip(getString(R.string.text_begin));
* 初始化监听器。
private InitListener mInitListener = new InitListener() {
public void onInit(int code) {
Log.d(TAG, "SpeechRecognizer init() code = " + code);
if (code != ErrorCode.SUCCESS) {
showTip("初始化失败,错误码:"+code);
* 听写UI监听器
private RecognizerDialogListener recognizerDialogListener=new RecognizerDialogListener(){
public void onResult(RecognizerResult results, boolean isLast) {
String text = JsonParser.parseIatResult(results.getResultString());
mResultText.append(text);
mResultText.setSelection(mResultText.length());
setParam(); // 开始合成
//showTip("完成识别2");//稍后
public void onError(SpeechError arg0) {
private void showTip(final String str)
mToast.setText(str);
mToast.show();
* 参数设置
* @param param
public void Iat_setParam(){
// 清空参数
mIat.setParameter(SpeechConstant.PARAMS, null);
String lag = mSharedPreferences.getString("iat_language_preference", "mandarin");
if (lag.equals("en_us")) {
// 设置语言
mIat.setParameter(SpeechConstant.LANGUAGE, "en_us");
// 设置语言
mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
// 设置语言区域
mIat.setParameter(SpeechConstant.ACCENT,lag);
mIat.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL);
* 初期化监听。
private InitListener mTtsInitListener = new InitListener() {
public void onInit(int code) {
Log.d(TAG, "InitListener init() code = " + code);
if (code != ErrorCode.SUCCESS) {
showTip("初始化失败,错误码:"+code);
* 合成回调监听。
private SynthesizerListener mTtsListener = new SynthesizerListener() {
public void onBufferProgress(int percent, int beginPos, int endPos,
String info) {
mPercentForBuffering =
showTip(String.format(getString(R.string.tts_toast_format),
mPercentForBuffering, mPercentForPlaying));
public void onSpeakProgress(int percent, int beginPos, int endPos) {
mPercentForPlaying =
showTip(String.format(getString(R.string.tts_toast_format),
mPercentForBuffering, mPercentForPlaying));
public void onCompleted(SpeechError error) {
if(error == null)
showTip("播放完成");
else if(error != null)
showTip(error.getPlainDescription(true));
public void onEvent(int arg0, int arg1, int arg2, Bundle arg3) {
// TODO Auto-generated method stub
public void onSpeakBegin() {
// TODO Auto-generated method stub
public void onSpeakPaused() {
// TODO Auto-generated method stub
public void onSpeakResumed() {
// TODO Auto-generated method stub
* 参数设置
* @param param
private void setParam(){
//设置合成
mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL);
//设置发音人 voicer为空默认通过语音+界面指定发音人。
mTts.setParameter(SpeechConstant.VOICE_NAME,"");
//设置播放器音频流类型
mTts.setParameter(SpeechConstant.STREAM_TYPE,mSharedPreferences.getString("stream_preference", "1"));//0则为听筒
int code = mTts.startSpeaking(mResultText.getText().toString(), mTtsListener);
if (code != ErrorCode.SUCCESS) {
showTip("未安装离线包");
protected void onDestroy() {
super.onDestroy();
mTts.stopSpeaking();
// 退出时释放连接
mTts.destroy();
mIat.cancel();
mIat.destroy();
protected void onResume() {
//移动数据统计分析
FlowerCollector.onResume(this);
FlowerCollector.onPageStart("TtsDemo");
super.onResume();
protected void onPause() {
//移动数据统计分析
FlowerCollector.onPageEnd("TtsDemo");
FlowerCollector.onPause(this);
super.onPause();
SpeechApp.java&~&495B&&&&
package com.iflytek.
import android.app.A
import com.iflytek.cloud.SpeechU
import com.iflytek.voicedemo.R;
public class SpeechApp extends Application{
public void onCreate() {
// 应用程序入口处调用,避免手机内存过小,杀死后台进程,造成SpeechUtility对象为null
// 设置你申请的应用appid
SpeechUtility.createUtility(SpeechApp.this, "appid="+getString(R.string.app_id));
super.onCreate();
JsonParser.java&~&2KB&&&&
package com.iflytek.speech.
import org.json.JSONA
import org.json.JSONO
import org.json.JSONT
* Json结果解析类
public class JsonParser {
public static String parseIatResult(String json) {
StringBuffer ret = new StringBuffer();
JSONTokener tokener = new JSONTokener(json);
JSONObject joResult = new JSONObject(tokener);
JSONArray words = joResult.getJSONArray("ws");
for (int i = 0; i & words.length(); i++) {
// 转写结果词,默认使用第一个结果
JSONArray items = words.getJSONObject(i).getJSONArray("cw");
JSONObject obj = items.getJSONObject(0);
ret.append(obj.getString("w"));
如果需要多候选结果,解析数组其他字段
for(int j = 0; j & items.length(); j++)
JSONObject obj = items.getJSONObject(j);
ret.append(obj.getString("w"));
} catch (Exception e) {
e.printStackTrace();
return ret.toString();
public static String parseGrammarResult(String json) {
StringBuffer ret = new StringBuffer();
JSONTokener tokener = new JSONTokener(json);
JSONObject joResult = new JSONObject(tokener);
JSONArray words = joResult.getJSONArray("ws");
for (int i = 0; i & words.length(); i++) {
JSONArray items = words.getJSONObject(i).getJSONArray("cw");
for(int j = 0; j & items.length(); j++)
JSONObject obj = items.getJSONObject(j);
if(obj.getString("w").contains("nomatch"))
ret.append("没有匹配结果.");
return ret.toString();
ret.append("【结果】" + obj.getString("w"));
ret.append("【置信度】" + obj.getInt("sc"));
ret.append("\n");
} catch (Exception e) {
e.printStackTrace();
ret.append("没有匹配结果.");
return ret.toString();
Msc.jar&~&236KB&&&&
libmsc.zip&~&523KB&&&&
Sunflower.jar&~&53KB&&&&
开源中国-程序员在线工具:
相关的代码(1524)
希望加点说明
2楼:angle_小帅 发表于
引用来自“芝麻谷”的评论希望加点说明希望加点说明
3楼:krolser 发表于
希望加点说明,apk安装会出错
4楼:HCOoorange 发表于
请问语音识别的时间设置在哪啊?就是你多久没说话,语音识别就结束
5楼:翻云 发表于
R.string.tts_toast_format
在String下tts_toast_format具体是什么内容?
6楼:不为风雅 发表于
楼主,请问您的分享能识别整句话吗?4 5 6 为什么下载不了,讯飞的APK也是空白,下载不了
7楼:卢孙远 发表于
c语言版的http://git.oschina.net/LSU/ai_talk_photo
开源从代码分享开始
几困的其它代码

我要回帖

更多关于 离线语音合成 的文章

 

随机推荐