Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android verison is too old to trigger offline model download #8

Closed
theprashant-one opened this issue Aug 22, 2024 · 8 comments
Closed

Comments

@theprashant-one
Copy link

theprashant-one commented Aug 22, 2024

Hi, thank you for this awesome package!

my issue is that triggering model download failling (am on android 13)

sample code:

const data = ExpoSpeechRecognitionModule.getSpeechRecognitionServices()
      // ["com.google.android.as", "com.google.android.tts"]

const res = await ExpoSpeechRecognitionModule.getSupportedLocales({
        // Stil failling for - data[0], data[1]
        androidRecognitionServicePackage: "com.google.android.googlequicksearchbox", // also this
})

      /*
      {"installedLocales": ["en-US"], "locales": ["cmn-Hans-CN", "cmn-Hant-TW", "de-AT", "de-BE", "de-CH", "de-DE", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN", "en-SG", "en-US", "es-ES", "es-US", "fr-BE", "fr-CA", "fr-CH", "fr-FR", "hi-IN", "id-ID", "it-CH", "it-IT", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "th-TH", "tr-TR", "vi-VN"]}
      */

await ExpoSpeechRecognitionModule.androidTriggerOfflineModelDownload({
        locale: res.locales[6],
})

WhatsApp Image 2024-08-22 at 20 39 28_c20de576

@jamsch
Copy link
Owner

jamsch commented Aug 23, 2024

Hey @theprashant-one, good spotting! I hadn't yet implemented triggerModelDownload for Android 13 as it wasn't possible to listen for the status of the download in the SDK. As one temporary measure, the promise for androidTriggerOfflineModelDownload will have to instantly resolve, however you won't be able to know when the user has downloaded the model or if it failed.

@jamsch
Copy link
Owner

jamsch commented Aug 23, 2024

I've just published a release at v0.2.13 which should alllow Android 13 devices to open the model download dialog, however there's a few slight differences, as indicated here:

ExpoSpeechRecognitionModule.androidTriggerOfflineModelDownload({
    locale: props.locale,
  })
  .then((result) => {
    if (result.status === "opened_dialog") {
      // On Android 13, the status will be "opened_dialog" indicating that the model download dialog was opened.
      Alert.alert("Offline model download dialog opened.");
    } else if (result.status === "download_success") {
      // On Android 14+, the status will be "download_success" indicating that the model download was successful.
      Alert.alert("Offline model downloaded successfully!");
    }
  })
  .catch((err) => {
    Alert.alert("Failed to download offline model!", err.message);
  })

@theprashant-one
Copy link
Author

hi @jamsch thanks for quick reponse.
I will try this solution and let you know.

@theprashant-one
Copy link
Author

theprashant-one commented Aug 23, 2024

One interesting thing I found is that I've downloaded several language packages, as you can see below, but the installed locales remain 'en-US'. Any guidance here?

{"installedLocales": ["en-US"], "locales": ["cmn-Hans-CN", "cmn-Hant-TW", "de-AT", "de-BE", "de-CH", "de-DE", "en-AU", "en-CA", "en-GB", "en-IE", "en-IN", "en-SG", "en-US", "es-ES", "es-US", "fr-BE", "fr-CA", "fr-CH", "fr-FR", "hi-IN", "id-ID", "it-CH", "it-IT", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "th-TH", "tr-TR", "vi-VN"]}

this screenshot is from live transcribe settings menu (app from google)

WhatsApp Image 2024-08-23 at 18 01 59_b530aedb

@jamsch
Copy link
Owner

jamsch commented Aug 26, 2024

@theprashant-one The language models actually are installed under the Android System Intelligence app by default ("com.google.android.as"). On Samsung devices you can find the list of installed locales at:
Settings -> Security and Privacy -> More privacy settings -> Android System Intelligence -> On-device speech recognition

@jamsch
Copy link
Owner

jamsch commented Aug 26, 2024

A bunch of menus to go through, I also got a bit mixed up because there were two Google apps that had options to download offline voice models too.

Screen_Recording_20240826_193853_Android.System.Intelligence.mp4

@theprashant-one
Copy link
Author

@jamsch, I can now see the downloaded locale. Thanks again!

@jamsch
Copy link
Owner

jamsch commented Aug 29, 2024

Sweet, closing this issue

@jamsch jamsch closed this as completed Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants