正式讯飞语音环境
This commit is contained in:
@ -8,7 +8,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "chaoran.business.pda"
|
applicationId "chaoran.business.pda"
|
||||||
minSdkVersion 22
|
minSdkVersion 26
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
@ -54,12 +54,18 @@ android {
|
|||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
/* repositories {
|
||||||
|
flatDir {
|
||||||
|
dirs 'libs'
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'com.google.android.material:material:1.2.1'
|
implementation 'com.google.android.material:material:1.2.1'
|
||||||
|
implementation 'com.google.code.gson:gson:2.6.2'
|
||||||
//加载jar包
|
//加载jar包
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation 'androidx.preference:preference:1.1.1'
|
implementation 'androidx.preference:preference:1.1.1'
|
||||||
|
//implementation fileTree(include: ['*.aar'], dir: 'libs')
|
||||||
}
|
}
|
||||||
BIN
app/libs/Msc.jar
Normal file
BIN
app/libs/Msc.jar
Normal file
Binary file not shown.
BIN
app/libs/arm64-v8a/libmsc.so
Normal file
BIN
app/libs/arm64-v8a/libmsc.so
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="chaoran.business">
|
package="chaoran.business">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|||||||
@ -5,8 +5,10 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -18,6 +20,9 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import chaoran.business.BrandEnum;
|
import chaoran.business.BrandEnum;
|
||||||
import chaoran.business.R;
|
import chaoran.business.R;
|
||||||
import chaoran.business.adapter.*;
|
import chaoran.business.adapter.*;
|
||||||
@ -25,6 +30,7 @@ import chaoran.business.engine.impl.NetworkSettingEngine;
|
|||||||
import chaoran.business.engine.SettingEngine;
|
import chaoran.business.engine.SettingEngine;
|
||||||
import chaoran.business.engine.impl.TekVoiceEngine;
|
import chaoran.business.engine.impl.TekVoiceEngine;
|
||||||
import chaoran.business.engine.VoiceEngine;
|
import chaoran.business.engine.VoiceEngine;
|
||||||
|
import chaoran.business.utils.LocalAddressUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程:联网认证设备型号,验证通过,查找设备品牌进行调用驱动操作
|
* 流程:联网认证设备型号,验证通过,查找设备品牌进行调用驱动操作
|
||||||
@ -37,7 +43,7 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
private Adapter adapter;
|
private Adapter adapter;
|
||||||
//private VoiceEngine voiceEngine;
|
private VoiceEngine voiceEngine;
|
||||||
private SettingEngine settingEngine;
|
private SettingEngine settingEngine;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private ActionBar actionBar;
|
private ActionBar actionBar;
|
||||||
@ -56,7 +62,7 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
BrandEnum brand = BrandEnum.code(Build.MANUFACTURER);
|
BrandEnum brand = BrandEnum.code(Build.MANUFACTURER);
|
||||||
Toast.makeText(this, Build.MANUFACTURER, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, Build.MANUFACTURER, Toast.LENGTH_LONG).show();
|
||||||
Log.i("brand===",brand.toString());
|
Log.i("brand===",brand.toString());
|
||||||
switch (brand) {
|
/* switch (brand) {
|
||||||
case UROBO:
|
case UROBO:
|
||||||
adapter = new UroBoAdapter(this, this);
|
adapter = new UroBoAdapter(this, this);
|
||||||
break;
|
break;
|
||||||
@ -72,13 +78,12 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
}
|
}
|
||||||
if (null != adapter) {
|
if (null != adapter) {
|
||||||
adapter.start();
|
adapter.start();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("JavascriptInterface")
|
@SuppressLint("JavascriptInterface")
|
||||||
private void initView() {
|
private void initView() {
|
||||||
actionBar = getSupportActionBar();
|
actionBar = getSupportActionBar();
|
||||||
// voiceEngine = new TekVoiceEngine(this);
|
voiceEngine = new TekVoiceEngine(this);
|
||||||
settingEngine = new NetworkSettingEngine(this);
|
settingEngine = new NetworkSettingEngine(this);
|
||||||
webView = findViewById(R.id.webView);
|
webView = findViewById(R.id.webView);
|
||||||
progressBar = findViewById(R.id.loading);
|
progressBar = findViewById(R.id.loading);
|
||||||
@ -88,11 +93,12 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
//设置接口进行windows暴露
|
//设置接口进行windows暴露
|
||||||
settings.setDomStorageEnabled(true);
|
settings.setDomStorageEnabled(true);
|
||||||
//语音引擎
|
//语音引擎
|
||||||
// webView.addJavascriptInterface(voiceEngine, "TekVoiceEngine");
|
webView.addJavascriptInterface(voiceEngine, "TekVoiceEngine");
|
||||||
//网络设置展示
|
//网络设置展示
|
||||||
webView.addJavascriptInterface(settingEngine, "NetworkSettingEngine");
|
webView.addJavascriptInterface(settingEngine, "NetworkSettingEngine");
|
||||||
//重新加载页面
|
//重新加载页面
|
||||||
webView.addJavascriptInterface(this, "View");
|
webView.addJavascriptInterface(this, "View");
|
||||||
|
webView.addJavascriptInterface(new LocalAddressUtil(), "Localpda");
|
||||||
webView.loadUrl(url());
|
webView.loadUrl(url());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,11 +179,24 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
public void result(String result) {
|
public void result(String result) {
|
||||||
runOnUiThread(() -> webView.loadUrl("javascript:render(\'" + result + "\')"));
|
runOnUiThread(() -> webView.loadUrl("javascript:render(\'" + result + "\')"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
adapter.stop();
|
adapter.stop();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
if (diPlayer != null) {
|
||||||
|
diPlayer.stop();
|
||||||
|
diPlayer.release();
|
||||||
|
diPlayer = null;
|
||||||
|
}
|
||||||
|
if (duPlayer != null) {
|
||||||
|
duPlayer.stop();
|
||||||
|
duPlayer.release();
|
||||||
|
duPlayer = null;
|
||||||
|
}
|
||||||
|
if (vibrator != null) {
|
||||||
|
vibrator.cancel();
|
||||||
|
}
|
||||||
|
completionListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -218,4 +237,48 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
webView.loadUrl(url());
|
webView.loadUrl(url());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
private MediaPlayer diPlayer = null;
|
||||||
|
private MediaPlayer duPlayer = null;
|
||||||
|
private String ttsNr;
|
||||||
|
public Vibrator vibrator;
|
||||||
|
|
||||||
|
@JavascriptInterface
|
||||||
|
public void play(String msg, String type, int isZd) {
|
||||||
|
ttsNr = msg;
|
||||||
|
if ("1".equals(type)) {
|
||||||
|
if (diPlayer == null) {
|
||||||
|
diPlayer = MediaPlayer.create(this, R.raw.didi);
|
||||||
|
diPlayer.setOnCompletionListener(completionListener);
|
||||||
|
}
|
||||||
|
diPlayer.start();
|
||||||
|
} else if ("2".equals(type)) {
|
||||||
|
if (duPlayer == null) {
|
||||||
|
duPlayer = MediaPlayer.create(this, R.raw.dudu);
|
||||||
|
duPlayer.setOnCompletionListener(completionListener);
|
||||||
|
}
|
||||||
|
duPlayer.start();
|
||||||
|
} else {
|
||||||
|
//isZd = 1;
|
||||||
|
if (voiceEngine != null) {
|
||||||
|
voiceEngine.startSpeaking(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isZd == 1) {
|
||||||
|
if (vibrator == null) {
|
||||||
|
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
}
|
||||||
|
vibrator.vibrate(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private MediaPlayer.OnCompletionListener completionListener = new MediaPlayer.OnCompletionListener() {
|
||||||
|
// @Override
|
||||||
|
public void onCompletion(MediaPlayer mp) {
|
||||||
|
if (ttsNr != null) {
|
||||||
|
if (voiceEngine != null) {
|
||||||
|
voiceEngine.startSpeaking(ttsNr);
|
||||||
|
}
|
||||||
|
ttsNr = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@ -1,11 +1,5 @@
|
|||||||
package chaoran.business.adapter;
|
package chaoran.business.adapter;
|
||||||
|
|
||||||
/*
|
|
||||||
**********************************************
|
|
||||||
* DATE PERSON REASON
|
|
||||||
* 2021-02-02 FXY Created
|
|
||||||
**********************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|||||||
Reference in New Issue
Block a user