alphacep / vosk-android-demo

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

Memory issue #176

Closed DjToMeK27 closed 2 years ago

DjToMeK27 commented 2 years ago

Hello! So in my application I am using implementation group: 'com.alphacephei', name: 'vosk-android', version: '0.3.32'

with Vosk running in Service

private void initModel() {
        StorageService.unpack(this, "model-en-us", "model",
                new Callback<Model>() {
                    @Override
                    public void onComplete(Model model) {
                        VoskSpeechRecognitionService.this.model = model;
                        VoskSpeechRecognitionService.this.recognizeMicrophone();
                    }
                },
                new Callback<IOException>() {
                    @Override
                    public void onComplete(IOException exception) {
                        // exception.printStackTrace();
                    }
                });
    }
private void recognizeMicrophone() {
   speechThread = new Thread(new Runnable() {
            @Override
            public void run() {
                if (searching)
                    return;

                searching = true;
                try {
                    Recognizer rec = new Recognizer(model, 16000.0f);
                    speechService = new SpeechService(rec, 16000.0f);
                    speechService.startListening(VoskSpeechRecognitionService.this);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        speechThread.start();
}

So this is running 24/7. I check onResult if word is found. Everything works great

The problem I see is that this is using more and more memory each day passes. My app used around 100MB memory, but after X days I saw it using around 450mb+. So I don't know if there is any problem with running this 24/7? Also I am sometimes pausing speech for X seconds and then unpause, if that can maybe cause any issues?

Thank you!

nshmyrev commented 2 years ago

Yeah, we have multiple reports about it. I will try to look soon. We track the original issue here:

https://github.com/alphacep/vosk-android-demo/issues/121

DjToMeK27 commented 2 years ago

Ok great! Thank you!