Speech to text failed

Ho Yeung, Lee 1 Reputation point
2024-06-02T00:48:53.95+00:00

Updated:

I press start button but can not recognize speech to text,

log message as below

startButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (isPermissionGranted()) {
            speak("start listening");
            startListening();

        } else {
            speak("request permission");
            requestPermissions();
        }
    }
});
stopButton = findViewById(R.id.stoprecord);
stopButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        stopRecording();
    }
});


// Initialize the Speech SDK
try {
    SpeechConfig config = SpeechConfig.fromSubscription("xxx", "East US");
    recognizer = new SpeechRecognizer(config);
} catch (Exception ex) {
    // Handle initialization error
}
// Handle speech recognition result
recognizer.recognizing.addEventListener((s, e) -> {
    final String recognizedText = e.getResult().getText();
    runOnUiThread(() -> textView.setText(recognizedText));
});

recognizer.recognized.addEventListener((s, e) -> {
    final String recognizedText = e.getResult().getText();
    runOnUiThread(() -> textView.setText(recognizedText));
});

recognizer.canceled.addEventListener((s, e) -> {
    final String cancellationDetails = e.getResult().getReason().toString();
    runOnUiThread(() -> Toast.makeText(this, "Speech Recognition canceled: " + cancellationDetails, Toast.LENGTH_SHORT).show());
});

public void startRecording() {
    try {
        recognizer.startContinuousRecognitionAsync();
    } catch (Exception ex) {
        // Handle start recording error
        textView.setText("start recording " + ex.getMessage());
    }
}

public void stopRecording() {
    try {
        recognizer.stopContinuousRecognitionAsync();
    } catch (Exception ex) {
        // Handle stop recording error
        textView.setText("stop recording " + ex.getMessage());
    }
}

I Connected to TTS engine

2024-06-03 21:36:28.736 3443-3507 TextToSpeech com.example.voicebot I Setting up the connection to TTS engine...

2024-06-03 21:36:43.775 3443-3461 System com.example.voicebot W A resource failed to call close.

2024-06-03 21:36:47.753 3443-3556 libOpenSLES com.example.voicebot W Conversion from OpenSL ES positional channel mask 0x4 to Android mask 0 loses channels

2024-06-03 21:36:47.753 3443-3556 libOpenSLES com.example.voicebot I Emulating old channel mask behavior (ignoring positional mask 0x4, using default mask 0x10 based on channel count of 1)

2024-06-03 21:36:47.753 3443-3556 AudioRecord com.example.voicebot D set(): 0xb31452f0, inputSource 0, sampleRate 16000, format 0x1, channelMask 0x10, frameCount 0, notificationFrames 0, sessionId 0, transferType 1, flags 0x5, identity AttributionSourceState{pid: 3443, uid: 10194, packageName: (null), attributionTag: (null), token: , renouncedPermissions: (null), next: []} uid 10194, pid 3443

2024-06-03 21:36:47.820 3443-3556 AudioRecord com.example.voicebot D openRecord_l: 0xb31452f0, mCblk = 0xb2ef9000

2024-06-03 21:36:47.821 3443-3556 AudioRecord com.example.voicebot D stop(503): 0xb31452f0, mActive:0

2024-06-03 21:36:47.822 3443-3556 AudioRecord com.example.voicebot D start(503): 0xb31452f0, sync event 0 trigger session 0

2024-06-03 21:36:47.837 3443-3556 AudioRecord com.example.voicebot D start(503): return status 0

2024-06-03 21:36:50.064 3443-3556 AudioRecord com.example.voicebot D stop(503): 0xb31452f0, mActive:1

2024-06-03 21:36:50.064 3443-3556 AudioTrackShared com.example.voicebot D this(0xad91e620), mCblk(0xb2ef9000), front(33920), mIsOut 0, interrupt() FUTEX_WAKE

2024-06-03 21:36:50.085 3443-3443 Compatibil...geReporter com.example.voicebot D Compat change id reported: 147798919; UID 10194; state: ENABLED

2024-06-03 21:36:50.115 1357-1357 ndroid.systemu com.android.systemui E Failed to open APK '/data/app/~~tVvOs62kd4mtP2-CTe0r8g==/com.example.voicebot-FAxNebhDYH-5ivlJNg9rhg==/base.apk': I/O error

2024-06-03 21:36:50.117 1357-1357 ndroid.systemu com.android.systemui E Failed to open APK '/data/app/~~tVvOs62kd4mtP2-CTe0r8g==/com.example.voicebot-FAxNebhDYH-5ivlJNg9rhg==/base.apk': I/O error

2024-06-03 21:36:50.119 3443-3556 AudioRecord com.example.voicebot D stop(503) done

2024-06-03 21:36:50.119 1357-1357 ResourcesManager com.android.systemui E failed to add asset path '/data/app/~~tVvOs62kd4mtP2-CTe0r8g==/com.example.voicebot-FAxNebhDYH-5ivlJNg9rhg==/base.apk'

                                                                                                java.io.IOException: Failed to load asset path /data/app/~~tVvOs62kd4mtP2-CTe0r8g==/com.example.voicebot-FAxNebhDYH-5ivlJNg9rhg==/base.apk

                                                                                                	at android.content.res.ApkAssets.nativeLoad(Native Method)

                                                                                                	at android.content.res.ApkAssets.<init>(ApkAssets.java:295)

                                                                                                	at android.content.res.ApkAssets.loadFromPath(ApkAssets.java:144)

                                                                                                	at android.app.ResourcesManager.loadApkAssets(ResourcesManager.java:454)

                                                                                                	at android.app.ResourcesManager.access$000(ResourcesManager.java:72)

                                                                                                	at android.app.ResourcesManager$ApkAssetsSupplier.load(ResourcesManager.java:168)

                                                                                                	at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:530)

                                                                                                	at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:612)

                                                                                                	at android.app.ResourcesManager.findOrCreateResourcesImplForKeyLocked(ResourcesManager.java:664)

                                                                                                	at android.app.ResourcesManager.createResources(ResourcesManager.java:1011)

                                                                                                	at android.app.ResourcesManager.getResources(ResourcesManager.java:1114)

                                                                                                	at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2409)

                                                                                                	at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:1751)

                                                                                                	at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:1737)

                                                                                                	at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:1506)

                                                                                                	at android.app.ApplicationPackageManager.loadUnbadgedItemIcon(ApplicationPackageManager.java:3029)

                                                                                                	at android.content.pm.PackageItemInfo.loadUnbadgedIcon(PackageItemInfo.java:290)

                                                                                                	at com.android.systemui.toast.SystemUIToast.getBadgedIcon(SystemUIToast.java:284)

                                                                                                	at com.android.systemui.toast.SystemUIToast.inflateToastView(SystemUIToast.java:198)

                                                                                                	at com.android.systemui.toast.SystemUIToast.<init>(SystemUIToast.java:90)

                                                                                                	at com.android.systemui.toast.SystemUIToast.<init>(SystemUIToast.java:77)

                                                                                                	at com.android.systemui.toast.ToastFactory.createToast(ToastFactory.java:78)

                                                                                                	at com.android.systemui.toast.ToastUI.lambda$showToast$0(ToastUI.java:113)

                                                                                                	at com.android.systemui.toast.ToastUI.$r8$lambda$w_gPCh3F8Xxn1jN4lkQZoUci71c(Unknown Source:0)

                                                                                                	at com.android.systemui.toast.ToastUI$$ExternalSyntheticLambda0.run(Unknown Source:16)

                                                                                                	at com.android.systemui.toast.ToastUI.showToast(ToastUI.java:140)

                                                                                                	at com.android.systemui.statusbar.CommandQueue$H.handleMessage(CommandQueue.java:1431)

                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:106)

                                                                                                	at android.os.Looper.loopOnce(Looper.java:207)

                                                                                                	at android.os.Looper.loop(Looper.java:294)

                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:7881)

                                                                                                	at java.lang.reflect.Method.invoke(Native Method)

                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)

                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,516 questions
{count} votes