[Huawei Developers] John Wo:
Introduction

Automatic speech recognition (ASR) can recognize speech not longer than 60 Seconds and convert the input speech into text in real time. This service uses industry-leading deep learning technologies to achieve a recognition accuracy of over 95%. Currently, Mandarin Chinese (including Chinese-English bilingual speech), English, French, German, Spanish, and Italian can be recognized

Real-time result output

Available options: with and without speech pickup UI

Endpoint detection: Start and end points can be accurately located.

Silence detection: No voice packet is sent for silent part.

Intelligent conversion to digital formats: For example, the year 2020 can be recognized from voice input.

Follow all the steps mentioned in Basic Setup to start HMS integration on B4A Platform.

Refer to

https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201286424114350051&fid=0101246461018590361

Enable ML Kit in App gallery connect.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030130425.49087047327455603751530597815026:50511112015808:2800:B700317CD692E8214CD3F6C0822E37A28DCC190B76B94B05D526101AD2F51C72.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030130425.49087047327455603751530597815026:50511112015808:2800:B700317CD692E8214CD3F6C0822E37A28DCC190B76B94B05D526101AD2F51C72.png[/IMG]

Creating Wrapper Class

1. Downloading the AAR Packages and JSON File

Sign in to HUAWEI Developer and download the AAR packages required.

2. Open AAR packages with rar tool and rename the class.jar and AndroidManifest.xml files. And save those jar file inside libs folder (It is recommended that the two files can be renamed consistently with the AAR package names.)

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121110.75505126267803484385078626304840:50511112015808:2800:C5AC7903977BEDFBB81C0B260DBD5BFF98F1B5AA7B1CF08D2FF32C96787975DB.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121110.75505126267803484385078626304840:50511112015808:2800:C5AC7903977BEDFBB81C0B260DBD5BFF98F1B5AA7B1CF08D2FF32C96787975DB.png[/IMG]

3. Copy required permissions in the <manifest> section in B4A IDE.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121134.71446747667472978819705151477368:50511112015808:2800:2EF7E4688A000429CBFA5DEA272CBB48081E58BFD09785478707EDD11DC934D3.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121134.71446747667472978819705151477368:50511112015808:2800:2EF7E4688A000429CBFA5DEA272CBB48081E58BFD09785478707EDD11DC934D3.png[/IMG]

4. Copy all configurations in the <application> section.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121158.75153436768036074933354905445158:50511112015808:2800:473E9B222BA6D09D8341D88A85C823C444D8C1247FA2A81D0465C6F7444A7333.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121158.75153436768036074933354905445158:50511112015808:2800:473E9B222BA6D09D8341D88A85C823C444D8C1247FA2A81D0465C6F7444A7333.png[/IMG]

5. Change ${applicationId} to $PACKAGE$.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121322.80126857900449244035783884862275:50511112015808:2800:AE7FBF45361FB279A1D5B51908206823B79BA8F01E0FF571255B7A40888EA307.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121322.80126857900449244035783884862275:50511112015808:2800:AE7FBF45361FB279A1D5B51908206823B79BA8F01E0FF571255B7A40888EA307.png[/IMG]

6. Download the configuration file(agconnect-services.json) from App Gallery Connect

And Add the JSON File to the assets Folder of the AAR file as shown below.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121345.14020890773932458751830047047514:50511112015808:2800:A59558293319DD306A69EDF5DDEFC17D2F8C9566862BAFD1E65B3A303E76EDD0.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121345.14020890773932458751830047047514:50511112015808:2800:A59558293319DD306A69EDF5DDEFC17D2F8C9566862BAFD1E65B3A303E76EDD0.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121352.48168224078052783963995802281527:50511112015808:2800:89C79E2F946D1CFA0FDCC5E0566D3CD402F82C8F2DADC22D150D2E6C67970ED9.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121352.48168224078052783963995802281527:50511112015808:2800:89C79E2F946D1CFA0FDCC5E0566D3CD402F82C8F2DADC22D150D2E6C67970ED9.png[/IMG]

B4A will automatically incorporate files in the assets folder of an AAR package to the assets folder of your main project.

Encapsulating Java Files Using SLC

1. Create Library as parent and then create bin, libs and src as subfolder in the project directory.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121444.47462311848683177469814220292232:50511112015808:2800:5413C322994BC1C48F9B1DE59A9AF6A6E739CB20274D9EA2747CBD2A2F8E2F47.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121444.47462311848683177469814220292232:50511112015808:2800:5413C322994BC1C48F9B1DE59A9AF6A6E739CB20274D9EA2747CBD2A2F8E2F47.png[/IMG]

2. Develop java project inside the following path:

Choose Library Folder > src > b4x > asr > demo

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121451.53475461183155432616900406116188:50511112015808:2800:535C1DE59B326AAA425E1155909D0FB17A0E7C42B73F26CB722D788C5E36C428.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/671/191/2640091000001671191.20201030121451.53475461183155432616900406116188:50511112015808:2800:535C1DE59B326AAA425E1155909D0FB17A0E7C42B73F26CB722D788C5E36C428.png[/IMG]

3. Import the following two lines of code to each Java file.

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
import anywheresoftware.b4a.IOnActivityResult;

4. Add necessary annotations to the ASR Java files.

@Version(1.0f)@ShortName("Asr")@DependsOn(values={"agconnect-core-1.0.1.300.aar",
"tasks-1.3.1.302.aar",
"network-common-4.0.2.300.aar",
"network-grs-4.0.2.300.aar",
"okhttp-3.12.0.jar",
"okio-1.15.0.jar",
"ml-computer-agc-inner-2.0.1.300.aar",
"ml-computer-cloud-base-inner-2.0.1.300.aar",
"ml-computer-commonutils-inner-2.0.1.300.aar",
"ml-computer-ha-inner-2.0.1.300.aar",
"ml-computer-grs-inner-2.0.1.300.aar",
"ml-computer-net-2.0.1.300.aar",
"ml-computer-voice-asr-plugin-2.0.1.300.aar",
"ml-computer-vision-cloud-2.0.1.300.aar",
"ml-computer-voice-asr-2.0.1.300.aar"
})
@Permissions(values={"android.permission.INTERNET",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.RECORD_AUDIO",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.CHANGE_WIFI_STATE",
"android.permission.ACCESS_WIFI_STATE",
"android.permission.CHANGE_CONFIGURATION",
"android.permission.WAKE_LOCK"})

More details, you can click https://forums.developer.huawei.com/forumPortal/en/topic/0203394430060880031