38#include <pocketsphinx.h>
47#include <unordered_map>
49#define MAX_BUFFER 262144
53 Buffer(
size_t bufferSize) : size(bufferSize), data(new char[size]), count(0) {}
60 void fill(
const char* newData,
size_t newDataSize)
62 if (newDataSize > size - count)
68 std::memcpy(data + count, newData, newDataSize);
74 if (consumeSize >= count)
80 std::memmove(data, data + consumeSize, count - consumeSize);
85 void getInt16(int16_t* int16Array,
size_t length)
87 const int16_t* audioData =
reinterpret_cast<const int16_t*
>(data);
88 for (
size_t i = 0; i < length; ++i)
90 int16Array[i] = audioData[i];
119 std::mutex mMutexConfig;
121 ps_config_t* mConfig;
122 ps_decoder_t* mDecoder;
123 ps_endpointer_t* mEndPointer;
127 std::vector<std::string> mKeyWords;
161 void AddWord(std::string s_Rule, std::string s_Word);
void consume(size_t consumeSize)
Buffer(size_t bufferSize)
void getInt16(int16_t *int16Array, size_t length)
const char * getData() const
void fill(const char *newData, size_t newDataSize)
Management of the recognition class .
void setVolume(int volume)
void AddWord(std::string s_Rule, std::string s_Word)
void fillAudioBuffer(const char *data, size_t lenght)
Recognition(std::string pathtobin, std::string lang)