# Conflicts:
#	src/MyApplication/.idea/vcs.xml
#	src/MyApplication/app/build.gradle
#	src/MyApplication/app/src/MyApplication/app/src/main/java/com/example/myapplication/WNaviGuideActivity.java
#	src/MyApplication/app/src/MyApplication/app/src/main/java/com/example/myapplication/yuyin.java
#	src/MyApplication/app/src/MyApplication/app/src/main/res/layout/activity_itemfound.xml
#	src/MyApplication/app/src/MyApplication/app/src/main/res/layout/activity_yuyin.xml
#	src/MyApplication/app/src/MyApplication/app/src/main/res/layout/activity_zhaoxun.xml
master
伍洲行 2 years ago
commit 858e6ee843

@ -1 +1,2 @@
111
111
develop

@ -15,7 +15,7 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// SOso
// SOso
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
}
}

@ -44,20 +44,20 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
private static final String TAG = "MainActivity";
private SpeechRecognizer mIat;// 语音听写对象
private RecognizerDialog mIatDialog;// 语音听写UI
private SpeechRecognizer mIat;// 语音听写对象
private RecognizerDialog mIatDialog;// 语音听写UI
// 用HashMap存储听写结果
// 用HashMap存储听写结果
private HashMap<String, String> mIatResults = new LinkedHashMap<String, String>();
private SharedPreferences mSharedPreferences;//缓存
private SharedPreferences mSharedPreferences;//缓存
private String mEngineType = SpeechConstant.TYPE_CLOUD;// 引擎类型
private String language = "zh_cn";//识别语言
private String mEngineType = SpeechConstant.TYPE_CLOUD;// 引擎类型
private String language = "zh_cn";//识别语言
private TextView tvResult;//识别结果
private Button btnStart;//开始识别
private String resultType = "json";//结果内容数据格式
private TextView tvResult;//识别结果
private Button btnStart;//开始识别
private String resultType = "json";//结果内容数据格式
private Button go;
private TextView tvResult1;
@ -71,12 +71,12 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
btnStart.setOnClickListener(this);
tvResult1=findViewById(R.id.tv_result1);
initPermission();//权限请求
initPermission();//权限请求
// 使用SpeechRecognizer对象可根据回调消息自定义界面
// 使用SpeechRecognizer对象可根据回调消息自定义界面
mIat = SpeechRecognizer.createRecognizer(yuyin.this, mInitListener);
// 使用UI听写功能请根据sdk文件目录下的notice.txt,放置布局文件和图片资源
// 使用UI听写功能请根据sdk文件目录下的notice.txt,放置布局文件和图片资源
mIatDialog = new RecognizerDialog(yuyin.this, mInitListener);
mSharedPreferences = getSharedPreferences("ASR",
Activity.MODE_PRIVATE);
@ -85,20 +85,20 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
@Override
public void onClick(View v) {
if( null == mIat ){
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
showMsg( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
showMsg( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
return;
}
mIatResults.clear();//清除数据
setParam(); // 设置参数
mIatDialog.setListener(mRecognizerDialogListener);//设置监听
mIatDialog.show();// 显示对话框
mIatResults.clear();//清除数据
setParam(); // 设置参数
mIatDialog.setListener(mRecognizerDialogListener);//设置监听
mIatDialog.show();// 显示对话框
}
/**
*
*
*/
private InitListener mInitListener = new InitListener() {
@ -106,25 +106,25 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
public void onInit(int code) {
Log.d(TAG, "SpeechRecognizer init() code = " + code);
if (code != ErrorCode.SUCCESS) {
showMsg("初始化失败,错误码:" + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
showMsg("初始化失败,错误码:" + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
}
}
};
/**
* UI
* UI
*/
private RecognizerDialogListener mRecognizerDialogListener = new RecognizerDialogListener() {
public void onResult(RecognizerResult results, boolean isLast) {
printResult(results);//结果数据解析
printResult(results);//结果数据解析
printButton(results);
}
/**
* .
* .
*/
public void onError(SpeechError error) {
showMsg(error.getPlainDescription(true));
@ -133,7 +133,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
};
/**
*
*
*
* @param results
*/
@ -141,7 +141,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
String text = JsonParser.parseIatResult(results.getResultString());
String sn = null;
// 读取json结果中的sn字段
// 读取json结果中的sn字段
try {
JSONObject resultJson = new JSONObject(results.getResultString());
sn = resultJson.optString("sn");
@ -156,14 +156,14 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
resultBuffer.append(mIatResults.get(key));
}
tvResult.setText(resultBuffer.toString());//听写结果显示
tvResult.setText(resultBuffer.toString());//听写结果显示
}
private void printButton(RecognizerResult results) {
String text = JsonParser.parseIatResult(results.getResultString());
String sn = null;
// 读取json结果中的sn字段
// 读取json结果中的sn字段
try {
JSONObject resultJson = new JSONObject(results.getResultString());
sn = resultJson.optString("sn");
@ -177,7 +177,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
for (String key : mIatResults.keySet()) {
resultBuffer.append(mIatResults.get(key));
}
if(resultBuffer.toString().equals("健康。")){
if(resultBuffer.toString().equals("健康。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -191,7 +191,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("行程。")){
else if(resultBuffer.toString().equals("行程。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -205,7 +205,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("核酸检测。")){
else if(resultBuffer.toString().equals("核酸检测。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -219,7 +219,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("扫码付款。")){
else if(resultBuffer.toString().equals("扫码付款。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -233,7 +233,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("付款码。")){
else if(resultBuffer.toString().equals("付款码。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -247,7 +247,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("收款码。")){
else if(resultBuffer.toString().equals("收款码。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -261,7 +261,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("设置常用联系人。")){
else if(resultBuffer.toString().equals("设置常用联系人。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -282,7 +282,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("呼叫。")){
else if(resultBuffer.toString().equals("呼叫。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -297,7 +297,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("一键通。")){
else if(resultBuffer.toString().equals("一键通。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -310,7 +310,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("找寻。")){
else if(resultBuffer.toString().equals("找寻。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -323,7 +323,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
});
}
else if(resultBuffer.toString().equals("健康。")){
else if(resultBuffer.toString().equals("健康。")){
Button button1 = findViewById(R.id.go);
tvResult1.setText(resultBuffer.toString());
@ -347,24 +347,24 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
/**
*
*
*
* @return
*/
public void setParam() {
// 清空参数
// 清空参数
mIat.setParameter(SpeechConstant.PARAMS, null);
// 设置听写引擎
// 设置听写引擎
mIat.setParameter(SpeechConstant.ENGINE_TYPE, mEngineType);
// 设置返回结果格式
// 设置返回结果格式
mIat.setParameter(SpeechConstant.RESULT_TYPE, resultType);
if (language.equals("zh_cn")) {
String lag = mSharedPreferences.getString("iat_language_preference",
"mandarin");
Log.e(TAG, "language:" + language);// 设置语言
Log.e(TAG, "language:" + language);// 设置语言
mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
// 设置语言区域
// 设置语言区域
mIat.setParameter(SpeechConstant.ACCENT, lag);
} else {
@ -372,25 +372,25 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
Log.e(TAG, "last language:" + mIat.getParameter(SpeechConstant.LANGUAGE));
//此处用于设置dialog中不显示错误码信息
//此处用于设置dialog中不显示错误码信息
//mIat.setParameter("view_tips_plain","false");
// 设置语音前端点:静音超时时间,即用户多长时间不说话则当做超时处理
// 设置语音前端点:静音超时时间,即用户多长时间不说话则当做超时处理
mIat.setParameter(SpeechConstant.VAD_BOS, mSharedPreferences.getString("iat_vadbos_preference", "4000"));
// 设置语音后端点:后端点静音检测时间,即用户停止说话多长时间内即认为不再输入, 自动停止录音
// 设置语音后端点:后端点静音检测时间,即用户停止说话多长时间内即认为不再输入, 自动停止录音
mIat.setParameter(SpeechConstant.VAD_EOS, mSharedPreferences.getString("iat_vadeos_preference", "1000"));
// 设置标点符号,设置为"0"返回结果无标点,设置为"1"返回结果有标点
// 设置标点符号,设置为"0"返回结果无标点,设置为"1"返回结果有标点
mIat.setParameter(SpeechConstant.ASR_PTT, mSharedPreferences.getString("iat_punc_preference", "1"));
// 设置音频保存路径保存音频格式支持pcm、wav设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
// 设置音频保存路径保存音频格式支持pcm、wav设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
mIat.setParameter(SpeechConstant.AUDIO_FORMAT, "wav");
mIat.setParameter(SpeechConstant.ASR_AUDIO_PATH, Environment.getExternalStorageDirectory() + "/msc/iat.wav");
}
/**
*
*
* @param msg
*/
private void showMsg(String msg) {
@ -402,7 +402,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
super.onDestroy();
if (null != mIat) {
// 退出时释放连接
// 退出时释放连接
mIat.cancel();
mIat.destroy();
}
@ -410,7 +410,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
/**
* android 6.0
* android 6.0
*/
private void initPermission() {
String permissions[] = {Manifest.permission.RECORD_AUDIO,
@ -434,7 +434,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
}
/**
*
*
*
* @param requestCode
* @param permissions
@ -442,7 +442,7 @@ public class yuyin extends AppCompatActivity implements View.OnClickListener {
*/
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
// 此处为android 6.0以上动态授权的回调,用户自行实现。
// 此处为android 6.0以上动态授权的回调,用户自行实现。
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

@ -11,12 +11,7 @@
android:text="选择要找寻物品的编号"
android:textSize="30sp"
android:onClick="jump"
<<<<<<< HEAD:src/MyApplication/app/src/main/res/layout/activity_zhaoxun.xml
android:gravity="left" />
=======
android:gravity="left"></Button>
>>>>>>> dc8dfd73a8a58508fec99a79684ba5574328c7e7:src/MyApplication/app/src/MyApplication/app/src/main/res/layout/activity_zhaoxun.xml
<Button
android:id="@+id/map"
android:layout_width="380dp"
@ -24,9 +19,5 @@
android:text="查看自己所在的定位"
android:onClick="jump"
android:textSize="30sp"
<<<<<<< HEAD:src/MyApplication/app/src/main/res/layout/activity_zhaoxun.xml
android:gravity="left" />
=======
android:gravity="left"></Button>
>>>>>>> dc8dfd73a8a58508fec99a79684ba5574328c7e7:src/MyApplication/app/src/MyApplication/app/src/main/res/layout/activity_zhaoxun.xml
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Loading…
Cancel
Save