Open tim-gromeyer opened 1 year ago
Hi
It is hard to figure out what is wrong without binary in hand. It might be a memory corruption from some external code. I can suggest you the following to check the problem:
I called vosk_recognizer_free
directly after the construction. It still crashes. That's the code I used:
model = vosk_model_new(QString(modelDir() + lang).toUtf8());
if (model) {
qDebug() << "[debug] Loaded model, language:" << lang;
globalRecognizer = vosk_recognizer_new(model, 16000.0);
vosk_recognizer_free(globalRecognizer);
Thank you for the quick response. It's my first time actually collecting a stacktrace. Always did it in QtCreator. So if I did something wrong you know why. But anyway here it is:
#0 0x000055555557b591 in Recognizer::~Recognizer() (this=0x7fffe04183c0, __in_chrg=<optimized out>)
at /home/tim/qtprojegt/VoiceAssistant/src/recognizer.cpp:325
#1 0x00007ffff6369a5e in vosk_recognizer_free () at /home/tim/qtprojegt/VoiceAssistant/vosk/libvosk.so
#2 0x000055555557b5a8 in Recognizer::~Recognizer() (this=0x7fffe04183c0, __in_chrg=<optimized out>)
at /home/tim/qtprojegt/VoiceAssistant/src/recognizer.cpp:326
#3 0x00007ffff6369a5e in vosk_recognizer_free () at /home/tim/qtprojegt/VoiceAssistant/vosk/libvosk.so
#4 0x000055555557b5a8 in Recognizer::~Recognizer() (this=0x7fffe04183c0, __in_chrg=<optimized out>)
at /home/tim/qtprojegt/VoiceAssistant/src/recognizer.cpp:326
#5 0x00007ffff6369a5e in vosk_recognizer_free () at /home/tim/qtprojegt/VoiceAssistant/vosk/libvosk.so
#6 0x000055555557b5a8 in Recognizer::~Recognizer() (this=0x7fffe04183c0, __in_chrg=<optimized out>)
at /home/tim/qtprojegt/VoiceAssistant/src/recognizer.cpp:326
#7 0x00007ffff6369a5e in vosk_recognizer_free () at /home/tim/qtprojegt/VoiceAssistant/vosk/libvosk.so
#8 0x000055555557b5a8 in Recognizer::~Recognizer() (this=0x7fffe04183c0, __in_chrg=<optimized out>)
at /home/tim/qtprojegt/VoiceAssistant/src/recognizer.cpp:326
#9 0x00007ffff6369a5e in vosk_recognizer_free () at /home/tim/qtprojegt/VoiceAssistant/vosk/libvosk.so
Now I try to run it with valgrind.
Ah valgrind is the tool named memcheck in QtCreator. I already tried to run it several times but after closing the window nothing happens. Waiting for 1/2 hour and still nothing happened. So vallgrind doesn't help here.
Valgrind is already running for 36 minutes. I will let it run and go to bed.
#0 0x000055555557b591 in Recognizer::~Recognizer() (this=0x7fffe04183c0, __in_chrg=<optimized out>)
at /home/tim/qtprojegt/VoiceAssistant/src/recognizer.cpp:325
What is this? A trace with circular dependency? Maybe you can call your class something else, not Recognizer? Try it. We probably need namespace in vosk.
It actually worked, funnily enough. Such a small detail I never would have thought of. Anyway, thank you very much!
We need to introduce namespace in vosk sources, reopening for now
About me and what I'm trying
Hello, my name is Tim Gromeyer and I'm trying to create a voice assistant using this library.
The problem
The recognition works really well and the models are small too. But there is something wrong with the code:
Every time I call
vosk_recognizer_free
the project crashes.Here the line in the code, currently commented out: https://github.com/tim-gromeyer/VoiceAssistant/blob/main/src/recognizer.cpp#L325.
VoskRecognizer set up
I set up the
VoskModel
in a function called viastd::thread(&myFunction).detach()
. The recognizer is set up in the same function as the model but I also tried to set it up in the apps main thread which changed absolutely nothing.Why I need help
I can't debug what's happening in
vosk_recognizer_free
because I simply doesn't have the necessary resources(memory).System information
Edit:
Steps to reproduce:
git clone https://github.com/tim-gromeyer/VoiceAssistant
mkdir -p VoiceAssistant/build && cd VoiceAssistant/build
cmake ..
(if you miss some dependency I suggest apt-file),cmake --build . -j3
./voiceassistant
2nd edit: Finx formatting
Thank you all for developing such a nice library and also thanks in advance!