alphacep / vosk-android-demo

Offline speech recognition for Android with Vosk library.
Apache License 2.0
734 stars 193 forks source link

How to switch the recognized language? #129

Open cl-6666 opened 3 years ago

cl-6666 commented 3 years ago

Hello, I have a problem. I don’t know how to switch languages. I’ve tested the English and the effect is okay. I want to try Chinese. How do I do it?

nshmyrev commented 3 years ago

Download

https://alphacephei.com/vosk/models/vosk-model-small-cn-0.3.zip

unpack over English files:

https://github.com/alphacep/vosk-android-demo/tree/master/models/src/main/assets/sync/model-android

modify grammar here and run:

https://github.com/alphacep/vosk-android-demo/blob/1725bde253128641e544471f875cf736474ee0a1/app/src/main/java/org/kaldi/demo/KaldiActivity.java#L143

it should work

cl-6666 commented 3 years ago

Thank you. For such a problem, I want to automatically switch the national language in the APP to avoid replacing the model every time. I want to put the prepared model in the project in advance. Is there a good way to generate the so library for the model? Is form dependent?

nshmyrev commented 3 years ago

If you want to support 2 languages inside the app you need 100 mb in the app. Not nice.

You can implement model download from the internet so users can pick the language.

k3b commented 3 years ago

see https://github.com/alphacep/vosk-android-demo/issues/54#issuecomment-851030622

r-bird commented 3 years ago

@cl-6666 I have written an example of how to switch the language on the fly when a button is pressed. See https://github.com/r-bird/vosk-android-demo/tree/multi_lang.

In this case the second language is German, but you should be able to adjust it to Chinese with little effort. Just:

The example is designed to work completely offline, so every language you add requires approx. 50 MB.

DeveloKing commented 2 years ago

Can someone explain me what's the problem with 50mb in a app. A game takes over 4gb. With that in mind, does a bigger module work, like a 2gb? Is the problem the space it takes or the computing power for it?

DeveloKing commented 2 years ago

I want to do a speech recognition app so the capability to recognize is above the space needed by the app

nshmyrev commented 2 years ago

Can someone explain me what's the problem with 50mb in a app. A game takes over 4gb.

There is no big problem, just take in account that bigger models are usually slower and might not run on android phone. Also, its not so nice to download say 300Mb just for voice input.

cdhiraj40 commented 2 years ago

There is no big problem, just take in account that bigger models are usually slower and might not run on android phone. Also, its not so nice to download say 300Mb just for voice input.

@nshmyrev I definitely can understand this. Do you suggest a proper way to handle voice triggers with kaldi and vosk + online model stored? I am thinking of working on something like this, I was able to achieve it offline but was wondering if it could happen online that would help users a lot. Thanks