bjornbytes / lua-deepspeech

Lua Library for Speech Recognition
MIT License
24 stars 0 forks source link

Memory issue with speech:decode() #1

Open gungugugungu opened 4 months ago

gungugugungu commented 4 months ago

Hi! I'm pretty sure this repository is abandoned, but I still wanted to post here since I knew nothing better. I'm trying to use this library along with love2d's mic recording system, but after turning all samples into a table of 16 bit numbers, it just throws this:

...
16375 -143
16376 -101
16377 -69
16378 -39
16379 0
16380 53
16381 112
16382 171
Done with all 16383 samples
malloc(): invalid size (unsorted)
Aborted (core dumped)

Here's my code for decoding all of this:

        local data = recording_device:stop()
        print(data:type())
        if data ~= nil then
            local samples = {}
            for i = 0, data:getSampleCount()-1 do
                local sample = math.floor(data:getSample(i) * 32767)
                print(i .. " " .. sample)
                table.insert(samples, sample)
            end
            print("Done with all " .. data:getSampleCount() ..  " samples")

            local decoded_text = speech.decode(samples)
            print("apparently decoded everything")
            print("command: " .. command)
            print("originally decoded text: " .. decoded_text)
            if type(decoded_text) == "string" then
                command = decoded_text:lower()
                exec_command()
            else
                print("Failed to decode speech")
            end
        end

to be clear, I also initalized the library already. What did I do wrong?

bjornbytes commented 4 months ago

Hi, are you able to share your full main.lua? I'd like to try running it myself to try to reproduce the issue so I can dig into the crash. Otherwise, I'll try to create my own test case based on the snippet.

gungugugungu commented 4 months ago

Hi, first of all, thanks for responding! I can share the main.lua, but it is a gui application mean't as a personal assistant. Since it also requires a few other files, I'll also provide them in a zip. Also, very sorry for this, but the model and scorer won't fit in this zip, so I'll attach them in the next message main files.zip

gungugugungu commented 4 months ago

Well they don't fit here either. They're just the model and scorer I downloaded from the 0.9.3 releases page renamed to model.pbmm and scorer.scorer

bjornbytes commented 3 months ago

It seems like this has to do with the buffer size passed to .decode, deepspeech only likes certain powers of 2 or something. Still investigating