Skip to content

Commit

Permalink
Memory managment improvements, optimization of the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mativizo committed Mar 12, 2024
1 parent 2f9f7c8 commit b225d4b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
Binary file modified .sconsign.dblite
Binary file not shown.
Binary file modified demo/bin/VoskVoiceRecognition.windows.template_debug.x86_64.dll
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions src/VoskVoiceRecognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <string>
#include <fstream>
#include <thread>
#include <mutex>


using namespace godot;

Expand Down Expand Up @@ -160,12 +162,14 @@ void VoskVoiceRecognition::cleanup()
{
vosk_recognizer_free(recognizer);
p("Vosk Info", "Recognizer cleaned up", "cleanup()");
recognizer = nullptr;
}

if (model)
{
vosk_model_free(model);
p("Vosk Info", "Model cleaned up", "cleanup()");
model = nullptr;
}

Pa_Terminate();
Expand Down Expand Up @@ -277,9 +281,15 @@ void VoskVoiceRecognition::set_size_in_ms(int miliseconds)

void VoskVoiceRecognition::accumulate_audio_data(const float *data, unsigned long num_samples)
{
// accumulated_audio_data.insert(accumulated_audio_data.end(), data, data + num_samples);

size_t newSize = accumulated_audio_data.size() + num_samples;
accumulated_audio_data.reserve(newSize);
accumulated_audio_data.insert(accumulated_audio_data.end(), data, data + num_samples);

}


bool VoskVoiceRecognition::save_accumulated_audio()
{
const std::string filename = "z_test.wav";
Expand Down
Binary file modified src/VoskVoiceRecognition.windows.template_debug.x86_64.obj
Binary file not shown.

0 comments on commit b225d4b

Please sign in to comment.