Skip to content

Memory issue with speech:decode() #1

Description

@gungugugungu

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions