Speech to Text failed in Android 12
hoyeunglee opened this issue · comments
I press start button but can not recognize speech to text,
log message as below
TypeScript
startButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isPermissionGranted()) {
speak("start listening");
startListening();
} else {
speak("request permission");
requestPermissions();
}
}
});
Java
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());
});
Java
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'
This item has been open without activity for 19 days. Provide a comment on status and remove "update needed" label.