ccoreilly / LocalSTT

Android Speech Recognition Service using Vosk/Kaldi and Mozilla DeepSpeech
GNU General Public License v3.0
92 stars 27 forks source link

more than one language #4

Open ippocratis opened 2 years ago

ippocratis commented 2 years ago

So as naming is hardcoded I have to replace vosk model files inside vosk-catala folder. What if I need a second language? English and another?

ccoreilly commented 2 years ago

Regarding the model path, you can replace the name here.

In order to have two languages I guess the easiest way is to create two services. Just duplicate the VoskRecognitionService and rename it to something else. You also need to register it to handle intents here (create a new service entry). You'll need to switch everytime in your phone's preferences or as you're using K9nele I think it'll let you choose, right?

There is a way to get the language from the intent. I think it is the language of the keyboard but maybe it is just the language of the phone. If it were that of the keyboard you could use it to load one model or another.

Another alternative would be to show a list of available SpeechRecognizers in the SpeechActivity. You can pass a second parameter to SpeechRecognizer.createSpeechRecognizer (SpeechActivity.java#L110) defining the exact recognizer service to use (otherwise it uses the one you set as default).

I hope it helps. I might one day do this myself but I have no time right now.

ippocratis commented 2 years ago

Thanks for pointing out I think I'll gonna try dublicating VoskRecognitionService kõnele lets you select on the popup voice input ''keyboard" yes The thing is I have zero experience with android studio but I hope its not gonna be that hard Thanks for your amazing app btw Its the only reliable solution to have an open source speech to text service on a degoogled device atm

ippocratis commented 2 years ago

can not build

''' Could not GET 'https://dl.bintray.com/alphacep/vosk/com/alphacep/vosk-android/0.3.15/vosk-android-0.3.15.pom'. Received status code 403 from server: Forbidden Disable Gradle 'offline mode' and sync project '''

toggling gradle offline mode syncs but throws error ''' No cached version of com.alphacep:vosk-android:0.3.15 available for offline mode. '''

looks like bintray and jcenter is shuting down https://stackoverflow.com/a/67804820 so i cant see how i can move forward

maybe open an issue on vosk git? thanks

ccoreilly commented 2 years ago

Mmm true. They moved it to their own maven repository but version 0.3.15 is no longer available and the API changed a bit. I'll have a look see if I can update the repository to a state that builds.

ippocratis commented 2 years ago

Thanks

ccoreilly commented 2 years ago

I pushed a new commit with the necessary changes and checked that it builds and works on Android 9. Let me know if you manage to build with your changes!

ippocratis commented 2 years ago

thanks again app is buildable now i compiled an english apk the vosk model for my language is 1gb thou and when i try to build with two languages i get error "Out of memory: Required array size too large. Please fix the project's Gradle settings." i'll try to fix that , i'll search a bit btw app stand alone still stays in loading condition but works great used in konele thanks again and take care

ccoreilly commented 2 years ago

Great to here that. May I ask what OS and version you're running? Does it stay in the loading status if you for example click on the mic icon of your keyboard?

ippocratis commented 2 years ago

Great to here that. May I ask what OS and version you're running? Does it stay in the loading status if you for example click on the mic icon of your keyboard?

on a redmi note 9s with arrow os with microg (custom rom) on it (android11) and it behaves the same either by the anysoft keyboard mic or the localstt app it self

logcat_08-04-2021_23-13-21.txt

i cant figure out anything out of the logcat

" Waiting to send key to Window{ecd0591 u0 cat.oreilly.localstt/cat.oreilly.localstt.SpeechActivity} because there are unprocessed events that may cause focus to change "

sounds relative but no idea what it may mean