1、文本识别服务
1.1、OCR打包后引入的证书问题
问题描述:
项目中依赖的SDK如下:
// 引入基础SDKapi "com.huawei.hms:ml-computer-vision-ocr:3.3.0.301"// 引入中英文文字识别模型包api "com.huawei.hms:ml-computer-vision-ocr-cn-model:3.3.0.301"
问题:引入端侧OCR识别,不使用云侧版本,当App打包完成之后,assets目录下会有多个证书,这些证书是用来做什么的,请说明如下五个证书的用途?

问题解答:
hmsrootcas.bks
updataesdkcas.bks
hmsincas.bks
grs_sp.bks
这些bks文件主要作用为资格验证和鉴权
ag_sdk_cbg_root.cer
证书被暴露作为公钥的预置,主要用于验签华为应用市场的合法性,这些证书没有安全风险,可以放心使用。
2、实时语音识别服务
2.1、asr中英文非华为手机是否可用
问题描述:
实时语音识别服务查看文档,其中中英文识别支持非华为手机,但是在服务价格文档里,如下图所示:

这里的意思是说华为手机免费,非华为手机收费吗?想确认以下几点:非华为手机是否可用,是否收费,美国是否可用?
问题解答:
Q:非华为手机是否可用?
A:中英文支持非华为手机。
Q:非华为手机是否收费?
A:免费。
Q:美国是否可用?
A:美国在支持的国家/地区,可用。
2.2、asr集成报错问题
问题描述:
环境: Unity2019.4.9f1导出的android Studio 工程
Android Gradle Plugin Version : 3.4.3
Gradle Version : 6.8
agconnect-services.json 文件放置于AS工程根目录中
[build.gradle(Project:Build)] 文件内容:
- allprojects {
- buildscript {
- repositories {
- google()
- jcenter()
- // 配置HMS Core SDK的Maven仓地址。
- maven {url 'https://developer.huawei.com/repo/'}
- flatDir {
- dirs 'libs'
- }
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:3.4.3'
- classpath 'com.huawei.agconnect:agcp:1.6.5.300'
- }
- }
-
- repositories {
- google()
- jcenter()
- flatDir {
- dirs "${project(':unityLibrary').projectDir}/libs"
- }
- maven { url "https://developer.huawei.com/repo/" }
- }
- }
-
- task clean(type: Delete) {
- delete rootProject.buildDir
- }
[build.gradle(Module: Build.launcher)] 文件内容:
- apply plugin: 'com.android.application'
- apply plugin: 'com.huawei.agconnect'
-
- dependencies {
- implementation project(':unityLibrary')
- }
-
- android {
- compileSdkVersion 32
- buildToolsVersion '32.0.0'
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- defaultConfig {
- minSdkVersion 24
- targetSdkVersion 32
- applicationId 'com.xxxxxxxxxxxxxxx'
- ndk {
- abiFilters 'armeabi-v7a', 'arm64-v8a'
- }
- versionCode 1
- versionName '1.00'
- }
-
- aaptOptions {
- noCompress = ['.tflite', '.unity3d', '.ress', '.resource', '.obb', 'html/privacy_policy.html', 'html/user_agreement.html']
- ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
- }
-
- lintOptions {
- abortOnError false
- }
-
- buildTypes {
- debug {
- minifyEnabled false
- useProguard false
- proguardFiles getDefaultProguardFile('proguard-android.txt')
- signingConfig signingConfigs.debug
- jniDebuggable true
- }
- release {
- minifyEnabled false
- useProguard false
- proguardFiles getDefaultProguardFile('proguard-android.txt')
- signingConfig signingConfigs.debug
- }
- }
-
- packagingOptions {
- doNotStrip '*/armeabi-v7a/*.so'
- doNotStrip '*/arm64-v8a/*.so'
- }
-
- bundle {
- language {
- enableSplit = false
- }
- density {
- enableSplit = false
- }
- abi {
- enableSplit = true
- }
- }
- ndkVersion '21.3.6528147'
- }
[build.gradle(Module: Build.unityLibrary)] 文件内容:
- apply plugin: 'com.android.library'
-
- dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation(name: 'alphabet-release', ext:'aar')
- implementation(name: 'android-gif-drawable-1.2.6', ext:'aar')
- implementation(name: 'AndroidPermissionManager', ext:'aar')
- implementation(name: 'arcore_client', ext:'aar')
- implementation(name: 'HUAWEI AR Engine Plugin_Required', ext:'aar')
- implementation(name: 'HUAWEI AR Engine SDK_v2.11.0', ext:'aar')
- implementation(name: 'HUAWEI_AR_Engine_UnityPlugin', ext:'aar')
- implementation(name: 'NatCorder', ext:'aar')
- implementation(name: 'NatRender', ext:'aar')
- implementation(name: 'ocr-release', ext:'aar')
- implementation(name: 'open_ad_sdk', ext:'aar')
- implementation(name: 'unityandroidpermissions', ext:'aar')
- implementation(name: 'UnityARCore', ext:'aar')
- implementation(name: 'UniWebView', ext:'aar')
- implementation(name: 'voice-release', ext:'aar')
- implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31'
- implementation 'androidx.browser:browser:1.2.0'
- implementation 'org.tensorflow:tensorflow-lite:2.4.0'
- implementation 'org.tensorflow:tensorflow-lite-gpu:2.4.0'
- implementation 'com.squareup.okhttp3:okhttp:3.12.1'
- // classification
- implementation 'com.huawei.hms:ml-computer-vision-classification:3.4.0.304'
- implementation 'com.huawei.hms:ml-computer-vision-image-classification-model:3.4.0.304'
- // object detection
- implementation 'com.huawei.hms:ml-computer-vision-object-detection-model:3.4.0.300'
- // OCR
- implementation 'com.huawei.hms:ml-computer-vision-ocr:3.4.0.301'
- implementation 'com.huawei.hms:ml-computer-vision-ocr-cn-model:3.4.0.301'
- // Automatic speech recognition SDK.
- implementation 'com.huawei.hms:ml-computer-voice-asr:3.4.0.302'
- // Automatic speech recognition plugin.
- implementation 'com.huawei.hms:ml-computer-voice-asr-plugin:3.4.0.302'
- // Automatic speech recognition Long voice SDK.
- implementation 'com.huawei.hms:ml-computer-voice-realtimetranscription:3.4.0.302'
- //implementation 'com.huawei.hms:hianalytics:6.4.0.300'
- }
- android {
- compileSdkVersion 32
- buildToolsVersion '32.0.0'
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- defaultConfig {
- minSdkVersion 24
- targetSdkVersion 32
- ndk {
- abiFilters 'armeabi-v7a', 'arm64-v8a'
- }
- versionCode 1
- versionName '1.00'
- consumerProguardFiles 'proguard-unity.txt'
- }
- lintOptions {
- abortOnError false
- }
- aaptOptions {
- ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
- }
- packagingOptions {
- doNotStrip '*/armeabi-v7a/*.so'
- doNotStrip '*/arm64-v8a/*.so'
- }
- ndkVersion '21.3.6528147'
- }
ASR错误Log信息:
2022-04-15 09:49:40.076 28731-29252/com.xxxxxxxx I/HaLogExecutor: type 1 mapValue:{package=com.xxxxxxxxx, appid=com.xxxxxxx, appName=xxxxx, version=ml-computer-voice-asr:3.4.0.302, service=MLKit, transId=65649995-1848-4baf-8c4f-03ad9b00cfbd, operator=46000, networkType=wifi, apkVersion=, apiName=, countryCode=CN, deviceType=TAS-AL00, emuiVersion=EmotionUI_12.0.0, moduleName=MLKitAsr, moduleVersion=3.4.0.302, deviceCategory=, applanguage=zh, speechStartTime=1649987379713, speechEndTime=, firstWordCost=, lastWordCost=, voiceStreamTime=, uploadVoiceSize=, textLength=, chainBuildingDelay=, result=40, resultDetail=[403002]Service unavailable}
2022-04-15 09:49:40.077 28731-28731/com.xxxxxxxxxx E/VoiceUtils: SpeechRecognitionListener::onError: ,subError code: 3002,errorMessage: Service unavailable
OCR错误Log信息为:
VoiceUtils: SpeechRecognitionListener::onError: ,subError code: 3002,errorMessage: Service unavailable
OcrUtils: [Failure]Incorrect parameter. This exception is irrelevant to services.
之前使用Unity2019.2.4f1导出AS工程,只有一个build.gradle, 在此环境中功能正常,现在使用的是Unity2019.4.9f1会报以上错误。
问题解答:
将agconnect-services.json配置文件放到应用的根目录下,不是整个工程的根目录下,如下图所示:

OK,今天的内容就这么多!
欲了解更多更全技术文章,欢迎访问https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh