package com.iflytek.aitalk;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.iflytek.business.speech.SpeechError;
import com.iflytek.speech.engines.processor.aitalk.recognizer.abstracts.AitalkContent;
import com.iflytek.speech.engines.processor.aitalk.recognizer.abstracts.IAitalkListener;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
public class Aitalk5 {
private static final String APPDATA = "/data/data/";
private static final String DESCFILES = "resource";
private static final String DEVIDER = "/";
public static final int MAX_RESULT_COUNT = 3;
public static final int MSG_COMMITNETWORK = 1544;
public static final int MSG_COPYGRMRES = 1543;
public static final int MSG_DESTROYWAITING = 1539;
public static final int MSG_DIALOG_CLOSE = 2305;
public static final int MSG_END_BY_USER = 1042;
public static final int MSG_ENGINE_STATE = 1541;
public static final int MSG_GRMDESTROYWAITING = 1540;
public static final int MSG_GRMNETWORKBUILT = 1542;
public static final int MSG_HAVE_RESULT = 1280;
public static final int MSG_RESPONSE_TIMEOUT = 1040;
public static final int MSG_SPEECH_END = 1026;
public static final int MSG_SPEECH_FLUSH_END = 1027;
public static final int MSG_SPEECH_NO_DETECT = 1039;
public static final int MSG_SPEECH_START = 1025;
public static final int MSG_SPEECH_TIMEOUT = 1041;
public static final int MSG_START_RECORD = 784;
public static final int MSG_STOP_RECORD = 785;
public static final int PARAM_AUDIODISCARD = 5;
public static final int PARAM_DENOSIE = 11;
public static final int PARAM_ES_INPUT = 15;
public static final int PARAM_ES_PITCH = 16;
public static final int PARAM_ES_SAMPLERATE = 101;
public static final int PARAM_GS = 10;
public static final int PARAM_RESPONSETIMEOUT = 2;
public static final int PARAM_SENSITIVITY = 1;
public static final int PARAM_SPEECHNOTIFY = 4;
public static final int PARAM_SPEECHTIMEOUT = 3;
public static final int PARAM_VAD_ENABLE = 103;
private static final int REFUSE_CONFIDENCE = 0;
private static final String[] RESOURCES_V2 = {"grm.mp3", "normModel.mp3", "ivCMNParam.mp3", "ivVadModels.mp3", "ivCMScore_8K.mp3", "ivDTree_8K.mp3", "ivDTree_16K.mp3", "ivFiller_8K.mp3", "ivHmmRes_8K.mp3", "ivHmmRes_16K.mp3", "ivModel_8K.mp3", "ivModel_16K.mp3", "ivTMRes_8K.mp3", "ivTMRes_16K.mp3", "sms_8K.mp3", "sms_16K.mp3", "poi_16K.mp3"};
public static final int SAMPLERATE_16K = 16000;
public static final int SAMPLERATE_8K = 8000;
private static final String SERVICE_DIR = "speechservice";
private static final int SPEECH_OUT_TIME = 20000;
private static final String SRCFILES = "aitalk5";
private static final String TAG = "SPEECH_Aitalk5";
private static final int TIMEOUT_WAIT_LOCK = 40000;
private static final int TIMEOUT_WAIT_QUEUE = 2000;
public static final int VALUE_ES_INPUT_FEATURE = 1;
public static final int VALUE_ES_INPUT_WAV = 0;
public static final int VALUE_GS_OFF = 1;
public static final int VALUE_GS_ON = 1;
private static final int WAIT_OUT_TIME = 4000;
private static final ReentrantLock asrRunLock = new ReentrantLock();
private static AitalkStatus mAitalkStatus = AitalkStatus.Idle;
private static IAitalkListener mCallback = null;
private static String mClient;
/* access modifiers changed from: private */
public static int mErrorCode = 0;
private static String mGrammarPath;
private static boolean mIsJniLoaded;
private static Handler mMsgHandler = new Handler(Looper.getMainLooper()) {
public void handleMessage(Message msg) {
switch (msg.what) {
case Aitalk5.MSG_START_RECORD /*784*/:
Log.i(Aitalk5.TAG, "MSG_START_RECORD");
return;
case Aitalk5.MSG_STOP_RECORD /*785*/:
Log.i(Aitalk5.TAG, "MSG_STOP_RECORD");
return;
case Aitalk5.MSG_SPEECH_START /*1025*/:
Log.i(Aitalk5.TAG, "MSG_SPEECH_START");
return;
case Aitalk5.MSG_SPEECH_END /*1026*/:
Log.i(Aitalk5.TAG, "MSG_SPEECH_END");
return;
case Aitalk5.MSG_SPEECH_FLUSH_END /*1027*/:
Log.i(Aitalk5.TAG, "MSG_SPEECH_FLUSH_END");
return;
case Aitalk5.MSG_SPEECH_NO_DETECT /*1039*/:
Log.i(Aitalk5.TAG, "MSG_SPEECH_NO_DETECT");
return;
case Aitalk5.MSG_RESPONSE_TIMEOUT /*1040*/:
Log.i(Aitalk5.TAG, "MSG_RESPONSE_TIMEOUT");
Aitalk5.errorCallback(SpeechError.ERROR_RESPONSE_TIMEOUT);
return;
case Aitalk5.MSG_SPEECH_TIMEOUT /*1041*/:
Log.i(Aitalk5.TAG, "MSG_SPEECH_TIMEOUT");
Aitalk5.errorCallback(SpeechError.ERROR_SPEECH_TIMEOUT);
return;
case Aitalk5.MSG_END_BY_USER /*1042*/:
Log.i(Aitalk5.TAG, "MSG_END_BY_USER");
return;
case Aitalk5.MSG_HAVE_RESULT /*1280*/:
Log.i(Aitalk5.TAG, "MSG_HAVE_RESULT FROM MSGHANDER");
Aitalk5.resultCallback();
return;
case Aitalk5.MSG_ENGINE_STATE /*1541*/:
int state = Aitalk5.JniGetEngineState();
Log.i(Aitalk5.TAG, "MSG_ENGINE_STATE state=" + state);
if (state == 0 || 29 == state || 31 == state) {
Log.i(Aitalk5.TAG, "MSG_ENGINE_STATE Start OK");
return;
} else if (state == 30 || state == 32) {
Log.i(Aitalk5.TAG, "MSG_ENGINE_STATE Stop OK");
return;
} else {
Log.e(Aitalk5.TAG, "MSG_ENGINE_STATE error,will stop." + state);
Aitalk5.mErrorCode = state;
Aitalk5.stop();
Aitalk5.errorCallback(state);
return;
}
case Aitalk5.MSG_COMMITNETWORK /*1544*/:
Log.i(Aitalk5.TAG, "MSG_COMMITNETWORK");
return;
default:
Log.i(Aitalk5.TAG, "unkown message: " + msg.what);
return;
}
}
};
private static String[] mReources = RESOURCES_V2;
private static final List<AitalkContent> mResult = new ArrayList();
private static int mSampleRate;
private static String mScene;
private enum AitalkStatus {
Idle,
Ready,
Running
}
private static native int JniAddLexiconItem(String str, String str2, int i);
private static native int JniAppendData(byte[] bArr, int i);
private static native int JniBuildGrammar(byte[] bArr, int i);
private static native int JniCreate(String str, FileDescriptor fileDescriptor, long[] jArr);
private static native int JniCreateLexicon(String str);
private static native int JniDeleteLexiconItem(String str, String str2);
private static native int JniDestroy();
private static native int JniEndData();
private static native int JniEndLexicon(String str);
private static native int JniExit();
private static native int JniGetConfidence(int i);
/* access modifiers chang
没有合适的资源?快使用搜索试试~ 我知道了~
一个安卓免费离线tts语音合成dome
共93个文件
java:31个
mp3:19个
xml:13个
需积分: 3 1 下载量 169 浏览量
2024-04-15
14:43:31
上传
评论
收藏 24.08MB ZIP 举报
温馨提示
该案例已经写成了单例模式;支持语音有:中英文普通话 嘉嘉 女 、普通话 楠楠 女童、普通话 晓锋 男、河南话 小坤 男、台湾话 晓琳 女、粤语 晓美 女、东北话 小倩 女、湖南话 小强 男、普通话 晓蓉 女、普通话 晓燕 女
资源推荐
资源详情
资源评论
收起资源包目录
TTS_Android.zip (93个子文件)
TTS_Android
gradle.properties 1KB
gradle
wrapper
gradle-wrapper.jar 58KB
gradle-wrapper.properties 205B
app
src
androidTest
java
com
example
tts_android
ExampleInstrumentedTest.java 757B
test
java
com
example
tts_android
ExampleUnitTest.java 381B
main
java
tts
TTSManager.java 2KB
com
example
tts_android
MainActivity.java 424B
res
mipmap-xxhdpi
ic_launcher_round.webp 6KB
ic_launcher.webp 3KB
mipmap-hdpi
ic_launcher_round.webp 3KB
ic_launcher.webp 1KB
drawable-v24
ic_launcher_foreground.xml 2KB
mipmap-anydpi-v26
ic_launcher.xml 343B
ic_launcher_round.xml 343B
values-night
themes.xml 331B
mipmap-mdpi
ic_launcher_round.webp 2KB
ic_launcher.webp 982B
mipmap-xxxhdpi
ic_launcher_round.webp 8KB
ic_launcher.webp 4KB
mipmap-xhdpi
ic_launcher_round.webp 4KB
ic_launcher.webp 2KB
xml
data_extraction_rules.xml 551B
backup_rules.xml 478B
values
colors.xml 147B
strings.xml 73B
themes.xml 405B
layout
activity_main.xml 778B
drawable
ic_launcher_background.xml 5KB
AndroidManifest.xml 960B
proguard-rules.pro 750B
libs
build.gradle 1KB
.gitignore 6B
gradlew.bat 3KB
build.gradle 1KB
settings.gradle 65B
gradlew 6KB
tts
src
androidTest
java
com
iflytek
ExampleInstrumentedTest.java 766B
test
java
com
iflytek
ExampleUnitTest.java 401B
main
assets
aitalk5
ivDTree_16K.mp3 96KB
ivTMRes_16K.mp3 10.03MB
ivCMNParam.mp3 88B
ivVadModels.mp3 4KB
normModel.mp3 5KB
grammar
grammar_main.bnf 669B
xiaomi.bnf 937B
grm.mp3 1019KB
ivModel_16K.mp3 4.88MB
ivHmmRes_16K.mp3 822KB
aisound
xiaofeng.mp3 1.34MB
xiaokun.mp3 1.03MB
xiaoqiang.mp3 1.04MB
xiaoqian.mp3 1.18MB
xiaorong.mp3 943KB
common.mp3 4.09MB
nannan.mp3 1.39MB
xiaomei.mp3 1.74MB
xiaoyan.mp3 2.35MB
xiaolin.mp3 1.89MB
jiajia.mp3 1.87MB
ivp
ivp_Hmm.irf 102KB
ivp_UBM.irf 45KB
ivw
ivModel_Multi.jet 27KB
java
com
cczhr
TTSConstants.java 1KB
TTS.java 6KB
iflytek
business
speech
SpeechIntent.java 4KB
SpeechError.java 5KB
SpeechConfig.java 4KB
speech
engines
processor
aitalk
recognizer
abstracts
AitalkAccessor.java 1KB
Slot.java 2KB
AitalkContent.java 2KB
IAitalkListener.java 217B
result
AitalkResult.java 307B
aisound
Aisound.java 3KB
aitalk
Aitalk5.java 26KB
logagent
LogAgent.java 3KB
msc
util
FileUtil.java 902B
speechcloud
SynthesizerPlayerListener.java 376B
SynthesizerListener.java 348B
LogConstants.java 2KB
TtsService.java 5KB
tts
interfaces
IAisoundJniListener.java 142B
IAisoundListener.java 186B
filelog
TtsFileLog.java 4KB
impl
TtsResource.java 7KB
AisoundEngine.java 5KB
binder
impl
LocalTtsPlayer.java 2KB
AiConstants.java 1KB
AndroidManifest.xml 151B
proguard-rules.pro 770B
build.gradle 1KB
consumer-rules.pro 0B
.gitignore 6B
.gitignore 225B
共 93 条
- 1
资源评论
来之梦
- 粉丝: 387
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 面向初学者的 Java 教程(包含 500 个代码示例).zip
- 阿里云OSS Java版SDK.zip
- 阿里云api网关请求签名示例(java实现).zip
- 通过示例学习 Android 的 RxJava.zip
- 通过多线程编程在 Java 中发现并发模式和特性 线程、锁、原子等等 .zip
- 通过在终端中进行探索来学习 JavaScript .zip
- 通过不仅针对初学者而且针对 JavaScript 爱好者(无论他们的专业水平如何)设计的编码挑战,自然而自信地拥抱 JavaScript .zip
- 适用于 Kotlin 和 Java 的现代 JSON 库 .zip
- AppPay-安卓开发资源
- yolo5实战-yolo资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功