csdcorp / speech_to_text

A Flutter plugin that exposes device specific text to speech recognition capability.
BSD 3-Clause "New" or "Revised" License
387 stars 235 forks source link

How to overcome error_language_not_supported with `onDevice: true` `SpeechListenOptions`? #541

Closed MrCsabaToth closed 2 months ago

MrCsabaToth commented 3 months ago

I checked that assistant is enabled on my phone, languages are installed (although I think that's for off-line TTS?), I configured language in any place I could find. My Android app has microphone permissions.

The reported system locale for STT is en_US and I confirmed it is among the enumerated locales by stt.

D/SpeechToTextPlugin( 9972): before setup intent
D/SpeechToTextPlugin( 9972): setupRecognizerIntent
D/SpeechToTextPlugin( 9972): after setup intent
D/SpeechToTextPlugin( 9972): Start listening
D/SpeechToTextPlugin( 9972): setupRecognizerIntent
D/SpeechToTextPlugin( 9972): Notify status:listening
D/SpeechToTextPlugin( 9972): Start listening done
D/SpeechToTextPlugin( 9972): Creating recognizer
D/SpeechToTextPlugin( 9972): Setting on device listener
D/SpeechToTextPlugin( 9972): In RecognizerIntent apply
D/SpeechToTextPlugin( 9972): put model
D/SpeechToTextPlugin( 9972): put package
D/SpeechToTextPlugin( 9972): put partial
D/SpeechToTextPlugin( 9972): In RecognizerIntent apply
D/SpeechToTextPlugin( 9972): put model
D/SpeechToTextPlugin( 9972): put package
D/SpeechToTextPlugin( 9972): put partial
D/SpeechToTextPlugin( 9972): put languageTag
I/flutter ( 9972): 2024-07-30T22:26:00.467556 Received listener status: listening, listening: true
[log] 2024-07-30T22:26:00.467556 Received listener status: listening, listening: true
[log] audio level: -2.0
[log] 2024-07-30T22:26:00.677535 Received listener status: notListening, listening: false
[log] 2024-07-30T22:26:00.678130 Received listener status: done, listening: false
D/SpeechToTextPlugin( 9972): rmsDB -2.0 / -2.0
D/SpeechToTextPlugin( 9972): Error 12 after start at 213 -2.0 / -2.0
D/SpeechToTextPlugin( 9972): Notify status:notListening
D/SpeechToTextPlugin( 9972): Notify status:doneNoResult
I/flutter ( 9972): 2024-07-30T22:26:00.677535 Received listener status: notListening, listening: false
I/flutter ( 9972): 2024-07-30T22:26:00.678130 Received listener status: done, listening: false
I/flutter ( 9972): 2024-07-30T22:26:00.679860 Received error status: SpeechRecognitionError msg: error_language_not_supported, permanent: true, listening: false

Haven't figured out what is this about yet. I'm not even trying anything Spanish, I just need transcription of native US English speech, nothing special. The phone is US as well, everything is US. (Once I get this working I may add more languages)

MrCsabaToth commented 3 months ago

More details: the phone in question is a 2022 Motorola Razr with Android 13. I tried with Android 14 as well, and same results

MrCsabaToth commented 3 months ago

The reason for the error was the onDevice: true in the SpeechListenOptions. When I set that to true I receive the error, while when it is false STT works. I'm not sure how to get it to work onDevice: true, IMHO I have the required languages on device, but oh well...

sowens-csd commented 2 months ago

This is fixed in 7.0.0-beta.3 available now on pub.dev. Turns out Android is expecting a '-' instead of '_' though both work for online only the dash version works for on device.

MrCsabaToth commented 2 months ago

Wow. I've seen that TTS plugins used the dash! So I can simply replace the underscore with dash and it'll work? That will match the TTS direction.

sowens-csd commented 2 months ago

Now available in 7.0.0 on pub.dev