vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

Model unpack fails without UUID file

Open Tadejo9 opened this issue 2 years ago • 2 comments

App fails to unpack the model with the following error:

java.lang.Error: Failed to unpack the model: model-en-us/uuid

None of the first three english models includes uuid subfolder.

This is the initModel method written using Kotlin. Uuid is not referenced anywhere in my code so i assume it is inside unpack method of StorageService class.

private fun initModel() {
        StorageService.unpack(this, "model-en-us", "model",
            { model: Model? ->
                this.model = model!!
                setUiState(AppState.READY)
            }
        ) { exception: IOException ->
            throw Error("Failed to unpack the model: ${exception.message}")
        }
    }

I have placed model folder on the same level as src AndroidStudioProjects/<App-name>/app/src AndroidStudioProjects/<App-name>/app/model

Is this location false?

Tadejo9 avatar Feb 07 '22 11:02 Tadejo9

Hi. UUID file is created by gradle:

https://github.com/alphacep/vosk-android-demo/blob/master/models/build.gradle#L19

nshmyrev avatar Feb 07 '22 12:02 nshmyrev

Hello, thank you for the response.

I figured out that i forgot to add :models to gradle.

Tadejo9 avatar Feb 07 '22 18:02 Tadejo9

@nshmyrev, what is this uuid used for? Is there any way to make it optional? Our problem is that we want to dynamically download the models, then load them in Vosk, but since this uuid is missing, it fails.

We also tried dynamically creating this uuid file where Vosk expects it, but it still fails.

The error is simply:

Error: /path/to/model/uuid

(and "/path/to/model/uuid" exists and has a random UUID in it)

laurent22 avatar May 03 '23 13:05 laurent22

what is this uuid used for?

To make sure model is sync between storage and aar.

Is there any way to make it optional? Our problem is that we want to dynamically download the models, then load them in Vosk, but since this uuid is missing, it fails.

If you don't need UUID, simply don't use it. Pick the code from

https://github.com/alphacep/vosk-android-service/tree/master/app/src/main/java/org/vosk/service/download

https://github.com/alphacep/vosk-android-service/blob/master/app/src/main/java/org/vosk/service/VoskRecognitionService.java#L83

nshmyrev avatar May 03 '23 13:05 nshmyrev

Thanks for your answer @nshmyrev. Unfortunately, we lack the knowledge to be able to edit and recompile the Vosk lib, especially since it's imported via another lib (react-native-vosk). What I'm wondering is why when I provide a UUID file, it still gives me this error?

Error: /path/to/model/uuid

Even though this file exists and has a valid UUID inside. Is there a certain requirement to get this file valid and accepted by the library? For us, that would be the easiest solution to just provide a random uuid, but we can't get that to work unfortunately.

laurent22 avatar Jun 11 '23 14:06 laurent22

Also why does it need to sync this between the storage and AAR? Our plan is to load the model files directly from storage, not from the AAR. Is it possible with the current implementation of the lib?

laurent22 avatar Jun 11 '23 14:06 laurent22

@laurent22 sorry, I misunderstood your question, you can obviously download models from the web and put them in storage. See

https://github.com/alphacep/vosk-android-service/tree/master/app/src/main/java/org/vosk/service/download

nshmyrev avatar Jun 11 '23 18:06 nshmyrev

@laurent22 let me know if you want me to implement this part, I can take a look

nshmyrev avatar Jun 11 '23 18:06 nshmyrev

Thanks @nshmyrev, I have replied on the pull request: https://github.com/laurent22/joplin/pull/8309

laurent22 avatar Jun 12 '23 10:06 laurent22

Good, actually same as https://github.com/alphacep/vosk-android-demo/issues/190

nshmyrev avatar Jun 28 '23 04:06 nshmyrev