滨化讯飞插件
This commit is contained in:
parent
f46962da29
commit
5e5aed2682
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,14 +1,13 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 30
|
||||||
buildToolsVersion '26.0.2'
|
buildToolsVersion "30.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.iflytek.voicedemo"
|
applicationId "com.iflytek.voicedemo"
|
||||||
minSdkVersion 9
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 30
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -26,17 +25,15 @@ android {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
|
google()
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile files('libs/Msc.jar')
|
implementation files('libs/Msc.jar')
|
||||||
// compile project(':MscLibSrc')
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
compile 'com.android.support:support-v4:23.+'
|
implementation 'com.google.android.material:material:1.4.0'
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,2 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<lint>
|
<lint></lint>
|
||||||
</lint>
|
|
@ -2,88 +2,81 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.iflytek.voicedemo"
|
package="com.iflytek.voicedemo"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="2.0.1018.1013" >
|
android:versionName="2.0.1018.1013">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:name="SpeechApp"
|
android:name="SpeechApp"
|
||||||
android:label="讯飞语音示例" >
|
android:label="讯飞语音示例">
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="com.iflytek.voicedemo.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.MainActivity"
|
android:name="com.iflytek.voicedemo.MainActivity"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:label="讯飞语音示例"
|
android:label="讯飞语音示例"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.iflytek.speech.setting.TtsSettings" >
|
<activity android:name="com.iflytek.speech.setting.TtsSettings" />
|
||||||
</activity>
|
<activity android:name="com.iflytek.speech.setting.IatSettings" />
|
||||||
<activity android:name="com.iflytek.speech.setting.IatSettings" >
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.IatDemo"
|
android:name="com.iflytek.voicedemo.IatDemo"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.AsrDemo"
|
android:name="com.iflytek.voicedemo.AsrDemo"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.TtsDemo"
|
android:name="com.iflytek.voicedemo.TtsDemo"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.IseDemo"
|
android:name="com.iflytek.voicedemo.IseDemo"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name="com.iflytek.voicedemo.vocalverify.VocalVerifyDemo"
|
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
|
||||||
android:screenOrientation="portrait" >
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.faceonline.OnlineFaceDemo"
|
android:name="com.iflytek.voicedemo.faceonline.OnlineFaceDemo"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.IdentifyGroup.GroupManagerActivity"
|
android:name="com.iflytek.voicedemo.IdentifyGroup.GroupManagerActivity"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait">
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.IdentifyGroup.FaceIdentifyActivity"
|
android:name="com.iflytek.voicedemo.IdentifyGroup.FaceIdentifyActivity"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait">
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
|
||||||
android:name="com.iflytek.voicedemo.IdentifyGroup.VocalIdentifyActivity"
|
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
|
||||||
android:screenOrientation="portrait">
|
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.voicedemo.IdentifyGroup.ResultIdentifyActivity"
|
android:name="com.iflytek.voicedemo.IdentifyGroup.ResultIdentifyActivity"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait">
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.speech.setting.IseSettings"
|
android:name="com.iflytek.speech.setting.IseSettings"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.iflytek.speech.setting.UrlSettings"
|
android:name="com.iflytek.speech.setting.UrlSettings"
|
||||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" />
|
||||||
</activity>
|
|
||||||
<!-- 移动统计分析 -->
|
<!-- 移动统计分析 -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="IFLYTEK_APPKEY"
|
android:name="IFLYTEK_APPKEY"
|
||||||
@ -95,20 +88,4 @@
|
|||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="8" />
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -3,10 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.iflytek.ise.result;
|
package com.iflytek.ise.result;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.iflytek.ise.result.entity.Sentence;
|
import com.iflytek.ise.result.entity.Sentence;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Title: Result</p>
|
* <p>Title: Result</p>
|
||||||
* <p>Description: 评测结果</p>
|
* <p>Description: 评测结果</p>
|
||||||
|
@ -99,7 +99,7 @@ public class Phone {
|
|||||||
|
|
||||||
public static String getStdSymbol(String content) {
|
public static String getStdSymbol(String content) {
|
||||||
String std = phone_map.get(content);
|
String std = phone_map.get(content);
|
||||||
return (null == std)? content: std;
|
return (null == std) ? content : std;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.iflytek.ise.result.util;
|
package com.iflytek.ise.result.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.iflytek.ise.result.entity.Phone;
|
import com.iflytek.ise.result.entity.Phone;
|
||||||
import com.iflytek.ise.result.entity.Sentence;
|
import com.iflytek.ise.result.entity.Sentence;
|
||||||
import com.iflytek.ise.result.entity.Syll;
|
import com.iflytek.ise.result.entity.Syll;
|
||||||
import com.iflytek.ise.result.entity.Word;
|
import com.iflytek.ise.result.entity.Word;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Title: ResultFormatUtl</p>
|
* <p>Title: ResultFormatUtl</p>
|
||||||
* <p>Description: </p>
|
* <p>Description: </p>
|
||||||
@ -31,7 +31,7 @@ public class ResultFormatUtil {
|
|||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Sentence sentence: sentences ) {
|
for (Sentence sentence : sentences) {
|
||||||
if ("噪音".equals(ResultTranslateUtil.getContent(sentence.content))
|
if ("噪音".equals(ResultTranslateUtil.getContent(sentence.content))
|
||||||
|| "静音".equals(ResultTranslateUtil.getContent(sentence.content))) {
|
|| "静音".equals(ResultTranslateUtil.getContent(sentence.content))) {
|
||||||
continue;
|
continue;
|
||||||
@ -40,7 +40,7 @@ public class ResultFormatUtil {
|
|||||||
if (null == sentence.words) {
|
if (null == sentence.words) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (Word word: sentence.words) {
|
for (Word word : sentence.words) {
|
||||||
if ("噪音".equals(ResultTranslateUtil.getContent(word.content))
|
if ("噪音".equals(ResultTranslateUtil.getContent(word.content))
|
||||||
|| "静音".equals(ResultTranslateUtil.getContent(word.content))) {
|
|| "静音".equals(ResultTranslateUtil.getContent(word.content))) {
|
||||||
continue;
|
continue;
|
||||||
@ -54,13 +54,13 @@ public class ResultFormatUtil {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Syll syll: word.sylls) {
|
for (Syll syll : word.sylls) {
|
||||||
buffer.append("\n└音节[" + ResultTranslateUtil.getContent(syll.getStdSymbol()) + "] ");
|
buffer.append("\n└音节[" + ResultTranslateUtil.getContent(syll.getStdSymbol()) + "] ");
|
||||||
if (null == syll.phones) {
|
if (null == syll.phones) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Phone phone: syll.phones) {
|
for (Phone phone : syll.phones) {
|
||||||
buffer.append("\n\t└音素[" + ResultTranslateUtil.getContent(phone.getStdSymbol()) + "] ")
|
buffer.append("\n\t└音素[" + ResultTranslateUtil.getContent(phone.getStdSymbol()) + "] ")
|
||||||
.append(" 朗读:" + ResultTranslateUtil.getDpMessageInfo(phone.dp_message));
|
.append(" 朗读:" + ResultTranslateUtil.getDpMessageInfo(phone.dp_message));
|
||||||
}
|
}
|
||||||
@ -85,18 +85,18 @@ public class ResultFormatUtil {
|
|||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Sentence sentence: sentences ) {
|
for (Sentence sentence : sentences) {
|
||||||
if (null == sentence.words) {
|
if (null == sentence.words) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Word word: sentence.words) {
|
for (Word word : sentence.words) {
|
||||||
buffer.append("\n词语[" + ResultTranslateUtil.getContent(word.content) + "] " + word.symbol + " 时长:" + word.time_len);
|
buffer.append("\n词语[" + ResultTranslateUtil.getContent(word.content) + "] " + word.symbol + " 时长:" + word.time_len);
|
||||||
if (null == word.sylls) {
|
if (null == word.sylls) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Syll syll: word.sylls) {
|
for (Syll syll : word.sylls) {
|
||||||
if ("噪音".equals(ResultTranslateUtil.getContent(syll.content))
|
if ("噪音".equals(ResultTranslateUtil.getContent(syll.content))
|
||||||
|| "静音".equals(ResultTranslateUtil.getContent(syll.content))) {
|
|| "静音".equals(ResultTranslateUtil.getContent(syll.content))) {
|
||||||
continue;
|
continue;
|
||||||
@ -107,7 +107,7 @@ public class ResultFormatUtil {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Phone phone: syll.phones) {
|
for (Phone phone : syll.phones) {
|
||||||
buffer.append("\n\t└音素[" + ResultTranslateUtil.getContent(phone.content) + "] " + "时长:" + phone.time_len)
|
buffer.append("\n\t└音素[" + ResultTranslateUtil.getContent(phone.content) + "] " + "时长:" + phone.time_len)
|
||||||
.append(" 朗读:" + ResultTranslateUtil.getDpMessageInfo(phone.dp_message));
|
.append(" 朗读:" + ResultTranslateUtil.getDpMessageInfo(phone.dp_message));
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,6 @@ public class ResultTranslateUtil {
|
|||||||
|
|
||||||
public static String getContent(String content) {
|
public static String getContent(String content) {
|
||||||
String val = special_content_map.get(content);
|
String val = special_content_map.get(content);
|
||||||
return (null == val)? content: val;
|
return (null == val) ? content : val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.iflytek.ise.result.xml;
|
package com.iflytek.ise.result.xml;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
|
|
||||||
@ -24,6 +16,14 @@ import com.iflytek.ise.result.entity.Sentence;
|
|||||||
import com.iflytek.ise.result.entity.Syll;
|
import com.iflytek.ise.result.entity.Syll;
|
||||||
import com.iflytek.ise.result.entity.Word;
|
import com.iflytek.ise.result.entity.Word;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Title: XmlResultParser</p>
|
* <p>Title: XmlResultParser</p>
|
||||||
* <p>Description: </p>
|
* <p>Description: </p>
|
||||||
@ -109,7 +109,7 @@ public class XmlResultParser {
|
|||||||
if (!rec_paperPassed) {
|
if (!rec_paperPassed) {
|
||||||
result = new ReadWordResult();
|
result = new ReadWordResult();
|
||||||
String lan = getLanguage(pullParser);
|
String lan = getLanguage(pullParser);
|
||||||
result.language = (null == lan)? "cn": lan;
|
result.language = (null == lan) ? "cn" : lan;
|
||||||
} else {
|
} else {
|
||||||
readTotalResult(result, pullParser);
|
readTotalResult(result, pullParser);
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ public class XmlResultParser {
|
|||||||
if (!rec_paperPassed) {
|
if (!rec_paperPassed) {
|
||||||
result = new ReadSentenceResult();
|
result = new ReadSentenceResult();
|
||||||
String lan = getLanguage(pullParser);
|
String lan = getLanguage(pullParser);
|
||||||
result.language = (null == lan)? "cn": lan;
|
result.language = (null == lan) ? "cn" : lan;
|
||||||
} else {
|
} else {
|
||||||
readTotalResult(result, pullParser);
|
readTotalResult(result, pullParser);
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,13 @@ public class IatSettings extends PreferenceActivity implements OnPreferenceChang
|
|||||||
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
||||||
addPreferencesFromResource(R.xml.iat_setting);
|
addPreferencesFromResource(R.xml.iat_setting);
|
||||||
|
|
||||||
mVadbosPreference = (EditTextPreference)findPreference("iat_vadbos_preference");
|
mVadbosPreference = (EditTextPreference) findPreference("iat_vadbos_preference");
|
||||||
mVadbosPreference.getEditText().addTextChangedListener(new SettingTextWatcher(IatSettings.this,mVadbosPreference,0,10000));
|
mVadbosPreference.getEditText().addTextChangedListener(new SettingTextWatcher(IatSettings.this, mVadbosPreference, 0, 10000));
|
||||||
|
|
||||||
mVadeosPreference = (EditTextPreference)findPreference("iat_vadeos_preference");
|
mVadeosPreference = (EditTextPreference) findPreference("iat_vadeos_preference");
|
||||||
mVadeosPreference.getEditText().addTextChangedListener(new SettingTextWatcher(IatSettings.this,mVadeosPreference,0,10000));
|
mVadeosPreference.getEditText().addTextChangedListener(new SettingTextWatcher(IatSettings.this, mVadeosPreference, 0, 10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,8 +7,8 @@ import android.os.Bundle;
|
|||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@ -17,6 +17,8 @@ import android.widget.Toast;
|
|||||||
import com.iflytek.cloud.SpeechConstant;
|
import com.iflytek.cloud.SpeechConstant;
|
||||||
import com.iflytek.voicedemo.R;
|
import com.iflytek.voicedemo.R;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评测设置界面
|
* 评测设置界面
|
||||||
*/
|
*/
|
||||||
@ -32,6 +34,9 @@ public class IseSettings extends PreferenceActivity {
|
|||||||
|
|
||||||
private Toast mToast;
|
private Toast mToast;
|
||||||
|
|
||||||
|
private HashMap<String, String> zhMap = new HashMap<>();
|
||||||
|
private HashMap<String, String> enMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
@ -39,10 +44,27 @@ public class IseSettings extends PreferenceActivity {
|
|||||||
|
|
||||||
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
||||||
addPreferencesFromResource(R.xml.ise_settings);
|
addPreferencesFromResource(R.xml.ise_settings);
|
||||||
|
initCategoryMap();
|
||||||
initUI();
|
initUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initCategoryMap() {
|
||||||
|
zhMap.put("read_syllable", "单字");
|
||||||
|
zhMap.put("read_word", "词语");
|
||||||
|
zhMap.put("read_sentence", "句子");
|
||||||
|
zhMap.put("read_chapter", "篇章");
|
||||||
|
|
||||||
|
enMap.put("read_word", "词语");
|
||||||
|
enMap.put("read_sentence", "句子");
|
||||||
|
enMap.put("read_chapter", "篇章");
|
||||||
|
enMap.put("simple_expression", "英文情景反应");
|
||||||
|
enMap.put("read_choice", "英文选择题");
|
||||||
|
enMap.put("topic", "英文自由题");
|
||||||
|
enMap.put("retell", "英文复述题");
|
||||||
|
enMap.put("picture_talk", "英文看图说话");
|
||||||
|
enMap.put("oral_translation", "英文口头翻译");
|
||||||
|
}
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
mLanguagePref = (ListPreference) findPreference(SpeechConstant.LANGUAGE);
|
mLanguagePref = (ListPreference) findPreference(SpeechConstant.LANGUAGE);
|
||||||
mCategoryPref = (ListPreference) findPreference(SpeechConstant.ISE_CATEGORY);
|
mCategoryPref = (ListPreference) findPreference(SpeechConstant.ISE_CATEGORY);
|
||||||
@ -70,14 +92,23 @@ public class IseSettings extends PreferenceActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
|
||||||
|
String categoryValue = mCategoryPref.getValue();
|
||||||
|
|
||||||
if ("zh_cn".equals(newValue.toString())) {
|
if ("zh_cn".equals(newValue.toString())) {
|
||||||
|
// 中文
|
||||||
if ("plain".equals(mResultLevelPref.getValue())) {
|
if ("plain".equals(mResultLevelPref.getValue())) {
|
||||||
showTip("汉语评测结果格式不支持plain设置");
|
showTip("汉语评测结果格式不支持plain设置");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!zhMap.containsKey(categoryValue)) {
|
||||||
|
showTip("中文评测不支持" + enMap.get(categoryValue));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ("read_syllable".equals(mCategoryPref.getValue())) {
|
// 英文
|
||||||
showTip("英语评测不支持单字");
|
if (!enMap.containsKey(categoryValue)) {
|
||||||
|
showTip("英语评测不支持" + zhMap.get(categoryValue));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,10 +124,20 @@ public class IseSettings extends PreferenceActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
if ("en_us".equals(mLanguagePref.getValue()) && "read_syllable".equals(newValue.toString())) {
|
String categoryValue = newValue.toString();
|
||||||
showTip("英语评测不支持单字,请选其他项");
|
|
||||||
|
if ("en_us".equals(mLanguagePref.getValue())) {
|
||||||
|
if (!enMap.containsKey(categoryValue)) {
|
||||||
|
showTip("英语评测不支持" + zhMap.get(categoryValue) + ",请选其他项");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ("zh_cn".equals(mLanguagePref.getValue())) {
|
||||||
|
if (!zhMap.containsKey(categoryValue)) {
|
||||||
|
showTip("中文评测不支持" + enMap.get(categoryValue) + ",请选其他项");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int newValueIndex = mCategoryPref.findIndexOfValue(newValue.toString());
|
int newValueIndex = mCategoryPref.findIndexOfValue(newValue.toString());
|
||||||
String newEntry = (String) mCategoryPref.getEntries()[newValueIndex];
|
String newEntry = (String) mCategoryPref.getEntries()[newValueIndex];
|
||||||
@ -163,7 +204,7 @@ public class IseSettings extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mSpeechTimeoutPref.getEditText().setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED|InputType.TYPE_CLASS_NUMBER);
|
mSpeechTimeoutPref.getEditText().setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_CLASS_NUMBER);
|
||||||
mSpeechTimeoutPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
mSpeechTimeoutPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -193,7 +234,8 @@ public class IseSettings extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showTip(String str) {
|
private void showTip(String str) {
|
||||||
if(!TextUtils.isEmpty(str)) {
|
if (!TextUtils.isEmpty(str)) {
|
||||||
|
mToast.cancel();
|
||||||
mToast.setText(str);
|
mToast.setText(str);
|
||||||
mToast.show();
|
mToast.show();
|
||||||
}
|
}
|
||||||
|
@ -29,14 +29,14 @@ public class TtsSettings extends PreferenceActivity implements OnPreferenceChang
|
|||||||
// 指定保存文件名字
|
// 指定保存文件名字
|
||||||
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
||||||
addPreferencesFromResource(R.xml.tts_setting);
|
addPreferencesFromResource(R.xml.tts_setting);
|
||||||
mSpeedPreference = (EditTextPreference)findPreference("speed_preference");
|
mSpeedPreference = (EditTextPreference) findPreference("speed_preference");
|
||||||
mSpeedPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mSpeedPreference,0,200));
|
mSpeedPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this, mSpeedPreference, 0, 200));
|
||||||
|
|
||||||
mPitchPreference = (EditTextPreference)findPreference("pitch_preference");
|
mPitchPreference = (EditTextPreference) findPreference("pitch_preference");
|
||||||
mPitchPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mPitchPreference,0,100));
|
mPitchPreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this, mPitchPreference, 0, 100));
|
||||||
|
|
||||||
mVolumePreference = (EditTextPreference)findPreference("volume_preference");
|
mVolumePreference = (EditTextPreference) findPreference("volume_preference");
|
||||||
mVolumePreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this,mVolumePreference,0,100));
|
mVolumePreference.getEditText().addTextChangedListener(new SettingTextWatcher(TtsSettings.this, mVolumePreference, 0, 100));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package com.iflytek.speech.setting;
|
package com.iflytek.speech.setting;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PersistableBundle;
|
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
|
||||||
import com.iflytek.cloud.SpeechConstant;
|
import androidx.annotation.Nullable;
|
||||||
import com.iflytek.voicedemo.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
import com.iflytek.voicedemo.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hjyu
|
* @author hjyu
|
||||||
@ -33,7 +30,7 @@ public class UrlSettings extends PreferenceActivity implements Preference.OnPref
|
|||||||
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
getPreferenceManager().setSharedPreferencesName(PREFER_NAME);
|
||||||
addPreferencesFromResource(R.xml.url_setting);
|
addPreferencesFromResource(R.xml.url_setting);
|
||||||
|
|
||||||
url_preference = (ListPreference)findPreference("url_preference");
|
url_preference = (ListPreference) findPreference("url_preference");
|
||||||
url_preference.setSummary("当前:" + url_preference.getEntry());
|
url_preference.setSummary("当前:" + url_preference.getEntry());
|
||||||
url_preference.setOnPreferenceChangeListener(this);
|
url_preference.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package com.iflytek.speech.util;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -13,14 +15,17 @@ import android.graphics.Point;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.media.ExifInterface;
|
import android.media.ExifInterface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Build;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class FaceUtil {
|
public class FaceUtil {
|
||||||
@ -28,6 +33,19 @@ public class FaceUtil {
|
|||||||
public final static int REQUEST_CAMERA_IMAGE = 2;
|
public final static int REQUEST_CAMERA_IMAGE = 2;
|
||||||
public final static int REQUEST_CROP_IMAGE = 3;
|
public final static int REQUEST_CROP_IMAGE = 3;
|
||||||
|
|
||||||
|
|
||||||
|
public static Uri parseUri(Context context, File file) {
|
||||||
|
Uri imageUri = Uri.fromFile(file);
|
||||||
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
|
imageUri = FileProvider.getUriForFile(
|
||||||
|
context,
|
||||||
|
context.getPackageName() + ".fileprovider",
|
||||||
|
file
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return imageUri;
|
||||||
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 裁剪图片
|
* 裁剪图片
|
||||||
* @param activity Activity
|
* @param activity Activity
|
||||||
@ -41,35 +59,40 @@ public class FaceUtil {
|
|||||||
innerIntent.putExtra("aspectY", 1);// 放大缩小比例的X 这里的比例为: 1:1
|
innerIntent.putExtra("aspectY", 1);// 放大缩小比例的X 这里的比例为: 1:1
|
||||||
innerIntent.putExtra("outputX", 320); //这个是限制输出图片大小
|
innerIntent.putExtra("outputX", 320); //这个是限制输出图片大小
|
||||||
innerIntent.putExtra("outputY", 320);
|
innerIntent.putExtra("outputY", 320);
|
||||||
innerIntent.putExtra("return-data", true);
|
innerIntent.putExtra("return-data", false);
|
||||||
// 切图大小不足输出,无黑框
|
// 切图大小不足输出,无黑框
|
||||||
innerIntent.putExtra("scale", true);
|
innerIntent.putExtra("scale", true);
|
||||||
innerIntent.putExtra("scaleUpIfNeeded", true);
|
innerIntent.putExtra("scaleUpIfNeeded", true);
|
||||||
File imageFile = new File(getImagePath(activity.getApplicationContext()));
|
File imageFile = new File(getImagePath(activity.getApplicationContext()));
|
||||||
innerIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
|
imageFile.delete();
|
||||||
|
Uri cropUri = parseUri(activity, imageFile);
|
||||||
|
innerIntent.putExtra(MediaStore.EXTRA_OUTPUT, cropUri);
|
||||||
innerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
innerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||||
|
|
||||||
|
List<ResolveInfo> resolveInfos = activity.getPackageManager()
|
||||||
|
.queryIntentActivities(innerIntent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||||
|
for (ResolveInfo resolveInfo : resolveInfos) {
|
||||||
|
activity.grantUriPermission(activity.getPackageName(), uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
activity.grantUriPermission(resolveInfo.activityInfo.packageName, cropUri,
|
||||||
|
(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION));
|
||||||
|
}
|
||||||
|
innerIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
innerIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
activity.startActivityForResult(innerIntent, REQUEST_CROP_IMAGE);
|
activity.startActivityForResult(innerIntent, REQUEST_CROP_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存裁剪的图片的路径
|
* 保存裁剪的图片的路径
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getImagePath(Context context){
|
public static String getImagePath(Context context) {
|
||||||
String path;
|
String path = context.getExternalFilesDir("msc").getAbsolutePath();
|
||||||
|
if (!path.endsWith("/")) {
|
||||||
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
|
||||||
path = context.getFilesDir().getAbsolutePath();
|
|
||||||
} else {
|
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/msc/";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!path.endsWith("/")) {
|
|
||||||
path += "/";
|
path += "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
File folder = new File(path);
|
File folder = new File(path);
|
||||||
if (folder != null && !folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
}
|
}
|
||||||
path += "ifd.jpg";
|
path += "ifd.jpg";
|
||||||
@ -134,7 +157,7 @@ public class FaceUtil {
|
|||||||
* @param DrawOriRect 可绘制原始框,也可以只画四个角
|
* @param DrawOriRect 可绘制原始框,也可以只画四个角
|
||||||
*/
|
*/
|
||||||
static public void drawFaceRect(Canvas canvas, FaceRect face, int width, int height, boolean frontCamera, boolean DrawOriRect) {
|
static public void drawFaceRect(Canvas canvas, FaceRect face, int width, int height, boolean frontCamera, boolean DrawOriRect) {
|
||||||
if(canvas == null) {
|
if (canvas == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +169,7 @@ public class FaceUtil {
|
|||||||
|
|
||||||
Rect rect = face.bound;
|
Rect rect = face.bound;
|
||||||
|
|
||||||
if(frontCamera) {
|
if (frontCamera) {
|
||||||
int top = rect.top;
|
int top = rect.top;
|
||||||
rect.top = width - rect.bottom;
|
rect.top = width - rect.bottom;
|
||||||
rect.bottom = width - top;
|
rect.bottom = width - top;
|
||||||
@ -161,20 +184,19 @@ public class FaceUtil {
|
|||||||
int drawu = rect.top - len;
|
int drawu = rect.top - len;
|
||||||
int drawd = rect.bottom + len;
|
int drawd = rect.bottom + len;
|
||||||
|
|
||||||
canvas.drawLine(drawl,drawd,drawl,drawd-len, paint);
|
canvas.drawLine(drawl, drawd, drawl, drawd - len, paint);
|
||||||
canvas.drawLine(drawl,drawd,drawl+len,drawd, paint);
|
canvas.drawLine(drawl, drawd, drawl + len, drawd, paint);
|
||||||
canvas.drawLine(drawr,drawd,drawr,drawd-len, paint);
|
canvas.drawLine(drawr, drawd, drawr, drawd - len, paint);
|
||||||
canvas.drawLine(drawr,drawd,drawr-len,drawd, paint);
|
canvas.drawLine(drawr, drawd, drawr - len, drawd, paint);
|
||||||
canvas.drawLine(drawl,drawu,drawl,drawu+len, paint);
|
canvas.drawLine(drawl, drawu, drawl, drawu + len, paint);
|
||||||
canvas.drawLine(drawl,drawu,drawl+len,drawu, paint);
|
canvas.drawLine(drawl, drawu, drawl + len, drawu, paint);
|
||||||
canvas.drawLine(drawr,drawu,drawr,drawu+len, paint);
|
canvas.drawLine(drawr, drawu, drawr, drawu + len, paint);
|
||||||
canvas.drawLine(drawr,drawu,drawr-len,drawu, paint);
|
canvas.drawLine(drawr, drawu, drawr - len, drawu, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (face.point != null) {
|
if (face.point != null) {
|
||||||
for (Point p : face.point)
|
for (Point p : face.point) {
|
||||||
{
|
if (frontCamera) {
|
||||||
if(frontCamera) {
|
|
||||||
p.y = width - p.y;
|
p.y = width - p.y;
|
||||||
}
|
}
|
||||||
canvas.drawPoint(p.x, p.y, paint);
|
canvas.drawPoint(p.x, p.y, paint);
|
||||||
@ -185,40 +207,27 @@ public class FaceUtil {
|
|||||||
/**
|
/**
|
||||||
* 将矩形随原图顺时针旋转90度
|
* 将矩形随原图顺时针旋转90度
|
||||||
*
|
*
|
||||||
* @param r
|
* @param r 待旋转的矩形
|
||||||
* 待旋转的矩形
|
* @param width 输入矩形对应的原图宽
|
||||||
*
|
* @param height 输入矩形对应的原图高
|
||||||
* @param width
|
* @return 旋转后的矩形
|
||||||
* 输入矩形对应的原图宽
|
|
||||||
*
|
|
||||||
* @param height
|
|
||||||
* 输入矩形对应的原图高
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* 旋转后的矩形
|
|
||||||
*/
|
*/
|
||||||
static public Rect RotateDeg90(Rect r, int width, int height) {
|
static public Rect RotateDeg90(Rect r, int width, int height) {
|
||||||
int left = r.left;
|
int left = r.left;
|
||||||
r.left = height- r.bottom;
|
r.left = height - r.bottom;
|
||||||
r.bottom= r.right;
|
r.bottom = r.right;
|
||||||
r.right = height- r.top;
|
r.right = height - r.top;
|
||||||
r.top = left;
|
r.top = left;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将点随原图顺时针旋转90度
|
* 将点随原图顺时针旋转90度
|
||||||
* @param p
|
|
||||||
* 待旋转的点
|
|
||||||
*
|
*
|
||||||
* @param width
|
* @param p 待旋转的点
|
||||||
* 输入点对应的原图宽
|
* @param width 输入点对应的原图宽
|
||||||
*
|
* @param height 输入点对应的原图宽
|
||||||
* @param height
|
* @return 旋转后的点
|
||||||
* 输入点对应的原图宽
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* 旋转后的点
|
|
||||||
*/
|
*/
|
||||||
static public Point RotateDeg90(Point p, int width, int height) {
|
static public Point RotateDeg90(Point p, int width, int height) {
|
||||||
int x = p.x;
|
int x = p.x;
|
||||||
@ -231,7 +240,7 @@ public class FaceUtil {
|
|||||||
class CpuFilter implements FileFilter {
|
class CpuFilter implements FileFilter {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File pathname) {
|
public boolean accept(File pathname) {
|
||||||
if(Pattern.matches("cpu[0-9]", pathname.getName())) {
|
if (Pattern.matches("cpu[0-9]", pathname.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -241,7 +250,7 @@ public class FaceUtil {
|
|||||||
File dir = new File("/sys/devices/system/cpu/");
|
File dir = new File("/sys/devices/system/cpu/");
|
||||||
File[] files = dir.listFiles(new CpuFilter());
|
File[] files = dir.listFiles(new CpuFilter());
|
||||||
return files.length;
|
return files.length;
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -249,9 +258,8 @@ public class FaceUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存Bitmap至本地
|
* 保存Bitmap至本地
|
||||||
* @param Bitmap
|
|
||||||
*/
|
*/
|
||||||
public static void saveBitmapToFile(Context context,Bitmap bmp){
|
public static void saveBitmapToFile(Context context, Bitmap bmp) {
|
||||||
String file_path = getImagePath(context);
|
String file_path = getImagePath(context);
|
||||||
File file = new File(file_path);
|
File file = new File(file_path);
|
||||||
FileOutputStream fOut;
|
FileOutputStream fOut;
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package com.iflytek.speech.util;
|
package com.iflytek.speech.util;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import android.content.Context;
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import com.iflytek.cloud.ErrorCode;
|
import com.iflytek.cloud.ErrorCode;
|
||||||
import com.iflytek.cloud.SpeechConstant;
|
import com.iflytek.cloud.SpeechConstant;
|
||||||
import com.iflytek.cloud.SpeechUtility;
|
import com.iflytek.cloud.SpeechUtility;
|
||||||
|
|
||||||
import android.content.Context;
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 功能性函数扩展类
|
* 功能性函数扩展类
|
||||||
@ -18,12 +19,12 @@ import android.content.Context;
|
|||||||
public class FucUtil {
|
public class FucUtil {
|
||||||
/**
|
/**
|
||||||
* 读取asset目录下文件。
|
* 读取asset目录下文件。
|
||||||
|
*
|
||||||
* @return content
|
* @return content
|
||||||
*/
|
*/
|
||||||
public static String readFile(Context mContext,String file,String code)
|
public static String readFile(Context mContext, String file, String code) {
|
||||||
{
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
byte []buf = null;
|
byte[] buf = null;
|
||||||
String result = "";
|
String result = "";
|
||||||
try {
|
try {
|
||||||
InputStream in = mContext.getAssets().open(file);
|
InputStream in = mContext.getAssets().open(file);
|
||||||
@ -31,51 +32,50 @@ public class FucUtil {
|
|||||||
buf = new byte[len];
|
buf = new byte[len];
|
||||||
in.read(buf, 0, len);
|
in.read(buf, 0, len);
|
||||||
|
|
||||||
result = new String(buf,code);
|
result = new String(buf, code);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将字节缓冲区按照固定大小进行分割成数组
|
* 将字节缓冲区按照固定大小进行分割成数组
|
||||||
|
*
|
||||||
* @param buffer 缓冲区
|
* @param buffer 缓冲区
|
||||||
* @param length 缓冲区大小
|
* @param length 缓冲区大小
|
||||||
* @param spsize 切割块大小
|
* @param spsize 切割块大小
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ArrayList<byte[]> splitBuffer(byte[] buffer,int length,int spsize)
|
public static ArrayList<byte[]> splitBuffer(byte[] buffer, int length, int spsize) {
|
||||||
{
|
|
||||||
ArrayList<byte[]> array = new ArrayList<byte[]>();
|
ArrayList<byte[]> array = new ArrayList<byte[]>();
|
||||||
if(spsize <= 0 || length <= 0 || buffer == null || buffer.length < length)
|
if (spsize <= 0 || length <= 0 || buffer == null || buffer.length < length)
|
||||||
return array;
|
return array;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
while(size < length)
|
while (size < length) {
|
||||||
{
|
|
||||||
int left = length - size;
|
int left = length - size;
|
||||||
if(spsize < left)
|
if (spsize < left) {
|
||||||
{
|
|
||||||
byte[] sdata = new byte[spsize];
|
byte[] sdata = new byte[spsize];
|
||||||
System.arraycopy(buffer,size,sdata,0,spsize);
|
System.arraycopy(buffer, size, sdata, 0, spsize);
|
||||||
array.add(sdata);
|
array.add(sdata);
|
||||||
size += spsize;
|
size += spsize;
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
byte[] sdata = new byte[left];
|
byte[] sdata = new byte[left];
|
||||||
System.arraycopy(buffer,size,sdata,0,left);
|
System.arraycopy(buffer, size, sdata, 0, left);
|
||||||
array.add(sdata);
|
array.add(sdata);
|
||||||
size += left;
|
size += left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取语记是否包含离线听写资源,如未包含跳转至资源下载页面
|
* 获取语记是否包含离线听写资源,如未包含跳转至资源下载页面
|
||||||
*1.PLUS_LOCAL_ALL: 本地所有资源
|
* 1.PLUS_LOCAL_ALL: 本地所有资源
|
||||||
2.PLUS_LOCAL_ASR: 本地识别资源
|
* 2.PLUS_LOCAL_ASR: 本地识别资源
|
||||||
3.PLUS_LOCAL_TTS: 本地合成资源
|
* 3.PLUS_LOCAL_TTS: 本地合成资源
|
||||||
*/
|
*/
|
||||||
public static String checkLocalResource(){
|
public static String checkLocalResource() {
|
||||||
String resource = SpeechUtility.getUtility().getParameter(SpeechConstant.PLUS_LOCAL_ASR);
|
String resource = SpeechUtility.getUtility().getParameter(SpeechConstant.PLUS_LOCAL_ASR);
|
||||||
try {
|
try {
|
||||||
JSONObject result = new JSONObject(resource);
|
JSONObject result = new JSONObject(resource);
|
||||||
@ -87,7 +87,7 @@ public class FucUtil {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
// 查询否包含离线听写资源
|
// 查询否包含离线听写资源
|
||||||
for (; i < asrArray.length(); i++) {
|
for (; i < asrArray.length(); i++) {
|
||||||
if("iat".equals(asrArray.getJSONObject(i).get(SpeechConstant.DOMAIN))){
|
if ("iat".equals(asrArray.getJSONObject(i).get(SpeechConstant.DOMAIN))) {
|
||||||
//asrArray中包含语言、方言字段,后续会增加支持方言的本地听写。
|
//asrArray中包含语言、方言字段,后续会增加支持方言的本地听写。
|
||||||
//如:"accent": "mandarin","language": "zh_cn"
|
//如:"accent": "mandarin","language": "zh_cn"
|
||||||
break;
|
break;
|
||||||
@ -98,7 +98,7 @@ public class FucUtil {
|
|||||||
SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR);
|
SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR);
|
||||||
return "没有听写资源,跳转至资源下载页面";
|
return "没有听写资源,跳转至资源下载页面";
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR);
|
SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR);
|
||||||
return "没有听写资源,跳转至资源下载页面";
|
return "没有听写资源,跳转至资源下载页面";
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Json结果解析类
|
* Json结果解析类
|
||||||
*/
|
*/
|
||||||
@ -36,6 +34,66 @@ public class JsonParser {
|
|||||||
return ret.toString();
|
return ret.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String parseGrammarResult(String json, String engType) {
|
||||||
|
StringBuffer ret = new StringBuffer();
|
||||||
|
try {
|
||||||
|
JSONTokener tokener = new JSONTokener(json);
|
||||||
|
JSONObject joResult = new JSONObject(tokener);
|
||||||
|
|
||||||
|
JSONArray words = joResult.getJSONArray("ws");
|
||||||
|
// 云端和本地结果分情况解析
|
||||||
|
if ("cloud".equals(engType)) {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ("local".equals(engType)) {
|
||||||
|
ret.append("【结果】");
|
||||||
|
for (int i = 0; i < words.length(); i++) {
|
||||||
|
JSONObject wsItem = words.getJSONObject(i);
|
||||||
|
JSONArray items = wsItem.getJSONArray("cw");
|
||||||
|
if ("<contact>".equals(wsItem.getString("slot"))) {
|
||||||
|
// 可能会有多个联系人供选择,用中括号括起来,这些候选项具有相同的置信度
|
||||||
|
ret.append("【");
|
||||||
|
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")).append("|");
|
||||||
|
}
|
||||||
|
ret.setCharAt(ret.length() - 1, '】');
|
||||||
|
} else {
|
||||||
|
//本地多候选按照置信度高低排序,一般选取第一个结果即可
|
||||||
|
JSONObject obj = items.getJSONObject(0);
|
||||||
|
if (obj.getString("w").contains("nomatch")) {
|
||||||
|
ret.append("没有匹配结果.");
|
||||||
|
return ret.toString();
|
||||||
|
}
|
||||||
|
ret.append(obj.getString("w"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret.append("【置信度】" + joResult.getInt("sc"));
|
||||||
|
ret.append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
ret.append("没有匹配结果.");
|
||||||
|
}
|
||||||
|
return ret.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public static String parseGrammarResult(String json) {
|
public static String parseGrammarResult(String json) {
|
||||||
StringBuffer ret = new StringBuffer();
|
StringBuffer ret = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
@ -45,11 +103,9 @@ public class JsonParser {
|
|||||||
JSONArray words = joResult.getJSONArray("ws");
|
JSONArray words = joResult.getJSONArray("ws");
|
||||||
for (int i = 0; i < words.length(); i++) {
|
for (int i = 0; i < words.length(); i++) {
|
||||||
JSONArray items = words.getJSONObject(i).getJSONArray("cw");
|
JSONArray items = words.getJSONObject(i).getJSONArray("cw");
|
||||||
for(int j = 0; j < items.length(); j++)
|
for (int j = 0; j < items.length(); j++) {
|
||||||
{
|
|
||||||
JSONObject obj = items.getJSONObject(j);
|
JSONObject obj = items.getJSONObject(j);
|
||||||
if(obj.getString("w").contains("nomatch"))
|
if (obj.getString("w").contains("nomatch")) {
|
||||||
{
|
|
||||||
ret.append("没有匹配结果.");
|
ret.append("没有匹配结果.");
|
||||||
return ret.toString();
|
return ret.toString();
|
||||||
}
|
}
|
||||||
@ -74,11 +130,9 @@ public class JsonParser {
|
|||||||
JSONArray words = joResult.getJSONArray("ws");
|
JSONArray words = joResult.getJSONArray("ws");
|
||||||
for (int i = 0; i < words.length(); i++) {
|
for (int i = 0; i < words.length(); i++) {
|
||||||
JSONArray items = words.getJSONObject(i).getJSONArray("cw");
|
JSONArray items = words.getJSONObject(i).getJSONArray("cw");
|
||||||
for(int j = 0; j < items.length(); j++)
|
for (int j = 0; j < items.length(); j++) {
|
||||||
{
|
|
||||||
JSONObject obj = items.getJSONObject(j);
|
JSONObject obj = items.getJSONObject(j);
|
||||||
if(obj.getString("w").contains("nomatch"))
|
if (obj.getString("w").contains("nomatch")) {
|
||||||
{
|
|
||||||
ret.append("没有匹配结果.");
|
ret.append("没有匹配结果.");
|
||||||
return ret.toString();
|
return ret.toString();
|
||||||
}
|
}
|
||||||
@ -95,13 +149,13 @@ public class JsonParser {
|
|||||||
return ret.toString();
|
return ret.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String parseTransResult(String json,String key) {
|
public static String parseTransResult(String json, String key) {
|
||||||
StringBuffer ret = new StringBuffer();
|
StringBuffer ret = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
JSONTokener tokener = new JSONTokener(json);
|
JSONTokener tokener = new JSONTokener(json);
|
||||||
JSONObject joResult = new JSONObject(tokener);
|
JSONObject joResult = new JSONObject(tokener);
|
||||||
String errorCode = joResult.optString("ret");
|
String errorCode = joResult.optString("ret");
|
||||||
if(!errorCode.equals("0")) {
|
if (!errorCode.equals("0")) {
|
||||||
return joResult.optString("errmsg");
|
return joResult.optString("errmsg");
|
||||||
}
|
}
|
||||||
JSONObject transResult = joResult.optJSONObject("trans_result");
|
JSONObject transResult = joResult.optJSONObject("trans_result");
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.iflytek.speech.util;
|
package com.iflytek.speech.util;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
@ -8,18 +7,20 @@ import android.text.TextUtils;
|
|||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输入框输入范围控制
|
* 输入框输入范围控制
|
||||||
*/
|
*/
|
||||||
public class SettingTextWatcher implements TextWatcher {
|
public class SettingTextWatcher implements TextWatcher {
|
||||||
private int editStart ;
|
private int editStart;
|
||||||
private int editCount ;
|
private int editCount;
|
||||||
private EditTextPreference mEditTextPreference;
|
private EditTextPreference mEditTextPreference;
|
||||||
int minValue;//最小值
|
int minValue;//最小值
|
||||||
int maxValue;//最大值
|
int maxValue;//最大值
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
public SettingTextWatcher(Context context,EditTextPreference e,int min, int max) {
|
public SettingTextWatcher(Context context, EditTextPreference e, int min, int max) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mEditTextPreference = e;
|
mEditTextPreference = e;
|
||||||
minValue = min;
|
minValue = min;
|
||||||
@ -34,7 +35,7 @@ public class SettingTextWatcher implements TextWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
// Log.e("demo", "beforeTextChanged start:"+start+" count:"+count+" after:"+after);
|
// Log.e("demo", "beforeTextChanged start:"+start+" count:"+count+" after:"+after);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,12 +49,12 @@ public class SettingTextWatcher implements TextWatcher {
|
|||||||
if (isNumeric(content)) {
|
if (isNumeric(content)) {
|
||||||
int num = Integer.parseInt(content);
|
int num = Integer.parseInt(content);
|
||||||
if (num > maxValue || num < minValue) {
|
if (num > maxValue || num < minValue) {
|
||||||
s.delete(editStart, editStart+editCount);
|
s.delete(editStart, editStart + editCount);
|
||||||
mEditTextPreference.getEditText().setText(s);
|
mEditTextPreference.getEditText().setText(s);
|
||||||
Toast.makeText(mContext, "超出有效值范围", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, "超出有效值范围", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
s.delete(editStart, editStart+editCount);
|
s.delete(editStart, editStart + editCount);
|
||||||
mEditTextPreference.getEditText().setText(s);
|
mEditTextPreference.getEditText().setText(s);
|
||||||
Toast.makeText(mContext, "只能输入数字哦", Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, "只能输入数字哦", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -62,7 +63,7 @@ public class SettingTextWatcher implements TextWatcher {
|
|||||||
/**
|
/**
|
||||||
* 正则表达式-判断是否为数字
|
* 正则表达式-判断是否为数字
|
||||||
*/
|
*/
|
||||||
public static boolean isNumeric(String str){
|
public static boolean isNumeric(String str) {
|
||||||
Pattern pattern = Pattern.compile("[0-9]*");
|
Pattern pattern = Pattern.compile("[0-9]*");
|
||||||
return pattern.matcher(str).matches();
|
return pattern.matcher(str).matches();
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
package com.iflytek.speech.util;
|
package com.iflytek.speech.util;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
/**
|
/**
|
||||||
* Xml结果解析类
|
* Xml结果解析类
|
||||||
*/
|
*/
|
||||||
public class XmlParser {
|
public class XmlParser {
|
||||||
|
|
||||||
public static String parseNluResult(String xml)
|
public static String parseNluResult(String xml) {
|
||||||
{
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// DOM builder
|
// DOM builder
|
||||||
DocumentBuilder domBuilder = null;
|
DocumentBuilder domBuilder = null;
|
||||||
// DOM doc
|
// DOM doc
|
||||||
@ -32,25 +31,24 @@ public class XmlParser {
|
|||||||
// 获取根节点
|
// 获取根节点
|
||||||
Element root = (Element) domDoc.getDocumentElement();
|
Element root = (Element) domDoc.getDocumentElement();
|
||||||
|
|
||||||
Element raw = (Element)root.getElementsByTagName("rawtext").item(0);
|
Element raw = (Element) root.getElementsByTagName("rawtext").item(0);
|
||||||
buffer.append("【识别结果】" + raw.getFirstChild().getNodeValue());
|
buffer.append("【识别结果】" + raw.getFirstChild().getNodeValue());
|
||||||
buffer.append("\n");
|
buffer.append("\n");
|
||||||
|
|
||||||
Element e = (Element)root.getElementsByTagName("result").item(0);
|
Element e = (Element) root.getElementsByTagName("result").item(0);
|
||||||
|
|
||||||
Element focus = (Element)e.getElementsByTagName("focus").item(0);
|
Element focus = (Element) e.getElementsByTagName("focus").item(0);
|
||||||
buffer.append("【FOCUS】" + focus.getFirstChild().getNodeValue());
|
buffer.append("【FOCUS】" + focus.getFirstChild().getNodeValue());
|
||||||
buffer.append("\n");
|
buffer.append("\n");
|
||||||
|
|
||||||
Element action = (Element)e.getElementsByTagName("action").item(0);
|
Element action = (Element) e.getElementsByTagName("action").item(0);
|
||||||
Element operation = (Element)action.getElementsByTagName("operation").item(0);
|
Element operation = (Element) action.getElementsByTagName("operation").item(0);
|
||||||
buffer.append("【ACTION】" + operation.getFirstChild().getNodeValue());
|
buffer.append("【ACTION】" + operation.getFirstChild().getNodeValue());
|
||||||
buffer.append("\n");
|
buffer.append("\n");
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
};
|
}
|
||||||
|
|
||||||
buffer.append("【ALL】" + xml);
|
buffer.append("【ALL】" + xml);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -5,21 +5,17 @@ import android.app.Activity;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioGroup;
|
|
||||||
import android.widget.RadioGroup.OnCheckedChangeListener;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.iflytek.cloud.ErrorCode;
|
import com.iflytek.cloud.ErrorCode;
|
||||||
import com.iflytek.cloud.GrammarListener;
|
import com.iflytek.cloud.GrammarListener;
|
||||||
import com.iflytek.cloud.InitListener;
|
import com.iflytek.cloud.InitListener;
|
||||||
import com.iflytek.cloud.LexiconListener;
|
|
||||||
import com.iflytek.cloud.RecognizerListener;
|
import com.iflytek.cloud.RecognizerListener;
|
||||||
import com.iflytek.cloud.RecognizerResult;
|
import com.iflytek.cloud.RecognizerResult;
|
||||||
import com.iflytek.cloud.SpeechConstant;
|
import com.iflytek.cloud.SpeechConstant;
|
||||||
@ -27,12 +23,11 @@ import com.iflytek.cloud.SpeechError;
|
|||||||
import com.iflytek.cloud.SpeechRecognizer;
|
import com.iflytek.cloud.SpeechRecognizer;
|
||||||
import com.iflytek.speech.util.FucUtil;
|
import com.iflytek.speech.util.FucUtil;
|
||||||
import com.iflytek.speech.util.JsonParser;
|
import com.iflytek.speech.util.JsonParser;
|
||||||
/*import com.iflytek.sunflower.FlowerCollector;*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 识别示例
|
* 识别示例
|
||||||
*/
|
*/
|
||||||
public class AsrDemo extends Activity implements OnClickListener{
|
public class AsrDemo extends Activity implements OnClickListener {
|
||||||
private static String TAG = AsrDemo.class.getSimpleName();
|
private static String TAG = AsrDemo.class.getSimpleName();
|
||||||
// 语音识别对象
|
// 语音识别对象
|
||||||
private SpeechRecognizer mAsr;
|
private SpeechRecognizer mAsr;
|
||||||
@ -57,11 +52,9 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
|
|
||||||
// 初始化识别对象
|
// 初始化识别对象
|
||||||
mAsr = SpeechRecognizer.createRecognizer(AsrDemo.this, mInitListener);
|
mAsr = SpeechRecognizer.createRecognizer(AsrDemo.this, mInitListener);
|
||||||
mCloudGrammar = FucUtil.readFile(this,"grammar_sample.abnf","utf-8");
|
mCloudGrammar = FucUtil.readFile(this, "grammar_sample.abnf", "utf-8");
|
||||||
|
|
||||||
mSharedPreferences = getSharedPreferences(getPackageName(), MODE_PRIVATE);
|
mSharedPreferences = getSharedPreferences(getPackageName(), MODE_PRIVATE);
|
||||||
mToast = Toast.makeText(this,"",Toast.LENGTH_SHORT);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,49 +69,47 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 语法、词典临时变量
|
// 语法、词典临时变量
|
||||||
String mContent;
|
private String mContent;
|
||||||
// 函数调用返回值
|
// 函数调用返回值
|
||||||
int ret = 0;
|
private int ret = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if( null == mAsr ){
|
if (null == mAsr) {
|
||||||
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
||||||
this.showTip( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
|
this.showTip("创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(null == mEngineType) {
|
if (null == mEngineType) {
|
||||||
showTip("请先选择识别引擎类型");
|
showTip("请先选择识别引擎类型");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(view.getId())
|
switch (view.getId()) {
|
||||||
{
|
|
||||||
case R.id.isr_grammar:
|
case R.id.isr_grammar:
|
||||||
showTip("上传预设关键词/语法文件");
|
showTip("上传预设关键词/语法文件");
|
||||||
// 在线-构建语法文件,生成语法id
|
// 在线-构建语法文件,生成语法id
|
||||||
((EditText)findViewById(R.id.isr_text)).setText(mCloudGrammar);
|
((EditText) findViewById(R.id.isr_text)).setText(mCloudGrammar);
|
||||||
mContent = new String(mCloudGrammar);
|
mContent = new String(mCloudGrammar);
|
||||||
//指定引擎类型
|
//指定引擎类型
|
||||||
mAsr.setParameter(SpeechConstant.ENGINE_TYPE, mEngineType);
|
mAsr.setParameter(SpeechConstant.ENGINE_TYPE, mEngineType);
|
||||||
mAsr.setParameter(SpeechConstant.TEXT_ENCODING,"utf-8");
|
mAsr.setParameter(SpeechConstant.TEXT_ENCODING, "utf-8");
|
||||||
ret = mAsr.buildGrammar(GRAMMAR_TYPE_ABNF, mContent, mCloudGrammarListener);
|
ret = mAsr.buildGrammar(GRAMMAR_TYPE_ABNF, mContent, mCloudGrammarListener);
|
||||||
if(ret != ErrorCode.SUCCESS)
|
if (ret != ErrorCode.SUCCESS) {
|
||||||
showTip("语法构建失败,错误码:" + ret+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("语法构建失败,错误码:" + ret + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
// 开始识别
|
// 开始识别
|
||||||
case R.id.isr_recognize:
|
case R.id.isr_recognize:
|
||||||
((EditText)findViewById(R.id.isr_text)).setText(null);// 清空显示内容
|
((EditText) findViewById(R.id.isr_text)).setText(null);// 清空显示内容
|
||||||
// 设置参数
|
// 设置参数
|
||||||
if (!setParam()) {
|
if (!setParam()) {
|
||||||
showTip("请先构建语法。");
|
showTip("请先构建语法。");
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
ret = mAsr.startListening(mRecognizerListener);
|
ret = mAsr.startListening(mRecognizerListener);
|
||||||
if (ret != ErrorCode.SUCCESS) {
|
if (ret != ErrorCode.SUCCESS) {
|
||||||
showTip("识别失败,错误码: " + ret+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("识别失败,错误码: " + ret + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// 停止识别
|
// 停止识别
|
||||||
@ -143,21 +134,7 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
public void onInit(int code) {
|
public void onInit(int code) {
|
||||||
Log.d(TAG, "SpeechRecognizer init() code = " + code);
|
Log.d(TAG, "SpeechRecognizer init() code = " + code);
|
||||||
if (code != ErrorCode.SUCCESS) {
|
if (code != ErrorCode.SUCCESS) {
|
||||||
showTip("初始化失败,错误码:"+code+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("初始化失败,错误码:" + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新词典监听器。
|
|
||||||
*/
|
|
||||||
private LexiconListener mLexiconListener = new LexiconListener() {
|
|
||||||
@Override
|
|
||||||
public void onLexiconUpdated(String lexiconId, SpeechError error) {
|
|
||||||
if(error == null){
|
|
||||||
showTip("词典更新成功");
|
|
||||||
}else{
|
|
||||||
showTip("词典更新失败,错误码:"+error.getErrorCode()+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -168,15 +145,15 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
private GrammarListener mCloudGrammarListener = new GrammarListener() {
|
private GrammarListener mCloudGrammarListener = new GrammarListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onBuildFinish(String grammarId, SpeechError error) {
|
public void onBuildFinish(String grammarId, SpeechError error) {
|
||||||
if(error == null){
|
if (error == null) {
|
||||||
String grammarID = new String(grammarId);
|
String grammarID = new String(grammarId);
|
||||||
Editor editor = mSharedPreferences.edit();
|
Editor editor = mSharedPreferences.edit();
|
||||||
if(!TextUtils.isEmpty(grammarId))
|
if (!TextUtils.isEmpty(grammarId))
|
||||||
editor.putString(KEY_GRAMMAR_ABNF_ID, grammarID);
|
editor.putString(KEY_GRAMMAR_ABNF_ID, grammarID);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
showTip("语法构建成功:" + grammarId);
|
showTip("语法构建成功:" + grammarId);
|
||||||
}else{
|
} else {
|
||||||
showTip("语法构建失败,错误码:" + error.getErrorCode()+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("语法构建失败,错误码:" + error.getErrorCode() + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -189,22 +166,22 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
@Override
|
@Override
|
||||||
public void onVolumeChanged(int volume, byte[] data) {
|
public void onVolumeChanged(int volume, byte[] data) {
|
||||||
showTip("当前正在说话,音量大小:" + volume);
|
showTip("当前正在说话,音量大小:" + volume);
|
||||||
Log.d(TAG, "返回音频数据:"+data.length);
|
Log.d(TAG, "返回音频数据:" + data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResult(final RecognizerResult result, boolean isLast) {
|
public void onResult(final RecognizerResult result, boolean isLast) {
|
||||||
if (null != result) {
|
if (null != result) {
|
||||||
Log.d(TAG, "recognizer result:" + result.getResultString());
|
Log.d(TAG, "recognizer result:" + result.getResultString());
|
||||||
String text ;
|
String text;
|
||||||
if("cloud".equalsIgnoreCase(mEngineType)){
|
if ("cloud".equalsIgnoreCase(mEngineType)) {
|
||||||
text = JsonParser.parseGrammarResult(result.getResultString());
|
text = JsonParser.parseGrammarResult(result.getResultString());
|
||||||
}else {
|
} else {
|
||||||
text = JsonParser.parseLocalGrammarResult(result.getResultString());
|
text = JsonParser.parseLocalGrammarResult(result.getResultString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示
|
// 显示
|
||||||
((EditText)findViewById(R.id.isr_text)).setText(text);
|
((EditText) findViewById(R.id.isr_text)).setText(text);
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "recognizer result : null");
|
Log.d(TAG, "recognizer result : null");
|
||||||
}
|
}
|
||||||
@ -240,12 +217,14 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void showTip(final String str) {
|
private void showTip(final String str) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mToast.setText(str);
|
if (mToast != null) {
|
||||||
|
mToast.cancel();
|
||||||
|
}
|
||||||
|
mToast = Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT);
|
||||||
mToast.show();
|
mToast.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -253,31 +232,30 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数设置
|
* 参数设置
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setParam(){
|
public boolean setParam() {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
//设置识别引擎
|
//设置识别引擎
|
||||||
mAsr.setParameter(SpeechConstant.ENGINE_TYPE, mEngineType);
|
mAsr.setParameter(SpeechConstant.ENGINE_TYPE, mEngineType);
|
||||||
//设置返回结果为json格式
|
//设置返回结果为json格式
|
||||||
mAsr.setParameter(SpeechConstant.RESULT_TYPE, "json");
|
mAsr.setParameter(SpeechConstant.RESULT_TYPE, "json");
|
||||||
|
|
||||||
if("cloud".equalsIgnoreCase(mEngineType))
|
if ("cloud".equalsIgnoreCase(mEngineType)) {
|
||||||
{
|
|
||||||
String grammarId = mSharedPreferences.getString(KEY_GRAMMAR_ABNF_ID, null);
|
String grammarId = mSharedPreferences.getString(KEY_GRAMMAR_ABNF_ID, null);
|
||||||
if(TextUtils.isEmpty(grammarId))
|
if (TextUtils.isEmpty(grammarId)) {
|
||||||
{
|
|
||||||
result = false;
|
result = false;
|
||||||
}else {
|
} else {
|
||||||
//设置云端识别使用的语法id
|
//设置云端识别使用的语法id
|
||||||
mAsr.setParameter(SpeechConstant.CLOUD_GRAMMAR, grammarId);
|
mAsr.setParameter(SpeechConstant.CLOUD_GRAMMAR, grammarId);
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 设置音频保存路径,保存音频格式支持pcm、wav,
|
||||||
// 设置音频保存路径,保存音频格式支持pcm、wav,设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
|
mAsr.setParameter(SpeechConstant.AUDIO_FORMAT, "wav");
|
||||||
mAsr.setParameter(SpeechConstant.AUDIO_FORMAT,"wav");
|
mAsr.setParameter(SpeechConstant.ASR_AUDIO_PATH,
|
||||||
mAsr.setParameter(SpeechConstant.ASR_AUDIO_PATH, Environment.getExternalStorageDirectory()+"/msc/asr.wav");
|
getExternalFilesDir("msc").getAbsolutePath() + "/asr.wav");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,27 +263,11 @@ public class AsrDemo extends Activity implements OnClickListener{
|
|||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
if( null != mAsr ){
|
if (null != mAsr) {
|
||||||
// 退出时释放连接
|
// 退出时释放连接
|
||||||
mAsr.cancel();
|
mAsr.cancel();
|
||||||
mAsr.destroy();
|
mAsr.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
//移动数据统计分析
|
|
||||||
/* FlowerCollector.onResume(AsrDemo.this);
|
|
||||||
FlowerCollector.onPageStart(TAG);*/
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
//移动数据统计分析
|
|
||||||
/*FlowerCollector.onPageEnd(TAG);
|
|
||||||
FlowerCollector.onPause(AsrDemo.this);*/
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
package com.iflytek.voicedemo;
|
package com.iflytek.voicedemo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -14,10 +7,6 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -36,12 +25,17 @@ import com.iflytek.cloud.SpeechError;
|
|||||||
import com.iflytek.cloud.SpeechRecognizer;
|
import com.iflytek.cloud.SpeechRecognizer;
|
||||||
import com.iflytek.cloud.ui.RecognizerDialog;
|
import com.iflytek.cloud.ui.RecognizerDialog;
|
||||||
import com.iflytek.cloud.ui.RecognizerDialogListener;
|
import com.iflytek.cloud.ui.RecognizerDialogListener;
|
||||||
import com.iflytek.cloud.util.ContactManager;
|
|
||||||
import com.iflytek.cloud.util.ContactManager.ContactListener;
|
|
||||||
import com.iflytek.speech.setting.IatSettings;
|
import com.iflytek.speech.setting.IatSettings;
|
||||||
import com.iflytek.speech.util.FucUtil;
|
import com.iflytek.speech.util.FucUtil;
|
||||||
import com.iflytek.speech.util.JsonParser;
|
import com.iflytek.speech.util.JsonParser;
|
||||||
/*import com.iflytek.sunflower.FlowerCollector;*/
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
public class IatDemo extends Activity implements OnClickListener {
|
public class IatDemo extends Activity implements OnClickListener {
|
||||||
private static String TAG = IatDemo.class.getSimpleName();
|
private static String TAG = IatDemo.class.getSimpleName();
|
||||||
@ -50,7 +44,7 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
// 语音听写UI
|
// 语音听写UI
|
||||||
private RecognizerDialog mIatDialog;
|
private RecognizerDialog mIatDialog;
|
||||||
// 用HashMap存储听写结果
|
// 用HashMap存储听写结果
|
||||||
private HashMap<String, String> mIatResults = new LinkedHashMap<String, String>();
|
private HashMap<String, String> mIatResults = new LinkedHashMap<>();
|
||||||
|
|
||||||
private EditText mResultText;
|
private EditText mResultText;
|
||||||
private EditText showContacts;
|
private EditText showContacts;
|
||||||
@ -60,31 +54,16 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
// 引擎类型
|
// 引擎类型
|
||||||
private String mEngineType = SpeechConstant.TYPE_CLOUD;
|
private String mEngineType = SpeechConstant.TYPE_CLOUD;
|
||||||
|
|
||||||
private String[] languageEntries ;
|
private String[] languageEntries;
|
||||||
private String[] languageValues;
|
private String[] languageValues;
|
||||||
private String language="zh_cn";
|
private String language = "zh_cn";
|
||||||
private int selectedNum=0;
|
private int selectedNum = 0;
|
||||||
|
|
||||||
private String resultType = "json";
|
private String resultType = "json";
|
||||||
|
|
||||||
private boolean cyclic = false;//音频流识别是否循环调用
|
|
||||||
|
|
||||||
private StringBuffer buffer = new StringBuffer();
|
private StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
Handler han = new Handler(){
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(Message msg) {
|
|
||||||
super.handleMessage(msg);
|
|
||||||
if (msg.what == 0x001) {
|
|
||||||
executeStream();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static int flg=0;
|
|
||||||
|
|
||||||
@SuppressLint("ShowToast")
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
@ -103,21 +82,17 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
mSharedPreferences = getSharedPreferences(IatSettings.PREFER_NAME,
|
mSharedPreferences = getSharedPreferences(IatSettings.PREFER_NAME,
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
|
|
||||||
mResultText = ((EditText) findViewById(R.id.iat_text));
|
mResultText = ((EditText) findViewById(R.id.iat_text));
|
||||||
showContacts = (EditText) findViewById(R.id.iat_contacts);
|
showContacts = (EditText) findViewById(R.id.iat_contacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化Layout。
|
* 初始化Layout。
|
||||||
*/
|
*/
|
||||||
private void initLayout() {
|
private void initLayout() {
|
||||||
findViewById(R.id.iat_recognize).setOnClickListener(IatDemo.this);
|
findViewById(R.id.iat_recognize).setOnClickListener(IatDemo.this);
|
||||||
findViewById(R.id.iat_recognize_stream).setOnClickListener(IatDemo.this);
|
findViewById(R.id.iat_recognize_stream).setOnClickListener(IatDemo.this);
|
||||||
findViewById(R.id.iat_upload_contacts).setOnClickListener(IatDemo.this);
|
|
||||||
findViewById(R.id.iat_upload_userwords).setOnClickListener(IatDemo.this);
|
findViewById(R.id.iat_upload_userwords).setOnClickListener(IatDemo.this);
|
||||||
findViewById(R.id.iat_stop).setOnClickListener(IatDemo.this);
|
findViewById(R.id.iat_stop).setOnClickListener(IatDemo.this);
|
||||||
findViewById(R.id.iat_cancel).setOnClickListener(IatDemo.this);
|
findViewById(R.id.iat_cancel).setOnClickListener(IatDemo.this);
|
||||||
@ -129,9 +104,9 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if( null == mIat ){
|
if (null == mIat) {
|
||||||
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
||||||
this.showTip( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
|
this.showTip("创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,9 +119,6 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
// 开始听写
|
// 开始听写
|
||||||
// 如何判断一次听写结束:OnResult isLast=true 或者 onError
|
// 如何判断一次听写结束:OnResult isLast=true 或者 onError
|
||||||
case R.id.iat_recognize:
|
case R.id.iat_recognize:
|
||||||
// 移动数据分析,收集开始听写事件
|
|
||||||
// FlowerCollector.onEvent(IatDemo.this, "iat_recognize");
|
|
||||||
|
|
||||||
buffer.setLength(0);
|
buffer.setLength(0);
|
||||||
mResultText.setText(null);// 清空显示内容
|
mResultText.setText(null);// 清空显示内容
|
||||||
mIatResults.clear();
|
mIatResults.clear();
|
||||||
@ -163,7 +135,7 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
// 不显示听写对话框
|
// 不显示听写对话框
|
||||||
ret = mIat.startListening(mRecognizerListener);
|
ret = mIat.startListening(mRecognizerListener);
|
||||||
if (ret != ErrorCode.SUCCESS) {
|
if (ret != ErrorCode.SUCCESS) {
|
||||||
showTip("听写失败,错误码:" + ret+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("听写失败,错误码:" + ret + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
} else {
|
} else {
|
||||||
showTip(getString(R.string.text_begin));
|
showTip(getString(R.string.text_begin));
|
||||||
}
|
}
|
||||||
@ -186,25 +158,16 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
mIat.cancel();
|
mIat.cancel();
|
||||||
showTip("取消听写");
|
showTip("取消听写");
|
||||||
break;
|
break;
|
||||||
// 上传联系人
|
|
||||||
case R.id.iat_upload_contacts:
|
|
||||||
showTip(getString(R.string.text_upload_contacts));
|
|
||||||
ContactManager mgr = ContactManager.createManager(IatDemo.this,
|
|
||||||
mContactListener);
|
|
||||||
mgr.asyncQueryAllContactsName();
|
|
||||||
break;
|
|
||||||
// 上传用户词表
|
// 上传用户词表
|
||||||
case R.id.iat_upload_userwords:
|
case R.id.iat_upload_userwords:
|
||||||
showTip(getString(R.string.text_upload_userwords));
|
String contents = FucUtil.readFile(IatDemo.this, "userwords", "utf-8");
|
||||||
String contents = FucUtil.readFile(IatDemo.this, "userwords","utf-8");
|
|
||||||
showContacts.setText(contents);
|
showContacts.setText(contents);
|
||||||
|
|
||||||
// 指定引擎类型
|
// 指定引擎类型
|
||||||
mIat.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
|
mIat.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
|
||||||
mIat.setParameter(SpeechConstant.TEXT_ENCODING, "utf-8");
|
mIat.setParameter(SpeechConstant.TEXT_ENCODING, "utf-8");
|
||||||
ret = mIat.updateLexicon("userword", contents, mLexiconListener);
|
ret = mIat.updateLexicon("userword", contents, mLexiconListener);
|
||||||
if (ret != ErrorCode.SUCCESS)
|
if (ret != ErrorCode.SUCCESS)
|
||||||
showTip("上传热词失败,错误码:" + ret+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("上传热词失败,错误码:" + ret + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -220,7 +183,7 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
public void onInit(int code) {
|
public void onInit(int code) {
|
||||||
Log.d(TAG, "SpeechRecognizer init() code = " + code);
|
Log.d(TAG, "SpeechRecognizer init() code = " + code);
|
||||||
if (code != ErrorCode.SUCCESS) {
|
if (code != ErrorCode.SUCCESS) {
|
||||||
showTip("初始化失败,错误码:" + code+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("初始化失败,错误码:" + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -234,9 +197,10 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
* <item>es_es</item> 西班牙语
|
* <item>es_es</item> 西班牙语
|
||||||
* <item>fr_fr</item> 法语
|
* <item>fr_fr</item> 法语
|
||||||
* <item>ko_kr</item> 韩语
|
* <item>ko_kr</item> 韩语
|
||||||
|
*
|
||||||
* @param v
|
* @param v
|
||||||
*/
|
*/
|
||||||
private void setLanguage(View v){
|
private void setLanguage(View v) {
|
||||||
new AlertDialog.Builder(v.getContext()).setTitle("语种语言种类")
|
new AlertDialog.Builder(v.getContext()).setTitle("语种语言种类")
|
||||||
.setSingleChoiceItems(languageEntries, // 单选框有几项,各是什么名字
|
.setSingleChoiceItems(languageEntries, // 单选框有几项,各是什么名字
|
||||||
0, // 默认的选项
|
0, // 默认的选项
|
||||||
@ -244,7 +208,7 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int which) { // 点击了哪一项
|
int which) { // 点击了哪一项
|
||||||
language = languageValues[which];
|
language = languageValues[which];
|
||||||
((TextView)findViewById(R.id.languageText)).setText("你选择的是:"+languageEntries[which]);
|
((TextView) findViewById(R.id.languageText)).setText("你选择的是:" + languageEntries[which]);
|
||||||
selectedNum = which;
|
selectedNum = which;
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
@ -282,7 +246,7 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
public void onError(SpeechError error) {
|
public void onError(SpeechError error) {
|
||||||
// Tips:
|
// Tips:
|
||||||
// 错误码:10118(您没有说话),可能是录音机权限被禁,需要提示用户打开应用的录音权限。
|
// 错误码:10118(您没有说话),可能是录音机权限被禁,需要提示用户打开应用的录音权限。
|
||||||
|
Log.d(TAG, "onError " + error.getPlainDescription(true));
|
||||||
showTip(error.getPlainDescription(true));
|
showTip(error.getPlainDescription(true));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -296,29 +260,23 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onResult(RecognizerResult results, boolean isLast) {
|
public void onResult(RecognizerResult results, boolean isLast) {
|
||||||
Log.d(TAG, results.getResultString());
|
Log.d(TAG, results.getResultString());
|
||||||
System.out.println(flg++);
|
if (isLast) {
|
||||||
|
Log.d(TAG, "onResult 结束");
|
||||||
|
}
|
||||||
if (resultType.equals("json")) {
|
if (resultType.equals("json")) {
|
||||||
|
|
||||||
printResult(results);
|
printResult(results);
|
||||||
|
return;
|
||||||
}else if(resultType.equals("plain")) {
|
}
|
||||||
|
if (resultType.equals("plain")) {
|
||||||
buffer.append(results.getResultString());
|
buffer.append(results.getResultString());
|
||||||
mResultText.setText(buffer.toString());
|
mResultText.setText(buffer.toString());
|
||||||
mResultText.setSelection(mResultText.length());
|
mResultText.setSelection(mResultText.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLast & cyclic) {
|
|
||||||
// TODO 最后的结果
|
|
||||||
Message message = Message.obtain();
|
|
||||||
message.what = 0x001;
|
|
||||||
han.sendMessageDelayed(message,100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onVolumeChanged(int volume, byte[] data) {
|
public void onVolumeChanged(int volume, byte[] data) {
|
||||||
showTip("当前正在说话,音量大小:" + volume);
|
showTip("当前正在说话,音量大小 = " + volume + " 返回音频数据 = " + data.length);
|
||||||
Log.d(TAG, "返回音频数据:"+data.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -332,9 +290,11 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示结果
|
||||||
|
*/
|
||||||
private void printResult(RecognizerResult results) {
|
private void printResult(RecognizerResult results) {
|
||||||
String text = JsonParser.parseIatResult(results.getResultString());
|
String text = JsonParser.parseIatResult(results.getResultString());
|
||||||
|
|
||||||
String sn = null;
|
String sn = null;
|
||||||
// 读取json结果中的sn字段
|
// 读取json结果中的sn字段
|
||||||
try {
|
try {
|
||||||
@ -350,7 +310,6 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
for (String key : mIatResults.keySet()) {
|
for (String key : mIatResults.keySet()) {
|
||||||
resultBuffer.append(mIatResults.get(key));
|
resultBuffer.append(mIatResults.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
mResultText.setText(resultBuffer.toString());
|
mResultText.setText(resultBuffer.toString());
|
||||||
mResultText.setSelection(mResultText.length());
|
mResultText.setSelection(mResultText.length());
|
||||||
}
|
}
|
||||||
@ -359,50 +318,24 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
* 听写UI监听器
|
* 听写UI监听器
|
||||||
*/
|
*/
|
||||||
private RecognizerDialogListener mRecognizerDialogListener = new RecognizerDialogListener() {
|
private RecognizerDialogListener mRecognizerDialogListener = new RecognizerDialogListener() {
|
||||||
|
// 返回结果
|
||||||
public void onResult(RecognizerResult results, boolean isLast) {
|
public void onResult(RecognizerResult results, boolean isLast) {
|
||||||
|
|
||||||
printResult(results);
|
printResult(results);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// 识别回调错误
|
||||||
* 识别回调错误.
|
|
||||||
*/
|
|
||||||
public void onError(SpeechError error) {
|
public void onError(SpeechError error) {
|
||||||
showTip(error.getPlainDescription(true));
|
showTip(error.getPlainDescription(true));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取联系人监听器。
|
|
||||||
*/
|
|
||||||
private ContactListener mContactListener = new ContactListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContactQueryFinish(final String contactInfos, boolean changeFlag) {
|
|
||||||
// 注:实际应用中除第一次上传之外,之后应该通过changeFlag判断是否需要上传,否则会造成不必要的流量.
|
|
||||||
// 每当联系人发生变化,该接口都将会被回调,可通过ContactManager.destroy()销毁对象,解除回调。
|
|
||||||
// if(changeFlag) {
|
|
||||||
// 指定引擎类型
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
showContacts.setText(contactInfos);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mIat.setParameter(SpeechConstant.ENGINE_TYPE,SpeechConstant.TYPE_CLOUD);
|
|
||||||
mIat.setParameter(SpeechConstant.TEXT_ENCODING, "utf-8");
|
|
||||||
ret = mIat.updateLexicon("contact", contactInfos, mLexiconListener);
|
|
||||||
if (ret != ErrorCode.SUCCESS) {
|
|
||||||
showTip("上传联系人失败:" + ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void showTip(final String str) {
|
private void showTip(final String str) {
|
||||||
mToast.setText(str);
|
if (mToast != null) {
|
||||||
|
mToast.cancel();
|
||||||
|
}
|
||||||
|
mToast = Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT);
|
||||||
mToast.show();
|
mToast.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,25 +347,23 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
public void setParam() {
|
public void setParam() {
|
||||||
// 清空参数
|
// 清空参数
|
||||||
mIat.setParameter(SpeechConstant.PARAMS, null);
|
mIat.setParameter(SpeechConstant.PARAMS, null);
|
||||||
|
|
||||||
// 设置听写引擎
|
// 设置听写引擎
|
||||||
mIat.setParameter(SpeechConstant.ENGINE_TYPE, mEngineType);
|
mIat.setParameter(SpeechConstant.ENGINE_TYPE, mEngineType);
|
||||||
// 设置返回结果格式
|
// 设置返回结果格式
|
||||||
mIat.setParameter(SpeechConstant.RESULT_TYPE, resultType);
|
mIat.setParameter(SpeechConstant.RESULT_TYPE, resultType);
|
||||||
|
|
||||||
|
if (language.equals("zh_cn")) {
|
||||||
if(language.equals("zh_cn")) {
|
|
||||||
String lag = mSharedPreferences.getString("iat_language_preference",
|
String lag = mSharedPreferences.getString("iat_language_preference",
|
||||||
"mandarin");
|
"mandarin");
|
||||||
Log.e(TAG,"language:"+language);// 设置语言
|
// 设置语言
|
||||||
|
Log.e(TAG, "language = " + language);
|
||||||
mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
|
mIat.setParameter(SpeechConstant.LANGUAGE, "zh_cn");
|
||||||
// 设置语言区域
|
// 设置语言区域
|
||||||
mIat.setParameter(SpeechConstant.ACCENT, lag);
|
mIat.setParameter(SpeechConstant.ACCENT, lag);
|
||||||
}else {
|
} else {
|
||||||
|
|
||||||
mIat.setParameter(SpeechConstant.LANGUAGE, language);
|
mIat.setParameter(SpeechConstant.LANGUAGE, language);
|
||||||
}
|
}
|
||||||
Log.e(TAG,"last language:"+mIat.getParameter(SpeechConstant.LANGUAGE));
|
Log.e(TAG, "last language:" + mIat.getParameter(SpeechConstant.LANGUAGE));
|
||||||
|
|
||||||
//此处用于设置dialog中不显示错误码信息
|
//此处用于设置dialog中不显示错误码信息
|
||||||
//mIat.setParameter("view_tips_plain","false");
|
//mIat.setParameter("view_tips_plain","false");
|
||||||
@ -446,39 +377,15 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
// 设置标点符号,设置为"0"返回结果无标点,设置为"1"返回结果有标点
|
// 设置标点符号,设置为"0"返回结果无标点,设置为"1"返回结果有标点
|
||||||
mIat.setParameter(SpeechConstant.ASR_PTT, mSharedPreferences.getString("iat_punc_preference", "1"));
|
mIat.setParameter(SpeechConstant.ASR_PTT, mSharedPreferences.getString("iat_punc_preference", "1"));
|
||||||
|
|
||||||
// 设置音频保存路径,保存音频格式支持pcm、wav,设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
|
// 设置音频保存路径,保存音频格式支持pcm、wav.
|
||||||
mIat.setParameter(SpeechConstant.AUDIO_FORMAT,"wav");
|
mIat.setParameter(SpeechConstant.AUDIO_FORMAT, "wav");
|
||||||
mIat.setParameter(SpeechConstant.ASR_AUDIO_PATH, Environment.getExternalStorageDirectory()+"/msc/iat.wav");
|
mIat.setParameter(SpeechConstant.ASR_AUDIO_PATH,
|
||||||
|
getExternalFilesDir("msc").getAbsolutePath() + "/iat.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
@Override
|
* 执行音频流识别操作
|
||||||
protected void onDestroy() {
|
*/
|
||||||
super.onDestroy();
|
|
||||||
|
|
||||||
if( null != mIat ){
|
|
||||||
// 退出时释放连接
|
|
||||||
mIat.cancel();
|
|
||||||
mIat.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
// 开放统计 移动数据统计分析
|
|
||||||
/*FlowerCollector.onResume(IatDemo.this);
|
|
||||||
FlowerCollector.onPageStart(TAG);*/
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
// 开放统计 移动数据统计分析
|
|
||||||
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
//执行音频流识别操作
|
|
||||||
private void executeStream() {
|
private void executeStream() {
|
||||||
buffer.setLength(0);
|
buffer.setLength(0);
|
||||||
mResultText.setText(null);// 清空显示内容
|
mResultText.setText(null);// 清空显示内容
|
||||||
@ -489,36 +396,33 @@ public class IatDemo extends Activity implements OnClickListener {
|
|||||||
mIat.setParameter(SpeechConstant.AUDIO_SOURCE, "-1");
|
mIat.setParameter(SpeechConstant.AUDIO_SOURCE, "-1");
|
||||||
// 也可以像以下这样直接设置音频文件路径识别(要求设置文件在sdcard上的全路径):
|
// 也可以像以下这样直接设置音频文件路径识别(要求设置文件在sdcard上的全路径):
|
||||||
// mIat.setParameter(SpeechConstant.AUDIO_SOURCE, "-2");
|
// mIat.setParameter(SpeechConstant.AUDIO_SOURCE, "-2");
|
||||||
//mIat.setParameter(SpeechConstant.ASR_SOURCE_PATH, "sdcard/XXX/XXX.pcm");
|
// mIat.setParameter(SpeechConstant.ASR_SOURCE_PATH, "sdcard/XXX/XXX.pcm");
|
||||||
ret = mIat.startListening(mRecognizerListener);
|
ret = mIat.startListening(mRecognizerListener);
|
||||||
if (ret != ErrorCode.SUCCESS) {
|
if (ret != ErrorCode.SUCCESS) {
|
||||||
showTip("识别失败,错误码:" + ret+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("识别失败,错误码:" + ret + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
} else {
|
return;
|
||||||
byte[] audioData = FucUtil.readAudioFile(IatDemo.this, "iattest.wav");
|
|
||||||
|
|
||||||
if (null != audioData) {
|
|
||||||
showTip(getString(R.string.text_begin_recognizer));
|
|
||||||
// 一次(也可以分多次)写入音频文件数据,数据格式必须是采样率为8KHz或16KHz(本地识别只支持16K采样率,云端都支持),
|
|
||||||
// 位长16bit,单声道的wav或者pcm
|
|
||||||
// 写入8KHz采样的音频时,必须先调用setParameter(SpeechConstant.SAMPLE_RATE, "8000")设置正确的采样率
|
|
||||||
// 注:当音频过长,静音部分时长超过VAD_EOS将导致静音后面部分不能识别。
|
|
||||||
ArrayList<byte[]> bytes = FucUtil.splitBuffer(audioData,audioData.length,audioData.length/3);
|
|
||||||
for(int i=0;i<bytes.size();i++) {
|
|
||||||
mIat.writeAudio(bytes.get(i), 0, bytes.get(i).length );
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}catch(Exception e){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
InputStream open = getAssets().open("iattest.wav");
|
||||||
|
byte[] buff = new byte[1280];
|
||||||
|
while (open.available() > 0) {
|
||||||
|
int read = open.read(buff);
|
||||||
|
mIat.writeAudio(buff, 0, read);
|
||||||
}
|
}
|
||||||
mIat.stopListening();
|
mIat.stopListening();
|
||||||
/*mIat.writeAudio(audioData, 0, audioData.length );
|
} catch (IOException e) {
|
||||||
mIat.stopListening();*/
|
|
||||||
} else {
|
|
||||||
mIat.cancel();
|
mIat.cancel();
|
||||||
showTip("读取音频流失败");
|
showTip("读取音频流失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (mIat != null) {
|
||||||
|
// 退出时释放连接
|
||||||
|
mIat.cancel();
|
||||||
|
mIat.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import android.media.ExifInterface;
|
|||||||
import android.media.MediaScannerConnection;
|
import android.media.MediaScannerConnection;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@ -32,9 +31,7 @@ import com.iflytek.cloud.IdentityVerifier;
|
|||||||
import com.iflytek.cloud.InitListener;
|
import com.iflytek.cloud.InitListener;
|
||||||
import com.iflytek.cloud.SpeechConstant;
|
import com.iflytek.cloud.SpeechConstant;
|
||||||
import com.iflytek.cloud.SpeechError;
|
import com.iflytek.cloud.SpeechError;
|
||||||
import com.iflytek.speech.util.FaceUtil;
|
|
||||||
import com.iflytek.voicedemo.R;
|
import com.iflytek.voicedemo.R;
|
||||||
import com.iflytek.voicedemo.faceonline.OnlineFaceDemo;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -51,7 +48,7 @@ import java.io.IOException;
|
|||||||
* @author hjyu
|
* @author hjyu
|
||||||
* @date 2017/9/28.
|
* @date 2017/9/28.
|
||||||
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
||||||
* */
|
*/
|
||||||
public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
||||||
private final static String TAG = FaceIdentifyActivity.class.getSimpleName();
|
private final static String TAG = FaceIdentifyActivity.class.getSimpleName();
|
||||||
|
|
||||||
@ -91,7 +88,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
if (ErrorCode.SUCCESS == errorCode) {
|
if (ErrorCode.SUCCESS == errorCode) {
|
||||||
showTip("引擎初始化成功");
|
showTip("引擎初始化成功");
|
||||||
} else {
|
} else {
|
||||||
showTip("引擎初始化失败,错误码:" + errorCode+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("引擎初始化失败,错误码:" + errorCode + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -104,7 +101,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
findViewById(R.id.online_pick).setOnClickListener(FaceIdentifyActivity.this);
|
findViewById(R.id.online_pick).setOnClickListener(FaceIdentifyActivity.this);
|
||||||
findViewById(R.id.online_camera).setOnClickListener(FaceIdentifyActivity.this);
|
findViewById(R.id.online_camera).setOnClickListener(FaceIdentifyActivity.this);
|
||||||
findViewById(R.id.btn_identity).setOnClickListener(FaceIdentifyActivity.this);
|
findViewById(R.id.btn_identity).setOnClickListener(FaceIdentifyActivity.this);
|
||||||
txt_groupid = (TextView)findViewById(R.id.txt_groupid);
|
txt_groupid = (TextView) findViewById(R.id.txt_groupid);
|
||||||
mProDialog = new ProgressDialog(FaceIdentifyActivity.this);
|
mProDialog = new ProgressDialog(FaceIdentifyActivity.this);
|
||||||
mProDialog.setCancelable(true);
|
mProDialog.setCancelable(true);
|
||||||
mProDialog.setTitle("请稍候");
|
mProDialog.setTitle("请稍候");
|
||||||
@ -120,7 +117,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mToast = Toast.makeText(FaceIdentifyActivity.this, "", Toast.LENGTH_SHORT);
|
mToast = Toast.makeText(FaceIdentifyActivity.this, "", Toast.LENGTH_SHORT);
|
||||||
mToast.setGravity(Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
|
mToast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
|
||||||
|
|
||||||
txt_groupid.setText(mGroupId);
|
txt_groupid.setText(mGroupId);
|
||||||
}
|
}
|
||||||
@ -154,9 +151,9 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if( null == mIdVerifier ){
|
if (null == mIdVerifier) {
|
||||||
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
||||||
showTip( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
|
showTip("创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,8 +168,8 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
case R.id.online_camera:
|
case R.id.online_camera:
|
||||||
// 设置相机拍照后照片保存路径
|
// 设置相机拍照后照片保存路径
|
||||||
mPictureFile = new File(Environment.getExternalStorageDirectory(),
|
mPictureFile = new File(getExternalFilesDir("msc").getAbsolutePath(),
|
||||||
"picture" + System.currentTimeMillis()/1000 + ".jpg");
|
"picture" + System.currentTimeMillis() / 1000 + ".jpg");
|
||||||
// 启动拍照,并保存到临时文件
|
// 启动拍照,并保存到临时文件
|
||||||
Intent mIntent = new Intent();
|
Intent mIntent = new Intent();
|
||||||
mIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
|
mIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
@ -196,7 +193,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
// 子业务执行参数,若无可以传空字符传
|
// 子业务执行参数,若无可以传空字符传
|
||||||
StringBuffer params = new StringBuffer();
|
StringBuffer params = new StringBuffer();
|
||||||
params.append(",group_id=" + mGroupId +",topc=3");
|
params.append(",group_id=" + mGroupId + ",topc=3");
|
||||||
// 向子业务写入数据,人脸数据可以一次写入
|
// 向子业务写入数据,人脸数据可以一次写入
|
||||||
mIdVerifier.writeData("ifr", params.toString(), mImageData, 0, mImageData.length);
|
mIdVerifier.writeData("ifr", params.toString(), mImageData, 0, mImageData.length);
|
||||||
// 写入完毕
|
// 写入完毕
|
||||||
@ -218,15 +215,13 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
try {
|
try {
|
||||||
String resultStr = result.getResultString();
|
String resultStr = result.getResultString();
|
||||||
JSONObject resultJson = new JSONObject(resultStr);
|
JSONObject resultJson = new JSONObject(resultStr);
|
||||||
if(ErrorCode.SUCCESS == resultJson.getInt("ret"))
|
if (ErrorCode.SUCCESS == resultJson.getInt("ret")) {
|
||||||
{
|
|
||||||
// 跳转到结果展示页面
|
// 跳转到结果展示页面
|
||||||
Intent intent = new Intent(FaceIdentifyActivity.this, ResultIdentifyActivity.class);
|
Intent intent = new Intent(FaceIdentifyActivity.this, ResultIdentifyActivity.class);
|
||||||
intent.putExtra("result", resultStr);
|
intent.putExtra("result", resultStr);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
showTip("鉴别失败!");
|
showTip("鉴别失败!");
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -241,7 +236,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String fileSrc = null;
|
String fileSrc = null;
|
||||||
if (requestCode == REQUEST_PICTURE_CHOOSE ) {
|
if (requestCode == REQUEST_PICTURE_CHOOSE) {
|
||||||
if ("file".equals(data.getData().getScheme())) {
|
if ("file".equals(data.getData().getScheme())) {
|
||||||
// 有些低版本机型返回的Uri模式为file
|
// 有些低版本机型返回的Uri模式为file
|
||||||
fileSrc = data.getData().getPath();
|
fileSrc = data.getData().getPath();
|
||||||
@ -256,7 +251,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
// 跳转到图片裁剪页面
|
// 跳转到图片裁剪页面
|
||||||
cropPicture(this,Uri.fromFile(new File(fileSrc)));
|
cropPicture(this, Uri.fromFile(new File(fileSrc)));
|
||||||
} else if (requestCode == REQUEST_CAMERA_IMAGE) {
|
} else if (requestCode == REQUEST_CAMERA_IMAGE) {
|
||||||
if (null == mPictureFile) {
|
if (null == mPictureFile) {
|
||||||
showTip("拍照失败,请重试");
|
showTip("拍照失败,请重试");
|
||||||
@ -266,7 +261,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
fileSrc = mPictureFile.getAbsolutePath();
|
fileSrc = mPictureFile.getAbsolutePath();
|
||||||
updateGallery(fileSrc);
|
updateGallery(fileSrc);
|
||||||
// 跳转到图片裁剪页面
|
// 跳转到图片裁剪页面
|
||||||
cropPicture(this,Uri.fromFile(new File(fileSrc)));
|
cropPicture(this, Uri.fromFile(new File(fileSrc)));
|
||||||
} else if (requestCode == REQUEST_INTENT_CROP) {
|
} else if (requestCode == REQUEST_INTENT_CROP) {
|
||||||
|
|
||||||
// 获取返回数据
|
// 获取返回数据
|
||||||
@ -276,7 +271,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
fileSrc = getImagePath();
|
fileSrc = getImagePath();
|
||||||
|
|
||||||
// 若返回数据不为null,保存至本地,防止裁剪时未能正常保存
|
// 若返回数据不为null,保存至本地,防止裁剪时未能正常保存
|
||||||
if(null != bmp){
|
if (null != bmp) {
|
||||||
saveBitmapToFile(bmp);
|
saveBitmapToFile(bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +288,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
mImageBitmap = BitmapFactory.decodeFile(fileSrc, options);
|
mImageBitmap = BitmapFactory.decodeFile(fileSrc, options);
|
||||||
|
|
||||||
// 若mImageBitmap为空则图片信息不能正常获取
|
// 若mImageBitmap为空则图片信息不能正常获取
|
||||||
if(null == mImageBitmap) {
|
if (null == mImageBitmap) {
|
||||||
showTip("图片信息无法正常获取!");
|
showTip("图片信息无法正常获取!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -365,7 +360,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateGallery(String filename) {
|
private void updateGallery(String filename) {
|
||||||
MediaScannerConnection.scanFile(this, new String[] {filename}, null,
|
MediaScannerConnection.scanFile(this, new String[]{filename}, null,
|
||||||
new MediaScannerConnection.OnScanCompletedListener() {
|
new MediaScannerConnection.OnScanCompletedListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -394,6 +389,7 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Toast弹出提示
|
* Toast弹出提示
|
||||||
|
*
|
||||||
* @param str
|
* @param str
|
||||||
*/
|
*/
|
||||||
private void showTip(final String str) {
|
private void showTip(final String str) {
|
||||||
@ -426,27 +422,25 @@ public class FaceIdentifyActivity extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置保存图片路径
|
* 设置保存图片路径
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private String getImagePath(){
|
private String getImagePath() {
|
||||||
String path;
|
String path = getExternalFilesDir("msc_face").getAbsolutePath() + "/MFVDemo";
|
||||||
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() +"/MFVDemo/";
|
|
||||||
File folder = new File(path);
|
File folder = new File(path);
|
||||||
if (folder != null && !folder.exists()) {
|
if (!folder.exists()) {
|
||||||
folder.mkdirs();
|
folder.mkdirs();
|
||||||
}
|
}
|
||||||
path += "mfvtest.jpg";
|
path += "/mfvtest.jpg";
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存Bitmap至本地
|
* 保存Bitmap至本地
|
||||||
|
*
|
||||||
* @param bmp
|
* @param bmp
|
||||||
*/
|
*/
|
||||||
private void saveBitmapToFile(Bitmap bmp){
|
private void saveBitmapToFile(Bitmap bmp) {
|
||||||
String file_path = getImagePath();
|
String file_path = getImagePath();
|
||||||
File file = new File(file_path);
|
File file = new File(file_path);
|
||||||
FileOutputStream fOut;
|
FileOutputStream fOut;
|
||||||
|
@ -41,16 +41,16 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* 声纹密码和人脸识别相关组操作
|
* 声纹密码和人脸识别相关组操作
|
||||||
* 支持组创建/添加成员/查询组成员/删除成员/删除组/
|
* 支持组创建/添加成员/查询组成员/删除成员/删除组/
|
||||||
|
*
|
||||||
|
* @author hjyu
|
||||||
|
* @date 2017/9/28.
|
||||||
* @see this#createGroup()
|
* @see this#createGroup()
|
||||||
* @see this#joinGroup(String)
|
* @see this#joinGroup(String)
|
||||||
* @see //this#queryGroups()
|
* @see //this#queryGroups()
|
||||||
* @see this#deleteGroup(String, boolean) ,第二个参数用于标示删除组成员or组
|
* @see this#deleteGroup(String, boolean) ,第二个参数用于标示删除组成员or组
|
||||||
*
|
|
||||||
* @author hjyu
|
|
||||||
* @date 2017/9/28.
|
|
||||||
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
||||||
*/
|
*/
|
||||||
public class GroupManagerActivity extends Activity implements OnClickListener ,AdapterView.OnItemClickListener {
|
public class GroupManagerActivity extends Activity implements OnClickListener, AdapterView.OnItemClickListener {
|
||||||
private final static String TAG = GroupManagerActivity.class.getSimpleName();
|
private final static String TAG = GroupManagerActivity.class.getSimpleName();
|
||||||
// 身份验证对象
|
// 身份验证对象
|
||||||
private IdentityVerifier mIdVerifier;
|
private IdentityVerifier mIdVerifier;
|
||||||
@ -64,7 +64,7 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
private ProgressDialog mProDialog;
|
private ProgressDialog mProDialog;
|
||||||
String authId;
|
String authId;
|
||||||
String mfv_type;
|
String mfv_type;
|
||||||
ArrayList<Map<String,String>> mList;
|
ArrayList<Map<String, String>> mList;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -135,15 +135,15 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
list.setDivider(null);
|
list.setDivider(null);
|
||||||
|
|
||||||
// 添加并且显示
|
// 添加并且显示
|
||||||
adapter = new MyAdapter(this, mList );
|
adapter = new MyAdapter(this, mList);
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if( null == mIdVerifier ){
|
if (null == mIdVerifier) {
|
||||||
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
||||||
showTip( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
|
showTip("创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,14 +168,10 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Intent init = new Intent();
|
Intent init = new Intent();
|
||||||
Map<String,String> map = (Map<String,String>)parent.getAdapter().getItem(position);
|
Map<String, String> map = (Map<String, String>) parent.getAdapter().getItem(position);
|
||||||
|
|
||||||
init.putExtra("group_id",map.get("group_id"));
|
init.putExtra("group_id", map.get("group_id"));
|
||||||
if (mfv_type.equals("ivp")) {
|
init.setClass(GroupManagerActivity.this, FaceIdentifyActivity.class);
|
||||||
init.setClass(GroupManagerActivity.this,VocalIdentifyActivity.class);
|
|
||||||
}else {
|
|
||||||
init.setClass(GroupManagerActivity.this,FaceIdentifyActivity.class);
|
|
||||||
}
|
|
||||||
startActivity(init);
|
startActivity(init);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,12 +320,12 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
|
|
||||||
// 设置模型参数,若无可以传空字符传
|
// 设置模型参数,若无可以传空字符传
|
||||||
StringBuffer params2 = new StringBuffer();
|
StringBuffer params2 = new StringBuffer();
|
||||||
if(deleteGroup) {
|
if (deleteGroup) {
|
||||||
params2.append("scope=group");
|
params2.append("scope=group");
|
||||||
} else {
|
} else {
|
||||||
// 删除组中指定auth_id用户
|
// 删除组中指定auth_id用户
|
||||||
params2.append("scope=person");
|
params2.append("scope=person");
|
||||||
params2.append(",auth_id="+authId);
|
params2.append(",auth_id=" + authId);
|
||||||
}
|
}
|
||||||
params2.append(",group_id=" + groupId);
|
params2.append(",group_id=" + groupId);
|
||||||
// 执行模型操作
|
// 执行模型操作
|
||||||
@ -378,17 +374,17 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
try {
|
try {
|
||||||
JSONObject resObj = new JSONObject(result.getResultString());
|
JSONObject resObj = new JSONObject(result.getResultString());
|
||||||
// 保存到用户信息中,用来显示用户加人的组
|
// 保存到用户信息中,用来显示用户加人的组
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("group_name",resObj.getString("group_name"));
|
map.put("group_name", resObj.getString("group_name"));
|
||||||
map.put("group_id",resObj.getString("group_id"));
|
map.put("group_id", resObj.getString("group_id"));
|
||||||
synchronized (mList) {
|
synchronized (mList) {
|
||||||
if (mList != null && mList.size() >0) {
|
if (mList != null && mList.size() > 0) {
|
||||||
for(int i = 0;i<mList.size();i++) {
|
for (int i = 0; i < mList.size(); i++) {
|
||||||
if(!mList.contains(map)) {
|
if (!mList.contains(map)) {
|
||||||
mList.add(map);
|
mList.add(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
mList.add(map);
|
mList.add(map);
|
||||||
}
|
}
|
||||||
mList.notify();
|
mList.notify();
|
||||||
@ -421,10 +417,12 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
showTip("查询成功");
|
showTip("查询成功");
|
||||||
stopProgress();
|
stopProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(int eventType, int arg1, int arg2, Bundle obj) {
|
public void onEvent(int eventType, int arg1, int arg2, Bundle obj) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(SpeechError error) {
|
public void onError(SpeechError error) {
|
||||||
Log.d(TAG, error.getPlainDescription(true));
|
Log.d(TAG, error.getPlainDescription(true));
|
||||||
@ -439,20 +437,20 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
Log.d(TAG, result.getResultString());
|
Log.d(TAG, result.getResultString());
|
||||||
try {
|
try {
|
||||||
JSONObject resObj = new JSONObject(result.getResultString());
|
JSONObject resObj = new JSONObject(result.getResultString());
|
||||||
Log.d(TAG,"resObj == "+resObj.toString());
|
Log.d(TAG, "resObj == " + resObj.toString());
|
||||||
int ret = resObj.getInt("ret");
|
int ret = resObj.getInt("ret");
|
||||||
if(0 != ret) {
|
if (0 != ret) {
|
||||||
onError(new SpeechError(ret));
|
onError(new SpeechError(ret));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if(result.getResultString().contains("user")) {
|
if (result.getResultString().contains("user")) {
|
||||||
String user = resObj.getString("user");
|
String user = resObj.getString("user");
|
||||||
showTip("删除组成员"+user+"成功");
|
showTip("删除组成员" + user + "成功");
|
||||||
} else {
|
} else {
|
||||||
showTip("删除组成功");
|
showTip("删除组成功");
|
||||||
// 保存到用户信息中,用来显示用户加人的组
|
// 保存到用户信息中,用来显示用户加人的组
|
||||||
for (Map<String,String> map1:mList){
|
for (Map<String, String> map1 : mList) {
|
||||||
if (map1.get("group_id").equals(resObj.getString("group_id"))){
|
if (map1.get("group_id").equals(resObj.getString("group_id"))) {
|
||||||
mList.remove(map1);
|
mList.remove(map1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,9 +486,9 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
public ArrayList<Map<String,String>> arr;
|
public ArrayList<Map<String, String>> arr;
|
||||||
|
|
||||||
public MyAdapter(Context context, ArrayList<Map<String,String>> array) {
|
public MyAdapter(Context context, ArrayList<Map<String, String>> array) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
inflater = LayoutInflater.from(context);
|
inflater = LayoutInflater.from(context);
|
||||||
@ -518,7 +516,7 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
return arg0;
|
return arg0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArray(ArrayList<Map<String,String>> list) {
|
public void setArray(ArrayList<Map<String, String>> list) {
|
||||||
this.arr = list;
|
this.arr = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,8 +526,8 @@ public class GroupManagerActivity extends Activity implements OnClickListener ,A
|
|||||||
view = inflater.inflate(R.layout.item_group, null);
|
view = inflater.inflate(R.layout.item_group, null);
|
||||||
}
|
}
|
||||||
final TextView edit = (TextView) view.findViewById(R.id.group_item_content);
|
final TextView edit = (TextView) view.findViewById(R.id.group_item_content);
|
||||||
Map<String,String> map2 = arr.get(arr.size() - position - 1);
|
Map<String, String> map2 = arr.get(arr.size() - position - 1);
|
||||||
edit.setText(map2.get("group_id")+"("+map2.get("group_name")+")"); // 在重构adapter的时候不至于数据错乱
|
edit.setText(map2.get("group_id") + "(" + map2.get("group_name") + ")"); // 在重构adapter的时候不至于数据错乱
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import java.text.DecimalFormat;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 1:N检测结果解析界面
|
* 1:N检测结果解析界面
|
||||||
|
*
|
||||||
* @author hjyu
|
* @author hjyu
|
||||||
* @date 2017/9/28.
|
* @date 2017/9/28.
|
||||||
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
||||||
@ -65,7 +66,7 @@ public class ResultIdentifyActivity extends Activity implements OnClickListener
|
|||||||
try {
|
try {
|
||||||
JSONObject obj = new JSONObject(result);
|
JSONObject obj = new JSONObject(result);
|
||||||
// 组名称
|
// 组名称
|
||||||
((TextView)findViewById(R.id.txt_group_name)).setText(obj.getString("group_name"));
|
((TextView) findViewById(R.id.txt_group_name)).setText(obj.getString("group_name"));
|
||||||
|
|
||||||
JSONObject ifv_result = obj.getJSONObject("ifv_result");
|
JSONObject ifv_result = obj.getJSONObject("ifv_result");
|
||||||
candidates = ifv_result.getJSONArray("candidates");
|
candidates = ifv_result.getJSONArray("candidates");
|
||||||
@ -143,8 +144,8 @@ public class ResultIdentifyActivity extends Activity implements OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getChineseNumber(int number) {
|
private String getChineseNumber(int number) {
|
||||||
String[] str = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
|
String[] str = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
|
||||||
String ss[] = new String[] { "", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿" };
|
String ss[] = new String[]{"", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿"};
|
||||||
String s = String.valueOf(number);
|
String s = String.valueOf(number);
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
for (int i = 0; i < s.length(); i++) {
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
@ -1,31 +1,30 @@
|
|||||||
package com.iflytek.voicedemo;
|
package com.iflytek.voicedemo;
|
||||||
|
|
||||||
import com.iflytek.cloud.ErrorCode;
|
|
||||||
import com.iflytek.ise.result.Result;
|
|
||||||
import com.iflytek.ise.result.xml.XmlResultParser;
|
|
||||||
import com.iflytek.speech.setting.IseSettings;
|
|
||||||
import com.iflytek.speech.util.FucUtil;
|
|
||||||
/*import com.iflytek.sunflower.FlowerCollector;*/
|
|
||||||
import com.iflytek.cloud.EvaluatorListener;
|
|
||||||
import com.iflytek.cloud.EvaluatorResult;
|
|
||||||
import com.iflytek.cloud.SpeechConstant;
|
|
||||||
import com.iflytek.cloud.SpeechError;
|
|
||||||
import com.iflytek.cloud.SpeechEvaluator;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.iflytek.cloud.EvaluatorListener;
|
||||||
|
import com.iflytek.cloud.EvaluatorResult;
|
||||||
|
import com.iflytek.cloud.SpeechConstant;
|
||||||
|
import com.iflytek.cloud.SpeechError;
|
||||||
|
import com.iflytek.cloud.SpeechEvaluator;
|
||||||
|
import com.iflytek.ise.result.Result;
|
||||||
|
import com.iflytek.ise.result.xml.XmlResultParser;
|
||||||
|
import com.iflytek.speech.setting.IseSettings;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 语音评测demo
|
* 语音评测demo
|
||||||
*/
|
*/
|
||||||
@ -36,7 +35,7 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
private final static int REQUEST_CODE_SETTINGS = 1;
|
private final static int REQUEST_CODE_SETTINGS = 1;
|
||||||
|
|
||||||
private EditText mEvaTextEditText;
|
private EditText mEvaTextEditText;
|
||||||
private EditText mResultEditText;
|
private TextView mResultEditText;
|
||||||
private Button mIseStartButton;
|
private Button mIseStartButton;
|
||||||
private Toast mToast;
|
private Toast mToast;
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(result.getResultString());
|
builder.append(result.getResultString());
|
||||||
|
|
||||||
if(!TextUtils.isEmpty(builder)) {
|
if (!TextUtils.isEmpty(builder)) {
|
||||||
mResultEditText.setText(builder.toString());
|
mResultEditText.setText(builder.toString());
|
||||||
}
|
}
|
||||||
mIseStartButton.setEnabled(true);
|
mIseStartButton.setEnabled(true);
|
||||||
@ -75,8 +74,8 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onError(SpeechError error) {
|
public void onError(SpeechError error) {
|
||||||
mIseStartButton.setEnabled(true);
|
mIseStartButton.setEnabled(true);
|
||||||
if(error != null) {
|
if (error != null) {
|
||||||
showTip("error:"+ error.getErrorCode() + "," + error.getErrorDescription());
|
showTip("error:" + error.getErrorCode() + "," + error.getErrorDescription());
|
||||||
mResultEditText.setText("");
|
mResultEditText.setText("");
|
||||||
mResultEditText.setHint("请点击“开始评测”按钮");
|
mResultEditText.setHint("请点击“开始评测”按钮");
|
||||||
} else {
|
} else {
|
||||||
@ -99,7 +98,7 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onVolumeChanged(int volume, byte[] data) {
|
public void onVolumeChanged(int volume, byte[] data) {
|
||||||
showTip("当前音量:" + volume);
|
showTip("当前音量:" + volume);
|
||||||
Log.d(TAG, "返回音频数据:"+data.length);
|
Log.d(TAG, "返回音频数据:" + data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -127,7 +126,7 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
private void initUI() {
|
private void initUI() {
|
||||||
findViewById(R.id.image_ise_set).setOnClickListener(IseDemo.this);
|
findViewById(R.id.image_ise_set).setOnClickListener(IseDemo.this);
|
||||||
mEvaTextEditText = (EditText) findViewById(R.id.ise_eva_text);
|
mEvaTextEditText = (EditText) findViewById(R.id.ise_eva_text);
|
||||||
mResultEditText = (EditText)findViewById(R.id.ise_result_text);
|
mResultEditText = (TextView) findViewById(R.id.ise_result_text);
|
||||||
mIseStartButton = (Button) findViewById(R.id.ise_start);
|
mIseStartButton = (Button) findViewById(R.id.ise_start);
|
||||||
mIseStartButton.setOnClickListener(IseDemo.this);
|
mIseStartButton.setOnClickListener(IseDemo.this);
|
||||||
findViewById(R.id.ise_parse).setOnClickListener(IseDemo.this);
|
findViewById(R.id.ise_parse).setOnClickListener(IseDemo.this);
|
||||||
@ -139,9 +138,9 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if( null == mIse ){
|
if (null == mIse) {
|
||||||
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
||||||
this.showTip( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
|
this.showTip("创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +185,16 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
case R.id.ise_parse:
|
case R.id.ise_parse:
|
||||||
// 解析最终结果
|
// 解析最终结果
|
||||||
if (!TextUtils.isEmpty(mLastResult)) {
|
if (!TextUtils.isEmpty(mLastResult)) {
|
||||||
|
// 拦截不支持的解析类型
|
||||||
|
if ("complete".equals(result_level)) {
|
||||||
|
if ("simple_expression".equals(category) || "read_choice".equals(category)
|
||||||
|
|| "topic".equals(category) || "retell".equals(category)
|
||||||
|
|| "picture_talk".equals(category) || "oral_translation".equals(category)) {
|
||||||
|
showTip("不支持解析该类型");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
XmlResultParser resultParser = new XmlResultParser();
|
XmlResultParser resultParser = new XmlResultParser();
|
||||||
Result result = resultParser.parse(mLastResult);
|
Result result = resultParser.parse(mLastResult);
|
||||||
|
|
||||||
@ -240,19 +249,51 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
String text = "";
|
String text = "";
|
||||||
if ("en_us".equals(language)) {
|
if ("en_us".equals(language)) {
|
||||||
if ("read_word".equals(category)) {
|
switch (category) {
|
||||||
|
case "read_word": // 词语
|
||||||
text = getString(R.string.text_en_word);
|
text = getString(R.string.text_en_word);
|
||||||
} else if ("read_sentence".equals(category)) {
|
break;
|
||||||
|
case "read_sentence": // 句子
|
||||||
text = getString(R.string.text_en_sentence);
|
text = getString(R.string.text_en_sentence);
|
||||||
|
break;
|
||||||
|
case "read_chapter": // 篇章
|
||||||
|
text = getString(R.string.text_en_chapter);
|
||||||
|
break;
|
||||||
|
case "simple_expression": // 英文情景反应
|
||||||
|
text = new String(Base64.decode(getString(R.string.text_en_simple_expression), Base64.DEFAULT));
|
||||||
|
break;
|
||||||
|
case "read_choice": // 英文选择题
|
||||||
|
text = new String(Base64.decode(getString(R.string.text_en_read_choice), Base64.DEFAULT));
|
||||||
|
break;
|
||||||
|
case "topic": // 英文自由题
|
||||||
|
text = new String(Base64.decode(getString(R.string.text_en_topic), Base64.DEFAULT));
|
||||||
|
break;
|
||||||
|
case "retell": // 英文复述题
|
||||||
|
text = new String(Base64.decode(getString(R.string.text_en_retell), Base64.DEFAULT));
|
||||||
|
break;
|
||||||
|
case "picture_talk": // 英文看图说话
|
||||||
|
text = new String(Base64.decode(getString(R.string.text_en_picture_talk), Base64.DEFAULT));
|
||||||
|
break;
|
||||||
|
case "oral_translation": // 英文口头翻译
|
||||||
|
text = new String(Base64.decode(getString(R.string.text_en_oral_translation), Base64.DEFAULT));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 中文评测
|
// 中文评测
|
||||||
if ("read_syllable".equals(category)) {
|
switch (category) {
|
||||||
|
case "read_syllable":
|
||||||
text = getString(R.string.text_cn_syllable);
|
text = getString(R.string.text_cn_syllable);
|
||||||
} else if ("read_word".equals(category)) {
|
break;
|
||||||
|
case "read_word":
|
||||||
text = getString(R.string.text_cn_word);
|
text = getString(R.string.text_cn_word);
|
||||||
} else if ("read_sentence".equals(category)) {
|
break;
|
||||||
|
case "read_sentence":
|
||||||
text = getString(R.string.text_cn_sentence);
|
text = getString(R.string.text_cn_sentence);
|
||||||
|
break;
|
||||||
|
case "read_chapter":
|
||||||
|
text = getString(R.string.text_cn_chapter);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,12 +304,15 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showTip(String str) {
|
private void showTip(String str) {
|
||||||
if(!TextUtils.isEmpty(str)) {
|
if (!TextUtils.isEmpty(str)) {
|
||||||
|
mToast.cancel();
|
||||||
mToast.setText(str);
|
mToast.setText(str);
|
||||||
mToast.show();
|
mToast.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setParams() {
|
private void setParams() {
|
||||||
|
|
||||||
SharedPreferences pref = getSharedPreferences(PREFER_NAME, MODE_PRIVATE);
|
SharedPreferences pref = getSharedPreferences(PREFER_NAME, MODE_PRIVATE);
|
||||||
// 设置评测语言
|
// 设置评测语言
|
||||||
language = pref.getString(SpeechConstant.LANGUAGE, "zh_cn");
|
language = pref.getString(SpeechConstant.LANGUAGE, "zh_cn");
|
||||||
@ -283,6 +327,21 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
// 语音输入超时时间,即用户最多可以连续说多长时间;
|
// 语音输入超时时间,即用户最多可以连续说多长时间;
|
||||||
String speech_timeout = pref.getString(SpeechConstant.KEY_SPEECH_TIMEOUT, "-1");
|
String speech_timeout = pref.getString(SpeechConstant.KEY_SPEECH_TIMEOUT, "-1");
|
||||||
|
|
||||||
|
// 设置流式版本所需参数 : ent sub plev
|
||||||
|
if ("zh_cn".equals(language)) {
|
||||||
|
mIse.setParameter("ent", "cn_vip");
|
||||||
|
}
|
||||||
|
if ("en_us".equals(language)) {
|
||||||
|
mIse.setParameter("ent", "en_vip");
|
||||||
|
}
|
||||||
|
mIse.setParameter(SpeechConstant.SUBJECT, "ise");
|
||||||
|
mIse.setParameter("plev", "0");
|
||||||
|
|
||||||
|
// 设置评分百分制 使用 ise_unite rst extra_ability 参数
|
||||||
|
mIse.setParameter("ise_unite", "1");
|
||||||
|
mIse.setParameter("rst", "entirety");
|
||||||
|
mIse.setParameter("extra_ability", "syll_phone_err_msg;pitch;multi_dimension");
|
||||||
|
|
||||||
mIse.setParameter(SpeechConstant.LANGUAGE, language);
|
mIse.setParameter(SpeechConstant.LANGUAGE, language);
|
||||||
mIse.setParameter(SpeechConstant.ISE_CATEGORY, category);
|
mIse.setParameter(SpeechConstant.ISE_CATEGORY, category);
|
||||||
mIse.setParameter(SpeechConstant.TEXT_ENCODING, "utf-8");
|
mIse.setParameter(SpeechConstant.TEXT_ENCODING, "utf-8");
|
||||||
@ -290,27 +349,13 @@ public class IseDemo extends Activity implements OnClickListener {
|
|||||||
mIse.setParameter(SpeechConstant.VAD_EOS, vad_eos);
|
mIse.setParameter(SpeechConstant.VAD_EOS, vad_eos);
|
||||||
mIse.setParameter(SpeechConstant.KEY_SPEECH_TIMEOUT, speech_timeout);
|
mIse.setParameter(SpeechConstant.KEY_SPEECH_TIMEOUT, speech_timeout);
|
||||||
mIse.setParameter(SpeechConstant.RESULT_LEVEL, result_level);
|
mIse.setParameter(SpeechConstant.RESULT_LEVEL, result_level);
|
||||||
mIse.setParameter(SpeechConstant.AUDIO_FORMAT_AUE,"opus");
|
mIse.setParameter(SpeechConstant.AUDIO_FORMAT_AUE, "opus");
|
||||||
// 设置音频保存路径,保存音频格式支持pcm、wav,设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
|
// 设置音频保存路径,保存音频格式支持pcm、wav,
|
||||||
mIse.setParameter(SpeechConstant.AUDIO_FORMAT,"wav");
|
mIse.setParameter(SpeechConstant.AUDIO_FORMAT, "wav");
|
||||||
mIse.setParameter(SpeechConstant.ISE_AUDIO_PATH, Environment.getExternalStorageDirectory().getAbsolutePath() + "/msc/ise.wav");
|
mIse.setParameter(SpeechConstant.ISE_AUDIO_PATH,
|
||||||
|
getExternalFilesDir("msc").getAbsolutePath() + "/ise.wav");
|
||||||
//通过writeaudio方式直接写入音频时才需要此设置
|
//通过writeaudio方式直接写入音频时才需要此设置
|
||||||
//mIse.setParameter(SpeechConstant.AUDIO_SOURCE,"-1");
|
//mIse.setParameter(SpeechConstant.AUDIO_SOURCE,"-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
// 开放统计 移动数据统计分析
|
|
||||||
/*FlowerCollector.onResume(IseDemo.this);
|
|
||||||
FlowerCollector.onPageStart(TAG);*/
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
/* // 开放统计 移动数据统计分析
|
|
||||||
FlowerCollector.onPageEnd(TAG);
|
|
||||||
FlowerCollector.onPause(IseDemo.this);*/
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,189 +1,75 @@
|
|||||||
package com.iflytek.voicedemo;
|
package com.iflytek.voicedemo;
|
||||||
|
|
||||||
import com.iflytek.cloud.SpeechUtility;
|
|
||||||
import com.iflytek.speech.setting.UrlSettings;
|
|
||||||
|
|
||||||
import com.iflytek.voicedemo.faceonline.OnlineFaceDemo;
|
|
||||||
import com.iflytek.voicedemo.vocalverify.VocalVerifyDemo;
|
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import static com.iflytek.speech.setting.UrlSettings.PREFER_NAME;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
public class MainActivity extends Activity implements OnClickListener {
|
public class MainActivity extends Activity {
|
||||||
|
|
||||||
private static final String TAG = MainActivity.class.getSimpleName();
|
|
||||||
private Toast mToast;
|
|
||||||
private final int URL_REQUEST_CODE = 0X001;
|
|
||||||
private TextView edit_text;
|
|
||||||
|
|
||||||
@SuppressLint("ShowToast")
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
edit_text = (TextView) findViewById(R.id.edit_text);
|
initView();
|
||||||
StringBuffer buf = new StringBuffer();
|
|
||||||
buf.append("当前APPID为:");
|
|
||||||
buf.append(getString(R.string.app_id)+"\n");
|
|
||||||
buf.append(getString(R.string.example_explain));
|
|
||||||
edit_text.setText(buf);
|
|
||||||
requestPermissions();
|
requestPermissions();
|
||||||
mToast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
|
|
||||||
//mscInit(null);//采用sdk默认url
|
|
||||||
SimpleAdapter listitemAdapter = new SimpleAdapter();
|
|
||||||
((ListView) findViewById(R.id.listview_main)).setAdapter(listitemAdapter);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void initView() {
|
||||||
public void onClick(View view) {
|
TextView tipTv = (TextView) findViewById(R.id.tip);
|
||||||
int tag = Integer.parseInt(view.getTag().toString());
|
String buf = "当前APPID为:" +
|
||||||
Intent intent = null;
|
getString(R.string.app_id) + "\n" +
|
||||||
switch (tag) {
|
getString(R.string.example_explain);
|
||||||
case 0:
|
tipTv.setText(buf);
|
||||||
// 语音转写
|
// 语音转写
|
||||||
intent = new Intent(MainActivity.this, IatDemo.class);
|
findViewById(R.id.iatBtn).setOnClickListener(v -> {
|
||||||
break;
|
startActivity(new Intent(MainActivity.this, IatDemo.class));
|
||||||
case 1:
|
});
|
||||||
// 语法识别
|
// 语法识别
|
||||||
intent = new Intent(MainActivity.this, AsrDemo.class);
|
findViewById(R.id.asrBtn).setOnClickListener(v -> {
|
||||||
break;
|
startActivity(new Intent(MainActivity.this, AsrDemo.class));
|
||||||
case 2:
|
});
|
||||||
// 语义理解
|
// 语义理解
|
||||||
|
findViewById(R.id.nlpBtn).setOnClickListener(v -> {
|
||||||
showTip("请登录:http://www.xfyun.cn/ 下载aiui体验吧!");
|
showTip("请登录:http://www.xfyun.cn/ 下载aiui体验吧!");
|
||||||
break;
|
});
|
||||||
case 3:
|
|
||||||
// 语音合成
|
// 语音合成
|
||||||
intent = new Intent(MainActivity.this, TtsDemo.class);
|
findViewById(R.id.ttsBtn).setOnClickListener(v -> {
|
||||||
break;
|
startActivity(new Intent(MainActivity.this, TtsDemo.class));
|
||||||
case 4:
|
});
|
||||||
// 语音评测
|
// 语音评测
|
||||||
intent = new Intent(MainActivity.this, IseDemo.class);
|
findViewById(R.id.iseBtn).setOnClickListener(v -> {
|
||||||
break;
|
startActivity(new Intent(MainActivity.this, IseDemo.class));
|
||||||
case 5:
|
});
|
||||||
// 唤醒
|
// 人脸识别
|
||||||
showTip("请登录:http://www.xfyun.cn/ 下载体验吧!");
|
findViewById(R.id.faceBtn).setOnClickListener(v -> {
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
// 声纹
|
|
||||||
//intent = new Intent(MainActivity.this, VocalVerifyDemo.class);
|
|
||||||
showTip("请登录:http://www.xfyun.cn/ “声纹识别”下载体验吧!");
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
//intent = new Intent(MainActivity.this,OnlineFaceDemo.class);
|
|
||||||
showTip("请登录:http://www.xfyun.cn/ “人脸识别”下载体验吧!");
|
showTip("请登录:http://www.xfyun.cn/ “人脸识别”下载体验吧!");
|
||||||
break;
|
});
|
||||||
/*case 8:
|
|
||||||
Intent init = new Intent(MainActivity.this, UrlSettings.class);
|
|
||||||
startActivityForResult(init, URL_REQUEST_CODE);
|
|
||||||
break;*/
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intent != null) {
|
private Toast mToast;
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menu 列表
|
|
||||||
String items[] = { "立刻体验语音听写", "立刻体验语法识别", "立刻体验语义理解", "立刻体验语音合成",
|
|
||||||
"立刻体验语音评测", "立刻体验语音唤醒", "立刻体验声纹密码","立刻体验人脸识别"/*,"重置域名"*/ };
|
|
||||||
|
|
||||||
private class SimpleAdapter extends BaseAdapter {
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
if (null == convertView) {
|
|
||||||
LayoutInflater factory = LayoutInflater.from(MainActivity.this);
|
|
||||||
View mView = factory.inflate(R.layout.list_items, null);
|
|
||||||
convertView = mView;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button btn = (Button) convertView.findViewById(R.id.btn);
|
|
||||||
btn.setOnClickListener(MainActivity.this);
|
|
||||||
btn.setTag(position);
|
|
||||||
btn.setText(items[position]);
|
|
||||||
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return items.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getItem(int position) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int position) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showTip(final String str) {
|
private void showTip(final String str) {
|
||||||
mToast.setText(str);
|
if (mToast != null) {
|
||||||
|
mToast.cancel();
|
||||||
|
}
|
||||||
|
mToast = Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT);
|
||||||
mToast.show();
|
mToast.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void requestPermissions() {
|
||||||
protected void onResume() {
|
|
||||||
// 开放统计 移动数据统计分析
|
|
||||||
/*FlowerCollector.onResume(MainActivity.this);
|
|
||||||
FlowerCollector.onPageStart(TAG);*/
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
// 开放统计 移动数据统计分析
|
|
||||||
/* FlowerCollector.onPageEnd(TAG);
|
|
||||||
FlowerCollector.onPause(MainActivity.this);*/
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void requestPermissions(){
|
|
||||||
try {
|
try {
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
int permission = ActivityCompat.checkSelfPermission(this,
|
ActivityCompat.requestPermissions(this, new String[]{
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
Manifest.permission.RECORD_AUDIO,
|
||||||
if(permission!= PackageManager.PERMISSION_GRANTED) {
|
Manifest.permission.CAMERA
|
||||||
ActivityCompat.requestPermissions(this,new String[]
|
}, 0x0010);
|
||||||
{Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
||||||
Manifest.permission.LOCATION_HARDWARE,Manifest.permission.READ_PHONE_STATE,
|
|
||||||
Manifest.permission.WRITE_SETTINGS,Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
||||||
Manifest.permission.RECORD_AUDIO,Manifest.permission.READ_CONTACTS},0x0010);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(permission != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
ActivityCompat.requestPermissions(this,new String[] {
|
|
||||||
Manifest.permission.ACCESS_COARSE_LOCATION,
|
|
||||||
Manifest.permission.ACCESS_FINE_LOCATION},0x0010);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -195,58 +81,4 @@ public class MainActivity extends Activity implements OnClickListener {
|
|||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mscInit (String serverUrl){
|
|
||||||
// 注意:此接口在非主进程调用会返回null对象,如需在非主进程使用语音功能,请增加参数:SpeechConstant.FORCE_LOGIN+"=true"
|
|
||||||
// 参数间使用半角“,”分隔。
|
|
||||||
// 设置你申请的应用appid,请勿在'='与appid之间添加空格及空转义符
|
|
||||||
|
|
||||||
// 注意: appid 必须和下载的SDK保持一致,否则会出现10407错误
|
|
||||||
StringBuffer bf = new StringBuffer();
|
|
||||||
bf.append("appid="+getString(R.string.app_id));
|
|
||||||
bf.append(",");
|
|
||||||
if (!TextUtils.isEmpty(serverUrl)) {
|
|
||||||
bf.append("server_url="+serverUrl);
|
|
||||||
bf.append(",");
|
|
||||||
}
|
|
||||||
//此处调用与SpeechDemo中重复,两处只调用其一即可
|
|
||||||
SpeechUtility.createUtility(this.getApplicationContext(), bf.toString());
|
|
||||||
// 以下语句用于设置日志开关(默认开启),设置成false时关闭语音云SDK日志打印
|
|
||||||
// Setting.setShowLog(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void mscUninit() {
|
|
||||||
if (SpeechUtility.getUtility()!= null) {
|
|
||||||
SpeechUtility.getUtility().destroy();
|
|
||||||
try{
|
|
||||||
new Thread().sleep(40);
|
|
||||||
}catch (InterruptedException e) {
|
|
||||||
Log.w(TAG,"msc uninit failed"+e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
if (URL_REQUEST_CODE == requestCode) {
|
|
||||||
Log.d(TAG,"onActivityResult>>");
|
|
||||||
try{
|
|
||||||
SharedPreferences pref = getSharedPreferences(PREFER_NAME, MODE_PRIVATE);
|
|
||||||
String server_url = pref.getString("url_preference","");
|
|
||||||
String domain = pref.getString("url_edit","");
|
|
||||||
Log.d(TAG,"onActivityResult>>domain = "+domain);
|
|
||||||
if (!TextUtils.isEmpty(domain)) {
|
|
||||||
server_url = "http://"+domain+"/msp.do";
|
|
||||||
}
|
|
||||||
Log.d(TAG,"onActivityResult>>server_url = "+server_url);
|
|
||||||
mscUninit();
|
|
||||||
new Thread().sleep(40);
|
|
||||||
//mscInit(server_url);
|
|
||||||
}catch (Exception e) {
|
|
||||||
showTip("reset url failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.iflytek.voicedemo;
|
package com.iflytek.voicedemo;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
|
||||||
import com.iflytek.cloud.Setting;
|
import com.iflytek.cloud.Setting;
|
||||||
import com.iflytek.cloud.SpeechUtility;
|
import com.iflytek.cloud.SpeechUtility;
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ public class SpeechApp extends Application {
|
|||||||
SpeechUtility.createUtility(SpeechApp.this, "appid=" + getString(R.string.app_id));
|
SpeechUtility.createUtility(SpeechApp.this, "appid=" + getString(R.string.app_id));
|
||||||
|
|
||||||
// 以下语句用于设置日志开关(默认开启),设置成false时关闭语音云SDK日志打印
|
// 以下语句用于设置日志开关(默认开启),设置成false时关闭语音云SDK日志打印
|
||||||
// Setting.setShowLog(false);
|
Setting.setShowLog(true);
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.iflytek.voicedemo;
|
package com.iflytek.voicedemo;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@ -8,8 +7,6 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.os.MemoryFile;
|
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.style.BackgroundColorSpan;
|
import android.text.style.BackgroundColorSpan;
|
||||||
@ -29,15 +26,11 @@ import com.iflytek.cloud.SpeechError;
|
|||||||
import com.iflytek.cloud.SpeechEvent;
|
import com.iflytek.cloud.SpeechEvent;
|
||||||
import com.iflytek.cloud.SpeechSynthesizer;
|
import com.iflytek.cloud.SpeechSynthesizer;
|
||||||
import com.iflytek.cloud.SynthesizerListener;
|
import com.iflytek.cloud.SynthesizerListener;
|
||||||
import com.iflytek.cloud.msc.util.FileUtil;
|
|
||||||
import com.iflytek.cloud.msc.util.log.DebugLog;
|
|
||||||
import com.iflytek.speech.setting.TtsSettings;
|
import com.iflytek.speech.setting.TtsSettings;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.RandomAccessFile;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
|
|
||||||
public class TtsDemo extends Activity implements OnClickListener {
|
public class TtsDemo extends Activity implements OnClickListener {
|
||||||
@ -49,8 +42,8 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
private String voicer = "xiaoyan";
|
private String voicer = "xiaoyan";
|
||||||
|
|
||||||
private String[] mCloudVoicersEntries;
|
private String[] mCloudVoicersEntries;
|
||||||
private String[] mCloudVoicersValue ;
|
private String[] mCloudVoicersValue;
|
||||||
String texts = "";
|
private String texts = "";
|
||||||
|
|
||||||
// 缓冲进度
|
// 缓冲进度
|
||||||
private int mPercentForBuffering = 0;
|
private int mPercentForBuffering = 0;
|
||||||
@ -64,30 +57,20 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
private Toast mToast;
|
private Toast mToast;
|
||||||
private SharedPreferences mSharedPreferences;
|
private SharedPreferences mSharedPreferences;
|
||||||
|
private File pcmFile;
|
||||||
|
|
||||||
MemoryFile memFile;
|
|
||||||
public volatile long mTotalSize = 0;
|
|
||||||
|
|
||||||
private Vector<byte[]> container = new Vector<> ();
|
|
||||||
|
|
||||||
@SuppressLint("ShowToast")
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
setContentView(R.layout.ttsdemo);
|
setContentView(R.layout.ttsdemo);
|
||||||
texts = getResources().getString(R.string.text_tts_source);
|
texts = getResources().getString(R.string.text_tts_source);
|
||||||
initLayout();
|
initLayout();
|
||||||
DebugLog.setShowLog(true);
|
|
||||||
// 初始化合成对象
|
// 初始化合成对象
|
||||||
mTts = SpeechSynthesizer.createSynthesizer(TtsDemo.this, mTtsInitListener);
|
mTts = SpeechSynthesizer.createSynthesizer(TtsDemo.this, mTtsInitListener);
|
||||||
|
|
||||||
// 云端发音人名称列表
|
// 云端发音人名称列表
|
||||||
mCloudVoicersEntries = getResources().getStringArray(R.array.voicer_cloud_entries);
|
mCloudVoicersEntries = getResources().getStringArray(R.array.voicer_cloud_entries);
|
||||||
mCloudVoicersValue = getResources().getStringArray(R.array.voicer_cloud_values);
|
mCloudVoicersValue = getResources().getStringArray(R.array.voicer_cloud_values);
|
||||||
|
|
||||||
mSharedPreferences = getSharedPreferences(TtsSettings.PREFER_NAME, MODE_PRIVATE);
|
mSharedPreferences = getSharedPreferences(TtsSettings.PREFER_NAME, MODE_PRIVATE);
|
||||||
mToast = Toast.makeText(this,"",Toast.LENGTH_SHORT);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +84,7 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
findViewById(R.id.image_tts_set).setOnClickListener(TtsDemo.this);
|
findViewById(R.id.image_tts_set).setOnClickListener(TtsDemo.this);
|
||||||
findViewById(R.id.tts_btn_person_select).setOnClickListener(TtsDemo.this);
|
findViewById(R.id.tts_btn_person_select).setOnClickListener(TtsDemo.this);
|
||||||
|
|
||||||
mRadioGroup=((RadioGroup) findViewById(R.id.tts_rediogroup));
|
mRadioGroup = ((RadioGroup) findViewById(R.id.tts_rediogroup));
|
||||||
mRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,23 +98,23 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} );
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if( null == mTts ){
|
if (null == mTts) {
|
||||||
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
|
||||||
this.showTip( "创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化" );
|
this.showTip("创建对象失败,请确认 libmsc.so 放置正确,且有调用 createUtility 进行初始化");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.image_tts_set:
|
case R.id.image_tts_set:
|
||||||
if(SpeechConstant.TYPE_CLOUD.equals(mEngineType)){
|
if (SpeechConstant.TYPE_CLOUD.equals(mEngineType)) {
|
||||||
Intent intent = new Intent(TtsDemo.this, TtsSettings.class);
|
Intent intent = new Intent(TtsDemo.this, TtsSettings.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}else{
|
} else {
|
||||||
showTip("请前往xfyun.cn下载离线合成体验");
|
showTip("请前往xfyun.cn下载离线合成体验");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -139,22 +122,23 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
// 收到onCompleted 回调时,合成结束、生成合成音频
|
// 收到onCompleted 回调时,合成结束、生成合成音频
|
||||||
// 合成的音频格式:只支持pcm格式
|
// 合成的音频格式:只支持pcm格式
|
||||||
case R.id.tts_play:
|
case R.id.tts_play:
|
||||||
// 移动数据分析,收集开始合成事件
|
pcmFile = new File(getExternalCacheDir().getAbsolutePath(), "tts_pcmFile.pcm");
|
||||||
/*FlowerCollector.onEvent(TtsDemo.this, "tts_play");*/
|
pcmFile.delete();
|
||||||
|
|
||||||
texts = ((EditText) findViewById(R.id.tts_text)).getText().toString();
|
texts = ((EditText) findViewById(R.id.tts_text)).getText().toString();
|
||||||
// 设置参数
|
// 设置参数
|
||||||
setParam();
|
setParam();
|
||||||
|
// 合成并播放
|
||||||
int code = mTts.startSpeaking(texts, mTtsListener);
|
int code = mTts.startSpeaking(texts, mTtsListener);
|
||||||
// /**
|
// /**
|
||||||
// * 只保存音频不进行播放接口,调用此接口请注释startSpeaking接口
|
// * 只保存音频不进行播放接口,调用此接口请注释startSpeaking接口
|
||||||
// * text:要合成的文本,uri:需要保存的音频全路径,listener:回调接口
|
// * text:要合成的文本,uri:需要保存的音频全路径,listener:回调接口
|
||||||
// */
|
// */
|
||||||
String path = Environment.getExternalStorageDirectory()+"/tts.pcm";
|
// String path = getExternalFilesDir("msc").getAbsolutePath() + "/tts.pcm";
|
||||||
// int code = mTts.synthesizeToUri(texts, path, mTtsListener);
|
// // synthesizeToUri 只保存音频不进行播放
|
||||||
|
// int code = mTts.synthesizeToUri(texts, path, mTtsListener);
|
||||||
|
|
||||||
if (code != ErrorCode.SUCCESS) {
|
if (code != ErrorCode.SUCCESS) {
|
||||||
showTip("语音合成失败,错误码: " + code+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("语音合成失败,错误码: " + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// 取消合成
|
// 取消合成
|
||||||
@ -171,15 +155,17 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
break;
|
break;
|
||||||
// 选择发音人
|
// 选择发音人
|
||||||
case R.id.tts_btn_person_select:
|
case R.id.tts_btn_person_select:
|
||||||
showPresonSelectDialog();
|
showPersonSelectDialog();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int selectedNum = 0;
|
private int selectedNum = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发音人选择。
|
* 发音人选择。
|
||||||
*/
|
*/
|
||||||
private void showPresonSelectDialog() {
|
private void showPersonSelectDialog() {
|
||||||
switch (mRadioGroup.getCheckedRadioButtonId()) {
|
switch (mRadioGroup.getCheckedRadioButtonId()) {
|
||||||
// 选择在线合成
|
// 选择在线合成
|
||||||
case R.id.tts_radioCloud:
|
case R.id.tts_radioCloud:
|
||||||
@ -192,7 +178,7 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
voicer = mCloudVoicersValue[which];
|
voicer = mCloudVoicersValue[which];
|
||||||
if ("catherine".equals(voicer) || "henry".equals(voicer) || "vimary".equals(voicer)) {
|
if ("catherine".equals(voicer) || "henry".equals(voicer) || "vimary".equals(voicer)) {
|
||||||
((EditText) findViewById(R.id.tts_text)).setText(R.string.text_tts_source_en);
|
((EditText) findViewById(R.id.tts_text)).setText(R.string.text_tts_source_en);
|
||||||
}else {
|
} else {
|
||||||
((EditText) findViewById(R.id.tts_text)).setText(R.string.text_tts_source);
|
((EditText) findViewById(R.id.tts_text)).setText(R.string.text_tts_source);
|
||||||
}
|
}
|
||||||
selectedNum = which;
|
selectedNum = which;
|
||||||
@ -214,7 +200,7 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
public void onInit(int code) {
|
public void onInit(int code) {
|
||||||
Log.d(TAG, "InitListener init() code = " + code);
|
Log.d(TAG, "InitListener init() code = " + code);
|
||||||
if (code != ErrorCode.SUCCESS) {
|
if (code != ErrorCode.SUCCESS) {
|
||||||
showTip("初始化失败,错误码:"+code+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("初始化失败,错误码:" + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
} else {
|
} else {
|
||||||
// 初始化成功,之后可以调用startSpeaking方法
|
// 初始化成功,之后可以调用startSpeaking方法
|
||||||
// 注:有的开发者在onCreate方法中创建完合成对象之后马上就调用startSpeaking进行合成,
|
// 注:有的开发者在onCreate方法中创建完合成对象之后马上就调用startSpeaking进行合成,
|
||||||
@ -261,30 +247,18 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
showTip(String.format(getString(R.string.tts_toast_format),
|
showTip(String.format(getString(R.string.tts_toast_format),
|
||||||
mPercentForBuffering, mPercentForPlaying));
|
mPercentForBuffering, mPercentForPlaying));
|
||||||
|
|
||||||
SpannableStringBuilder style=new SpannableStringBuilder(texts);
|
SpannableStringBuilder style = new SpannableStringBuilder(texts);
|
||||||
Log.e(TAG,"beginPos = "+beginPos +" endPos = "+endPos);
|
Log.e(TAG, "beginPos = " + beginPos + " endPos = " + endPos);
|
||||||
style.setSpan(new BackgroundColorSpan(Color.RED),beginPos,endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
style.setSpan(new BackgroundColorSpan(Color.RED), beginPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
((EditText) findViewById(R.id.tts_text)).setText(style);
|
((EditText) findViewById(R.id.tts_text)).setText(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCompleted(SpeechError error) {
|
public void onCompleted(SpeechError error) {
|
||||||
System.out.println("oncompleted");
|
showTip("播放完成");
|
||||||
if (error == null) {
|
if (error != null) {
|
||||||
// showTip("播放完成");
|
|
||||||
DebugLog.LogD("播放完成,"+container.size());
|
|
||||||
try {
|
|
||||||
for(int i=0;i<container.size();i++) {
|
|
||||||
writeToFile(container.get(i));
|
|
||||||
}
|
|
||||||
}catch (IOException e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
FileUtil.saveFile(memFile,mTotalSize,Environment.getExternalStorageDirectory()+"/1.pcm");
|
|
||||||
|
|
||||||
|
|
||||||
} else if (error != null) {
|
|
||||||
showTip(error.getPlainDescription(true));
|
showTip(error.getPlainDescription(true));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,33 +270,39 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
String sid = obj.getString(SpeechEvent.KEY_EVENT_SESSION_ID);
|
String sid = obj.getString(SpeechEvent.KEY_EVENT_SESSION_ID);
|
||||||
Log.d(TAG, "session id =" + sid);
|
Log.d(TAG, "session id =" + sid);
|
||||||
}
|
}
|
||||||
|
// 当设置 SpeechConstant.TTS_DATA_NOTIFY 为1时,抛出buf数据
|
||||||
//当设置SpeechConstant.TTS_DATA_NOTIFY为1时,抛出buf数据
|
|
||||||
if (SpeechEvent.EVENT_TTS_BUFFER == eventType) {
|
if (SpeechEvent.EVENT_TTS_BUFFER == eventType) {
|
||||||
byte[] buf = obj.getByteArray(SpeechEvent.KEY_EVENT_TTS_BUFFER);
|
byte[] buf = obj.getByteArray(SpeechEvent.KEY_EVENT_TTS_BUFFER);
|
||||||
Log.e("MscSpeechLog_", "bufis =" + buf.length);
|
Log.e(TAG, "EVENT_TTS_BUFFER = " + buf.length);
|
||||||
container.add(buf);
|
// 保存文件
|
||||||
|
appendFile(pcmFile, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void showTip(final String str) {
|
private void showTip(final String str) {
|
||||||
Toast.makeText(this,str,Toast.LENGTH_SHORT);
|
runOnUiThread(() -> {
|
||||||
|
if (mToast != null) {
|
||||||
|
mToast.cancel();
|
||||||
|
}
|
||||||
|
mToast = Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT);
|
||||||
|
mToast.show();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数设置
|
* 参数设置
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private void setParam(){
|
private void setParam() {
|
||||||
// 清空参数
|
// 清空参数
|
||||||
mTts.setParameter(SpeechConstant.PARAMS, null);
|
mTts.setParameter(SpeechConstant.PARAMS, null);
|
||||||
// 根据合成引擎设置相应参数
|
// 根据合成引擎设置相应参数
|
||||||
if(mEngineType.equals(SpeechConstant.TYPE_CLOUD)) {
|
if (mEngineType.equals(SpeechConstant.TYPE_CLOUD)) {
|
||||||
mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
|
mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD);
|
||||||
//支持实时音频返回,仅在synthesizeToUri条件下支持
|
// 支持实时音频返回,仅在 synthesizeToUri 条件下支持
|
||||||
mTts.setParameter(SpeechConstant.TTS_DATA_NOTIFY, "1");
|
mTts.setParameter(SpeechConstant.TTS_DATA_NOTIFY, "1");
|
||||||
// mTts.setParameter(SpeechConstant.TTS_BUFFER_TIME,"1");
|
// mTts.setParameter(SpeechConstant.TTS_BUFFER_TIME,"1");
|
||||||
|
|
||||||
@ -334,7 +314,7 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
mTts.setParameter(SpeechConstant.PITCH, mSharedPreferences.getString("pitch_preference", "50"));
|
mTts.setParameter(SpeechConstant.PITCH, mSharedPreferences.getString("pitch_preference", "50"));
|
||||||
//设置合成音量
|
//设置合成音量
|
||||||
mTts.setParameter(SpeechConstant.VOLUME, mSharedPreferences.getString("volume_preference", "50"));
|
mTts.setParameter(SpeechConstant.VOLUME, mSharedPreferences.getString("volume_preference", "50"));
|
||||||
}else {
|
} else {
|
||||||
mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL);
|
mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL);
|
||||||
mTts.setParameter(SpeechConstant.VOICE_NAME, "");
|
mTts.setParameter(SpeechConstant.VOICE_NAME, "");
|
||||||
|
|
||||||
@ -347,49 +327,35 @@ public class TtsDemo extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
// 设置音频保存路径,保存音频格式支持pcm、wav,设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
|
// 设置音频保存路径,保存音频格式支持pcm、wav,设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
|
||||||
mTts.setParameter(SpeechConstant.AUDIO_FORMAT, "pcm");
|
mTts.setParameter(SpeechConstant.AUDIO_FORMAT, "pcm");
|
||||||
mTts.setParameter(SpeechConstant.TTS_AUDIO_PATH, Environment.getExternalStorageDirectory()+"/msc/tts.pcm");
|
mTts.setParameter(SpeechConstant.TTS_AUDIO_PATH,
|
||||||
|
getExternalFilesDir("msc").getAbsolutePath() + "/tts.pcm");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
if (null != mTts) {
|
||||||
|
|
||||||
if( null != mTts ){
|
|
||||||
mTts.stopSpeaking();
|
mTts.stopSpeaking();
|
||||||
// 退出时释放连接
|
// 退出时释放连接
|
||||||
mTts.destroy();
|
mTts.destroy();
|
||||||
}
|
}
|
||||||
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
//移动数据统计分析
|
|
||||||
/*FlowerCollector.onResume(TtsDemo.this);
|
|
||||||
FlowerCollector.onPageStart(TAG);*/
|
|
||||||
super.onResume();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
//移动数据统计分析
|
|
||||||
/*FlowerCollector.onPageEnd(TAG);
|
|
||||||
FlowerCollector.onPause(TtsDemo.this);*/
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeToFile(byte[] data) throws IOException {
|
/**
|
||||||
if (data == null || data.length == 0)
|
* 给file追加数据
|
||||||
return;
|
*/
|
||||||
|
private void appendFile(File file, byte[] buffer) {
|
||||||
try {
|
try {
|
||||||
if(memFile == null)
|
if (!file.exists()) {
|
||||||
{
|
boolean b = file.createNewFile();
|
||||||
Log.e("MscSpeechLog_","ffffffffff");
|
|
||||||
String mFilepath = Environment.getExternalStorageDirectory()+"/1.pcm";
|
|
||||||
memFile = new MemoryFile(mFilepath,1920000);
|
|
||||||
memFile.allowPurging(false);
|
|
||||||
}
|
}
|
||||||
memFile.writeBytes(data, 0, (int)mTotalSize, data.length);
|
RandomAccessFile randomFile = new RandomAccessFile(file, "rw");
|
||||||
mTotalSize += data.length;
|
randomFile.seek(file.length());
|
||||||
} finally {
|
randomFile.write(buffer);
|
||||||
|
randomFile.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,12 @@ import android.app.Activity;
|
|||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.media.MediaScannerConnection;
|
import android.media.MediaScannerConnection;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.SystemClock;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -19,7 +18,6 @@ import android.view.View;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.iflytek.cloud.ErrorCode;
|
import com.iflytek.cloud.ErrorCode;
|
||||||
@ -29,11 +27,9 @@ import com.iflytek.cloud.IdentityVerifier;
|
|||||||
import com.iflytek.cloud.InitListener;
|
import com.iflytek.cloud.InitListener;
|
||||||
import com.iflytek.cloud.SpeechConstant;
|
import com.iflytek.cloud.SpeechConstant;
|
||||||
import com.iflytek.cloud.SpeechError;
|
import com.iflytek.cloud.SpeechError;
|
||||||
import com.iflytek.cloud.SpeechUtility;
|
|
||||||
import com.iflytek.speech.util.FaceUtil;
|
import com.iflytek.speech.util.FaceUtil;
|
||||||
import com.iflytek.voicedemo.IdentifyGroup.GroupManagerActivity;
|
import com.iflytek.voicedemo.IdentifyGroup.GroupManagerActivity;
|
||||||
import com.iflytek.voicedemo.R;
|
import com.iflytek.voicedemo.R;
|
||||||
import com.iflytek.voicedemo.vocalverify.VocalVerifyDemo;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -42,18 +38,14 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* 此demo意在为提供在线人脸识别相关api调用方式,1:1 识别
|
* 此demo意在为提供在线人脸识别相关api调用方式,1:1 识别
|
||||||
*
|
*
|
||||||
* @author hjyu
|
* @author hjyu
|
||||||
* @date 2017/9/28.
|
* @date 2017/9/28.
|
||||||
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
* @see <a href="http://www.xfyun.cn">讯飞开放平台</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
||||||
private final String TAG = "OnlineFaceDemo";
|
private final String TAG = "OnlineFaceDemo";
|
||||||
private final int REQUEST_PICTURE_CHOOSE = 1;
|
|
||||||
private final int REQUEST_CAMERA_IMAGE = 2;
|
|
||||||
|
|
||||||
private Bitmap mImage = null;
|
private Bitmap mImage = null;
|
||||||
private byte[] mImageData = null;
|
private byte[] mImageData = null;
|
||||||
@ -112,7 +104,7 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
if (ErrorCode.SUCCESS == errorCode) {
|
if (ErrorCode.SUCCESS == errorCode) {
|
||||||
showTip("引擎初始化成功");
|
showTip("引擎初始化成功");
|
||||||
} else {
|
} else {
|
||||||
showTip("引擎初始化失败,错误码:" + errorCode+",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
showTip("引擎初始化失败,错误码:" + errorCode + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -149,8 +141,6 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 人脸注册监听器
|
* 人脸注册监听器
|
||||||
*/
|
*/
|
||||||
@ -170,7 +160,7 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
|
|
||||||
if (ErrorCode.SUCCESS == ret) {
|
if (ErrorCode.SUCCESS == ret) {
|
||||||
showTip("注册成功");
|
showTip("注册成功");
|
||||||
}else {
|
} else {
|
||||||
showTip(new SpeechError(ret).getPlainDescription(true));
|
showTip(new SpeechError(ret).getPlainDescription(true));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
@ -208,7 +198,7 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject object = new JSONObject(result.getResultString());
|
JSONObject object = new JSONObject(result.getResultString());
|
||||||
Log.d(TAG,"object is: "+object.toString());
|
Log.d(TAG, "object is: " + object.toString());
|
||||||
String decision = object.getString("decision");
|
String decision = object.getString("decision");
|
||||||
|
|
||||||
if ("accepted".equalsIgnoreCase(decision)) {
|
if ("accepted".equalsIgnoreCase(decision)) {
|
||||||
@ -281,7 +271,6 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void executeModelCommand(String cmd) {
|
private void executeModelCommand(String cmd) {
|
||||||
// 设置模型参数,若无可以传空字符传
|
// 设置模型参数,若无可以传空字符传
|
||||||
StringBuffer params = new StringBuffer();
|
StringBuffer params = new StringBuffer();
|
||||||
@ -293,10 +282,10 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
int ret = ErrorCode.SUCCESS;
|
int ret = ErrorCode.SUCCESS;
|
||||||
mAuthid = online_authid.getText().toString();
|
mAuthid = online_authid.getText().toString();
|
||||||
if(TextUtils.isEmpty(mAuthid)) {
|
if (TextUtils.isEmpty(mAuthid)) {
|
||||||
showTip("请输入用户ID");
|
showTip("请输入用户ID");
|
||||||
return;
|
return;
|
||||||
}else {
|
} else {
|
||||||
online_authid.setEnabled(false);
|
online_authid.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +294,7 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setType("image/*");
|
intent.setType("image/*");
|
||||||
intent.setAction(Intent.ACTION_PICK);
|
intent.setAction(Intent.ACTION_PICK);
|
||||||
startActivityForResult(intent, REQUEST_PICTURE_CHOOSE);
|
startActivityForResult(intent, FaceUtil.REQUEST_PICTURE_CHOOSE);
|
||||||
break;
|
break;
|
||||||
case R.id.online_reg:
|
case R.id.online_reg:
|
||||||
if (TextUtils.isEmpty(mAuthid)) {
|
if (TextUtils.isEmpty(mAuthid)) {
|
||||||
@ -376,15 +365,8 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.online_camera:
|
case R.id.online_camera:
|
||||||
// 设置相机拍照后照片保存路径
|
|
||||||
mPictureFile = new File(Environment.getExternalStorageDirectory(),
|
|
||||||
"picture" + System.currentTimeMillis()/1000 + ".jpg");
|
|
||||||
// 启动拍照,并保存到临时文件
|
// 启动拍照,并保存到临时文件
|
||||||
Intent mIntent = new Intent();
|
takePhoto();
|
||||||
mIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
||||||
mIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mPictureFile));
|
|
||||||
mIntent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
|
|
||||||
startActivityForResult(mIntent, REQUEST_CAMERA_IMAGE);
|
|
||||||
break;
|
break;
|
||||||
case R.id.btn_modle_delete:
|
case R.id.btn_modle_delete:
|
||||||
// 人脸模型删除
|
// 人脸模型删除
|
||||||
@ -393,60 +375,59 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
break;
|
break;
|
||||||
case R.id.btn_identity:
|
case R.id.btn_identity:
|
||||||
Intent init = new Intent(OnlineFaceDemo.this, GroupManagerActivity.class);
|
Intent init = new Intent(OnlineFaceDemo.this, GroupManagerActivity.class);
|
||||||
init.putExtra("auth_id",mAuthid);
|
init.putExtra("auth_id", mAuthid);
|
||||||
init.putExtra("mfv_scenes","ifr");
|
init.putExtra("mfv_scenes", "ifr");
|
||||||
startActivity(init);
|
startActivity(init);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}//end of switch
|
}//end of switch
|
||||||
|
|
||||||
if( ErrorCode.SUCCESS != ret ){
|
if (ErrorCode.SUCCESS != ret) {
|
||||||
mProDialog.dismiss();
|
mProDialog.dismiss();
|
||||||
showTip( "出现错误:"+ret );
|
showTip("出现错误:" + ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void takePhoto() {
|
||||||
|
// 设置相机拍照后照片保存路径
|
||||||
|
mPictureFile = new File(getExternalFilesDir("msc").getAbsolutePath(),
|
||||||
|
"picture_" + SystemClock.uptimeMillis() + ".jpg");
|
||||||
|
if (mPictureFile.exists()) {
|
||||||
|
mPictureFile.delete();
|
||||||
|
}
|
||||||
|
Uri imageUri = FaceUtil.parseUri(getApplication(), mPictureFile);
|
||||||
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
||||||
|
startActivityForResult(intent, FaceUtil.REQUEST_CAMERA_IMAGE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (resultCode != RESULT_OK) {
|
if (resultCode != RESULT_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String fileSrc = null;
|
String fileSrc = null;
|
||||||
if (requestCode == REQUEST_PICTURE_CHOOSE) {
|
// 选择文件
|
||||||
if ("file".equals(data.getData().getScheme())) {
|
if (requestCode == FaceUtil.REQUEST_PICTURE_CHOOSE) {
|
||||||
// 有些低版本机型返回的Uri模式为file
|
|
||||||
fileSrc = data.getData().getPath();
|
|
||||||
} else {
|
|
||||||
// Uri模型为content
|
|
||||||
String[] proj = {MediaStore.Images.Media.DATA};
|
|
||||||
Cursor cursor = getContentResolver().query(data.getData(), proj,
|
|
||||||
null, null, null);
|
|
||||||
cursor.moveToFirst();
|
|
||||||
int idx = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
||||||
fileSrc = cursor.getString(idx);
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
// 跳转到图片裁剪页面
|
// 跳转到图片裁剪页面
|
||||||
FaceUtil.cropPicture(this,Uri.fromFile(new File(fileSrc)));
|
FaceUtil.cropPicture(this, data.getData());
|
||||||
} else if (requestCode == REQUEST_CAMERA_IMAGE) {
|
return;
|
||||||
if (null == mPictureFile) {
|
}
|
||||||
|
// 拍照
|
||||||
|
if (requestCode == FaceUtil.REQUEST_CAMERA_IMAGE) {
|
||||||
|
if (null == mPictureFile || !mPictureFile.exists()) {
|
||||||
showTip("拍照失败,请重试");
|
showTip("拍照失败,请重试");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSrc = mPictureFile.getAbsolutePath();
|
|
||||||
updateGallery(fileSrc);
|
|
||||||
// 跳转到图片裁剪页面
|
// 跳转到图片裁剪页面
|
||||||
FaceUtil.cropPicture(this,Uri.fromFile(new File(fileSrc)));
|
FaceUtil.cropPicture(
|
||||||
} else if (requestCode == FaceUtil.REQUEST_CROP_IMAGE) {
|
OnlineFaceDemo.this,
|
||||||
// 获取返回数据
|
FaceUtil.parseUri(getApplication(), mPictureFile));
|
||||||
Bitmap bmp = data.getParcelableExtra("data");
|
return;
|
||||||
// 若返回数据不为null,保存至本地,防止裁剪时未能正常保存
|
|
||||||
if(null != bmp){
|
|
||||||
FaceUtil.saveBitmapToFile(OnlineFaceDemo.this, bmp);
|
|
||||||
}
|
}
|
||||||
|
// 裁剪
|
||||||
|
if (requestCode == FaceUtil.REQUEST_CROP_IMAGE) {
|
||||||
// 获取图片保存路径
|
// 获取图片保存路径
|
||||||
fileSrc = FaceUtil.getImagePath(OnlineFaceDemo.this);
|
fileSrc = FaceUtil.getImagePath(OnlineFaceDemo.this);
|
||||||
// 获取图片的宽和高
|
// 获取图片的宽和高
|
||||||
@ -461,29 +442,23 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
options.inJustDecodeBounds = false;
|
options.inJustDecodeBounds = false;
|
||||||
mImage = BitmapFactory.decodeFile(fileSrc, options);
|
mImage = BitmapFactory.decodeFile(fileSrc, options);
|
||||||
|
|
||||||
|
|
||||||
// 若mImageBitmap为空则图片信息不能正常获取
|
// 若mImageBitmap为空则图片信息不能正常获取
|
||||||
if(null == mImage) {
|
if (null == mImage) {
|
||||||
showTip("图片信息无法正常获取!");
|
showTip("图片信息无法正常获取!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 部分手机会对图片做旋转,这里检测旋转角度
|
// 部分手机会对图片做旋转,这里检测旋转角度
|
||||||
int degree = FaceUtil.readPictureDegree(fileSrc);
|
int degree = FaceUtil.readPictureDegree(fileSrc);
|
||||||
if (degree != 0) {
|
if (degree != 0) {
|
||||||
// 把图片旋转为正的方向
|
// 把图片旋转为正的方向
|
||||||
mImage = FaceUtil.rotateImage(degree, mImage);
|
mImage = FaceUtil.rotateImage(degree, mImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
//可根据流量及网络状况对图片进行压缩
|
//可根据流量及网络状况对图片进行压缩
|
||||||
mImage.compress(Bitmap.CompressFormat.JPEG, 80, baos);
|
mImage.compress(Bitmap.CompressFormat.JPEG, 80, baos);
|
||||||
mImageData = baos.toByteArray();
|
mImageData = baos.toByteArray();
|
||||||
|
|
||||||
((ImageView) findViewById(R.id.online_img)).setImageBitmap(mImage);
|
((ImageView) findViewById(R.id.online_img)).setImageBitmap(mImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -495,9 +470,8 @@ public class OnlineFaceDemo extends Activity implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateGallery(String filename) {
|
private void updateGallery(String filename) {
|
||||||
MediaScannerConnection.scanFile(this, new String[] {filename}, null,
|
MediaScannerConnection.scanFile(this, new String[]{filename}, null,
|
||||||
new MediaScannerConnection.OnScanCompletedListener() {
|
new MediaScannerConnection.OnScanCompletedListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScanCompleted(String path, Uri uri) {
|
public void onScanCompleted(String path, Uri uri) {
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:state_pressed="true" android:drawable="@color/list_backgroud_color"></item>
|
<item android:state_pressed="true" android:drawable="@color/list_backgroud_color"></item>
|
||||||
<item android:drawable="@drawable/layout_backgroud"></item>
|
<item android:drawable="@drawable/layout_backgroud"></item>
|
||||||
</selector>
|
</selector>
|
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<item android:drawable="@drawable/setting" android:state_focused="true" android:state_pressed="false"/>
|
<item android:drawable="@drawable/setting" android:state_focused="true" android:state_pressed="false" />
|
||||||
<item android:drawable="@drawable/setting_p" android:state_focused="true" android:state_pressed="true"/>
|
<item android:drawable="@drawable/setting_p" android:state_focused="true" android:state_pressed="true" />
|
||||||
<item android:drawable="@drawable/setting_p" android:state_focused="false" android:state_pressed="true"/>
|
<item android:drawable="@drawable/setting_p" android:state_focused="false" android:state_pressed="true" />
|
||||||
<item android:drawable="@drawable/setting"></item>
|
<item android:drawable="@drawable/setting"></item>
|
||||||
|
|
||||||
</selector>
|
</selector>
|
@ -6,7 +6,7 @@
|
|||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="10dp" >
|
android:padding="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -21,7 +21,7 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center" >
|
android:gravity="center">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/online_img"
|
android:id="@+id/online_img"
|
||||||
@ -36,9 +36,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/txt_groupid"
|
android:id="@+id/txt_groupid"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:padding="5dp"/>
|
android:padding="5dp" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -46,7 +44,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/online_pick"
|
android:id="@+id/online_pick"
|
||||||
@ -71,7 +69,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_identity"
|
android:id="@+id/btn_identity"
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/group_manager_layout"
|
android:id="@+id/group_manager_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/lv_my_group"
|
android:id="@+id/lv_my_group"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- 标题栏 -->
|
<!-- 标题栏 -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@ -19,14 +19,14 @@
|
|||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textSize="26sp"
|
android:textSize="26sp"
|
||||||
android:text="1:N验证结果"/>
|
android:text="1:N验证结果" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/idf_result_layout"
|
android:id="@+id/idf_result_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/lly_group_name"
|
android:id="@+id/lly_group_name"
|
||||||
@ -35,7 +35,7 @@
|
|||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:layout_marginTop="30dp"
|
android:layout_marginTop="30dp"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -74,8 +74,7 @@
|
|||||||
android:layout_alignLeft="@id/txt_hint"
|
android:layout_alignLeft="@id/txt_hint"
|
||||||
android:fadingEdge="none"
|
android:fadingEdge="none"
|
||||||
android:cacheColorHint="#00000000"
|
android:cacheColorHint="#00000000"
|
||||||
android:listSelector="#00000000" >
|
android:listSelector="#00000000"></ListView>
|
||||||
</ListView>
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/group_manager_layout"
|
android:id="@+id/group_manager_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
@ -10,7 +9,7 @@
|
|||||||
android:id="@+id/rllyt_title"
|
android:id="@+id/rllyt_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:gravity="center_vertical" >
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txt_login_title"
|
android:id="@+id/txt_login_title"
|
||||||
@ -29,7 +28,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center" >
|
android:gravity="center">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="17dp"
|
android:layout_width="17dp"
|
||||||
@ -53,7 +52,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/user_info_layout"
|
android:layout_below="@id/user_info_layout"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
android:paddingBottom="10dp" >
|
android:paddingBottom="10dp">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/line_create"
|
android:id="@+id/line_create"
|
||||||
@ -70,7 +69,7 @@
|
|||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="visible" >
|
android:visibility="visible">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edt_group_name"
|
android:id="@+id/edt_group_name"
|
||||||
@ -82,8 +81,7 @@
|
|||||||
android:hint="请输入组名用于创建组..."
|
android:hint="请输入组名用于创建组..."
|
||||||
android:inputType="text"
|
android:inputType="text"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:textSize="18sp" >
|
android:textSize="18sp"></EditText>
|
||||||
</EditText>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp" >
|
android:paddingRight="10dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp" >
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -35,29 +35,29 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:hint="@string/text_show_iat_result"
|
|
||||||
android:gravity="top|left"
|
android:gravity="top|left"
|
||||||
|
android:hint="@string/text_show_iat_result"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/iat_contacts"
|
android:id="@+id/iat_contacts"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:hint="@string/text_show_contacts"
|
|
||||||
android:gravity="top|left"
|
android:gravity="top|left"
|
||||||
|
android:hint="@string/text_show_contacts"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="2dp"
|
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/iat_recognize"
|
android:id="@+id/iat_recognize"
|
||||||
@ -89,13 +89,12 @@
|
|||||||
android:id="@+id/languageText"
|
android:id="@+id/languageText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="点击设置小语种,当前语种:中文(普通话)"
|
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:textSize="20sp"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
/>
|
android:gravity="center_horizontal"
|
||||||
|
android:text="点击设置小语种,当前语种:中文(普通话)"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/iat_recognize_stream"
|
android:id="@+id/iat_recognize_stream"
|
||||||
@ -109,32 +108,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="上传联系人、词表,可以使云端识别联系人和词表更加准确,这里上传的内容对语义理解同样有效。"
|
android:text="上传词表,可以使云端识别更加准确,这里上传的内容对语义理解同样有效。"
|
||||||
android:textSize="@dimen/txt_size" />
|
android:textSize="@dimen/txt_size" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="2dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/iat_upload_contacts"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="上传联系人"
|
|
||||||
android:textSize="17sp" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/iat_upload_userwords"
|
android:id="@+id/iat_upload_userwords"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
android:text="上传词表"
|
android:text="上传词表"
|
||||||
android:textSize="17sp" />
|
android:textSize="17sp" />
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ifly_mnotice_image_container"
|
android:id="@+id/ifly_mnotice_image_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -5,12 +5,12 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp" >
|
android:paddingRight="10dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp" >
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -28,32 +28,44 @@
|
|||||||
android:background="@drawable/main_setting_btn_np" />
|
android:background="@drawable/main_setting_btn_np" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<EditText
|
<ScrollView
|
||||||
android:id="@+id/ise_eva_text"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="120dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_weight="1">
|
||||||
android:gravity="top|left"
|
|
||||||
android:textSize="20sp" />
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
<EditText
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/ise_result_text"
|
android:orientation="vertical">
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="200dp"
|
<EditText
|
||||||
android:layout_marginBottom="5dp"
|
android:id="@+id/ise_eva_text"
|
||||||
android:layout_weight="1"
|
android:layout_width="match_parent"
|
||||||
android:editable="false"
|
android:layout_height="360dp"
|
||||||
android:gravity="top|left"
|
android:layout_marginBottom="5dp"
|
||||||
android:hint="请点击“开始评测”按钮"
|
android:gravity="top|left"
|
||||||
android:textSize="16sp" />
|
android:textSize="13sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ise_result_text"
|
||||||
|
android:minHeight="200dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:hint="请点击“开始评测”按钮"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="2dp"
|
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/ise_start"
|
android:id="@+id/ise_start"
|
||||||
@ -75,10 +87,10 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="2dp"
|
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/ise_cancel"
|
android:id="@+id/ise_cancel"
|
||||||
|
@ -7,18 +7,19 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp" >
|
android:paddingRight="10dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp" >
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:text="讯飞语法示例"
|
android:text="讯飞语法示例"
|
||||||
|
android:textColor="@color/black"
|
||||||
android:textSize="30sp" />
|
android:textSize="30sp" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
@ -36,7 +37,7 @@
|
|||||||
android:layout_marginBottom="2dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/isr_grammar"
|
android:id="@+id/isr_grammar"
|
||||||
@ -54,7 +55,7 @@
|
|||||||
android:layout_marginBottom="2dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/isr_recognize"
|
android:id="@+id/isr_recognize"
|
||||||
@ -71,7 +72,7 @@
|
|||||||
android:layout_marginBottom="2dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/isr_stop"
|
android:id="@+id/isr_stop"
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:gravity="center" >
|
android:gravity="center">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
@ -27,7 +27,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/set_authId"
|
android:id="@+id/set_authId"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:hint="请输入 authId"/>
|
android:hint="请输入 authId" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/edt_result"
|
android:id="@+id/edt_result"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/isv_getpassword"
|
android:id="@+id/isv_getpassword"
|
||||||
@ -78,14 +78,14 @@
|
|||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:id="@+id/vocal_radioGroup1"
|
android:id="@+id/vocal_radioGroup1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:weightSum="2" >
|
android:weightSum="2">
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/vocal_radioEnroll"
|
android:id="@+id/vocal_radioEnroll"
|
||||||
@ -93,8 +93,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text=" 声纹注册"
|
android:text=" 声纹注册"
|
||||||
android:textSize="18sp" >
|
android:textSize="18sp"></RadioButton>
|
||||||
</RadioButton>
|
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/vocal_radioVerify"
|
android:id="@+id/vocal_radioVerify"
|
||||||
@ -102,8 +101,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text=" 1:1验证"
|
android:text=" 1:1验证"
|
||||||
android:textSize="18sp" >
|
android:textSize="18sp"></RadioButton>
|
||||||
</RadioButton>
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -111,7 +109,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/isv_reocrd"
|
android:id="@+id/isv_reocrd"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="3dip" >
|
android:paddingBottom="3dip">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/group_item_content"
|
android:id="@+id/group_item_content"
|
||||||
@ -13,7 +13,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="20dp"
|
android:layout_marginLeft="20dp"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="20sp" >
|
android:textSize="20sp"></TextView>
|
||||||
</TextView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -6,7 +6,7 @@
|
|||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:paddingBottom="3dip" >
|
android:paddingBottom="3dip">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/identify_item_number"
|
android:id="@+id/identify_item_number"
|
||||||
@ -15,6 +15,7 @@
|
|||||||
android:text="第一:"
|
android:text="第一:"
|
||||||
android:textColor="#ebf657"
|
android:textColor="#ebf657"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/identify_item_user"
|
android:id="@+id/identify_item_user"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -23,6 +24,7 @@
|
|||||||
android:text="18505511338"
|
android:text="18505511338"
|
||||||
android:textColor="#ebf657"
|
android:textColor="#ebf657"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/identify_item_score"
|
android:id="@+id/identify_item_score"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -4,15 +4,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/list_bg_color"
|
android:background="@drawable/list_bg_color"
|
||||||
android:descendantFocusability="blocksDescendants"
|
android:descendantFocusability="blocksDescendants"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btn"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="@dimen/margin_"
|
|
||||||
android:layout_marginRight="@dimen/margin_"
|
|
||||||
android:layout_marginTop="@dimen/pading_"
|
|
||||||
android:textSize="@dimen/btn_size" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -3,28 +3,101 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/layout_backgroud"
|
android:background="@drawable/layout_backgroud"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/title" />
|
<include layout="@layout/title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/edit_text"
|
android:id="@+id/tip"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/margin_"
|
android:layout_marginLeft="@dimen/margin_"
|
||||||
android:layout_marginRight="@dimen/margin_"
|
android:layout_marginRight="@dimen/margin_"
|
||||||
|
android:textColor="@color/white"
|
||||||
android:textSize="@dimen/txt_size" />
|
android:textSize="@dimen/txt_size" />
|
||||||
|
|
||||||
<ListView
|
<ScrollView
|
||||||
android:id="@+id/listview_main"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:orientation="vertical">
|
||||||
android:layout_marginLeft="5dp"
|
|
||||||
android:layout_marginRight="5dp"
|
<Button
|
||||||
android:cacheColorHint="@color/white"
|
android:id="@+id/iatBtn"
|
||||||
android:divider="@drawable/line_background"
|
android:layout_width="match_parent"
|
||||||
android:dividerHeight="@dimen/line_height"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="5dp" />
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="立刻体验语音听写"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/btn_size" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/asrBtn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="立刻体验语法识别"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/btn_size" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/nlpBtn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="立刻体验语义理解"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/btn_size" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/ttsBtn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="立刻体验语音合成"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/btn_size" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/iseBtn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="立刻体验语音评测"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/btn_size" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/faceBtn"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:text="立刻体验人脸识别"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="@dimen/btn_size" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -6,7 +6,7 @@
|
|||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="10dp" >
|
android:padding="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -21,7 +21,7 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center" >
|
android:gravity="center">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/online_img"
|
android:id="@+id/online_img"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/online_authid"
|
android:id="@+id/online_authid"
|
||||||
@ -46,20 +46,19 @@
|
|||||||
android:digits="abcdefghijklmnopqrstuvwxyz0123456789_"
|
android:digits="abcdefghijklmnopqrstuvwxyz0123456789_"
|
||||||
android:hint="请输入 authid"
|
android:hint="请输入 authid"
|
||||||
android:maxLength="18"
|
android:maxLength="18"
|
||||||
android:textSize="16sp" >
|
android:textSize="16sp">
|
||||||
|
|
||||||
<requestFocus />
|
<requestFocus />
|
||||||
</EditText>
|
</EditText>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/online_pick"
|
android:id="@+id/online_pick"
|
||||||
@ -83,7 +82,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/online_reg"
|
android:id="@+id/online_reg"
|
||||||
@ -108,7 +107,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_modle_delete"
|
android:id="@+id/btn_modle_delete"
|
||||||
@ -116,7 +115,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:text="@string/face_model_delete"/>
|
android:text="@string/face_model_delete" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_identity"
|
android:id="@+id/btn_identity"
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
android:gravity="center" >
|
android:gravity="center">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:textColor="@color/white"
|
||||||
android:text="讯飞语音示例"
|
android:text="讯飞语音示例"
|
||||||
android:textSize="30sp" />
|
android:textSize="30sp" />
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp" >
|
android:paddingRight="10dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp" >
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -44,14 +44,14 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:id="@+id/tts_rediogroup"
|
android:id="@+id/tts_rediogroup"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/tts_radioCloud"
|
android:id="@+id/tts_radioCloud"
|
||||||
@ -77,7 +77,7 @@
|
|||||||
android:layout_marginBottom="2dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tts_play"
|
android:id="@+id/tts_play"
|
||||||
@ -102,7 +102,7 @@
|
|||||||
android:layout_marginBottom="2dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tts_pause"
|
android:id="@+id/tts_pause"
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp" >
|
android:paddingRight="10dp">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp" >
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -46,7 +46,7 @@
|
|||||||
android:layout_marginBottom="2dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/text_understander"
|
android:id="@+id/text_understander"
|
||||||
@ -71,7 +71,7 @@
|
|||||||
android:layout_marginBottom="2dp"
|
android:layout_marginBottom="2dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/understander_stop"
|
android:id="@+id/understander_stop"
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<drawable name="line_background">#161823</drawable>
|
<drawable name="line_background">#161823</drawable>
|
||||||
|
|
||||||
<color name="white">#FFFFFF</color>
|
<color name="white">#FFFFFF</color>
|
||||||
|
<color name="black">#000</color>
|
||||||
|
|
||||||
<!-- 控件按下时显示的颜色 -->
|
<!-- 控件按下时显示的颜色 -->
|
||||||
<color name="list_backgroud_color">#2fb3cb</color>
|
<color name="list_backgroud_color">#2fb3cb</color>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="dialog" parent="@android:style/Theme.Dialog">
|
<style name="dialog" parent="@android:style/Theme.Dialog">
|
||||||
<item name="android:windowFrame">@null</item>
|
<item name="android:windowFrame">@null</item>
|
||||||
<item name="android:windowIsFloating">true</item>
|
<item name="android:windowIsFloating">true</item>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="iat_language_preference"
|
android:key="iat_language_preference"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:dialogTitle="请输入语速:在线(0-100)本地(0-200)"
|
android:dialogTitle="请输入语速:在线(0-100)本地(0-200)"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="understander_language_preference"
|
android:key="understander_language_preference"
|
||||||
android:title="语言设置"
|
android:title="语言设置"
|
||||||
@ -29,11 +29,11 @@
|
|||||||
android:summary="默认值:有标点 "
|
android:summary="默认值:有标点 "
|
||||||
android:defaultValue="1" />
|
android:defaultValue="1" />
|
||||||
|
|
||||||
<!-- <CheckBoxPreference -->
|
<!-- <CheckBoxPreference -->
|
||||||
<!-- android:key="nbest_preference" -->
|
<!-- android:key="nbest_preference" -->
|
||||||
<!-- android:title="@string/set_multiple_candidate_title" -->
|
<!-- android:title="@string/set_multiple_candidate_title" -->
|
||||||
<!-- android:summary="@string/set_multiple_candidate_summary" -->
|
<!-- android:summary="@string/set_multiple_candidate_summary" -->
|
||||||
<!-- android:defaultValue="false" /> -->
|
<!-- android:defaultValue="false" /> -->
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="url_preference"
|
android:key="url_preference"
|
||||||
@ -11,7 +11,7 @@
|
|||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="url_edit"
|
android:key="url_edit"
|
||||||
android:title="输入域名(优先级较高) 格式参考:域名(+:端口)"
|
android:title="输入域名(优先级较高) 格式参考:域名(+:端口)"
|
||||||
android:summary=""/>
|
android:summary="" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user