Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ implementation (provided in this issue) #56

Open
Stypox opened this issue Sep 5, 2024 · 3 comments
Open

C++ implementation (provided in this issue) #56

Stypox opened this issue Sep 5, 2024 · 3 comments

Comments

@Stypox
Copy link

Stypox commented Sep 5, 2024

Today I spent a bit of time on implementing a C++ version of this library that can run the "First iteration siamese" model using TFLite/LiteRT. I'm providing it here in case someone else needs it.

main.cpp
#include <cstdio>
#include <vector>

#include <tensorflow/lite/interpreter.h>
#include <tensorflow/lite/kernels/register.h>
#include <tensorflow/lite/model.h>
#include <tensorflow/lite/optional_debug_tools.h>

using f32 = float;
#include "embeddings.h"


class HotwordDetector {

    std::unique_ptr<tflite::FlatBufferModel> lmc;
    std::unique_ptr<tflite::FlatBufferModel> bm;

    std::unique_ptr<tflite::Interpreter> lmcInterpreter;
    int lmcInputIndex;
    int lmcOutputIndex;

    std::unique_ptr<tflite::Interpreter> bmInterpreter;
    int bmInputIndex;
    int bmOutputIndex;

    std::vector<std::array<f32, 128>> embeddings;


public:

    HotwordDetector()
    {
    }

    int init(
        const char* logMelCalcPath,
        const char* baseModelPath,
        std::vector<std::array<f32, 128>> newEmbeddings
    ) {
        lmc = tflite::FlatBufferModel::BuildFromFile(logMelCalcPath);
        if (lmc == nullptr) {
            return 2 + 0;
        }

        bm = tflite::FlatBufferModel::BuildFromFile(baseModelPath);
        if (bm == nullptr) {
            return 2 + 1;
        }

        tflite::ops::builtin::BuiltinOpResolver lmcResolver;
        tflite::InterpreterBuilder lmcInterpreterBuilder(*lmc, lmcResolver);
        lmcInterpreterBuilder(&lmcInterpreter);
        if (lmcInterpreter == nullptr) {
            return 4 + 0;
        }
        if (lmcInterpreter->AllocateTensors() != kTfLiteOk) {
            return 6 + 0;
        }

        tflite::ops::builtin::BuiltinOpResolver bmResolver;
        tflite::InterpreterBuilder bmInterpreterBuilder(*bm, bmResolver);
        bmInterpreterBuilder(&bmInterpreter);
        if (bmInterpreter == nullptr) {
            return 4 + 1;
        }
        if (bmInterpreter->AllocateTensors() != kTfLiteOk) {
            return 6 + 1;
        }

        if (newEmbeddings.size() <= 4) {
            return 8;
        }
        embeddings = newEmbeddings;
        return 0;
    }

    f32 process_frame(std::array<f32, 16000> audio) {
        // TODO implement silence check

        // normalize the input
        f32 max_val = *std::max_element(audio.begin(), audio.end());
        std::transform(audio.begin(), audio.end(), audio.begin(),
                [max_val](f32 x) { return x / max_val; });

        // set the logMelCalc model input
        f32* lmcInputTensor = lmcInterpreter->typed_input_tensor<f32>(0);
        std::copy(audio.begin(), audio.end(), lmcInputTensor);

        // invoke the logMelCalc model
        lmcInterpreter->Invoke();

        // obtain the logMelCalc output and set the baseModel input
        f32* lmcOutputTensor = lmcInterpreter->typed_output_tensor<f32>(0);
        f32* bmInputTensor = bmInterpreter->typed_input_tensor<f32>(0);
        std::copy(lmcOutputTensor, lmcOutputTensor + 98*64, bmInputTensor);

        // invoke the baseModel model
        bmInterpreter->Invoke();

        // obtain the baseModel output (i.e. the calculated embeddings)
        f32* bmOutputTensor = bmInterpreter->typed_output_tensor<f32>(0);
        std::array<f32, 128> bmOutput;
        std::copy(bmOutputTensor, bmOutputTensor + bmOutput.size(), bmOutput.begin());

        // calculate distances from embeddings
        std::vector<f32> distances;
        for (const auto& embedding : embeddings) {
            f32 sum = 0.0;
            for (size_t i = 0; i < 128; ++i) {
                f32 diff = bmOutputTensor[i] - embedding[i];
                sum += diff * diff;
            }
            distances.push_back(std::sqrt(sum));
        }

        // find the best three distances
        std::partial_sort(distances.begin(), distances.begin() + 3, distances.end());

        // calculate the final score
        f32 out = 0.0f;
        for (int i = 0; i < 3; ++i) {
            f32 distance = distances[i];
            distance = std::min(0.3f, distance);
            distance = (0.3f - distance) / 0.3f;
            out += (1-out) * distance;
        }

        return out;
    }
};

int main(int argc, char* argv[]) {
    HotwordDetector hd;

    int ok = hd.init("../logmelcalc.tflite", "../baseModel.tflite", embeddings_alexa);
    if (ok != 0) {
        printf("Error %d\n", ok);
    } else {
        printf("Initialized correctly\n");
    }

    FILE* audioFile = fopen("../test_audio_float.raw", "rb");
    std::vector<float> audioData;
    while (true) {
        float sample;
        if (fread(&sample, 1, 4, audioFile) == 4) {
            audioData.push_back(sample);
        } else {
            break;
        }
    }

    printf("Audio file: %d samples", audioData.size());

    for (int i = 0; i < audioData.size() - 16000; i += 1000) {
        std::array<f32, 16000> data;
        std::copy(audioData.begin() + i, audioData.begin() + i + 16000, data.begin());
        f32 confidence = hd.process_frame(data);
        printf("Confidence %.2fs %f%s\n", i / 16000.0f, confidence, confidence > 0.9f ? " DETECTED!" : "");
    }
}
embeddings.h (data is from alexa_ref.json in the commit before the ResNet50 model was added)
#ifndef EMBEDDINGS_H
#define EMBEDDINGS_H

#include <vector>
#include <array>

std::vector<std::array<f32, 128>> embeddings_alexa{{-0.0018443578155711293, 0.0012409311020746827, -0.0002715830923989415, 0.0004013945581391454, 8.306189556606114e-05, 0.00044053635792806745, 0.0009874621173366904, 0.0009157363674603403, -0.0012063418980687857, 0.0016062910435721278, 0.001714642159640789, 0.0010646098526194692, 0.001067142584361136, 0.0026639034040272236, 0.0010514091700315475, 0.0016106378752738237, -0.00010444383951835334, -0.43039366602897644, 0.00017202840535901487, -0.04051519185304642, -0.34928077459335327, 0.0018010134808719158, -0.0020715740974992514, 0.001733542187139392, -0.000593288685195148, -0.0008430416928604245, 0.0013320832513272762, -0.28834396600723267, -0.0011945832520723343, -0.001150083844549954, -0.0008581099100410938, 0.2882259488105774, 0.0017530254554003477, -0.00025029361131601036, 0.0017177052795886993, -0.0005449739401228726, 0.00012596861051861197, 0.0020090285688638687, -0.0017851801821962, 0.00013088944251649082, -0.00031638433574698865, -0.0017561435233801603, 0.0018899600254371762, -0.4391557276248932, 0.001379559631459415, -0.001019650255329907, -0.0011724227806553245, 0.36617204546928406, 0.023888058960437775, 0.001750345341861248, -0.001019726158119738, 0.0012767650187015533, -0.002323133172467351, -0.0013836531434208155, 0.0018793671624734998, 0.0012834904482588172, 0.001410864875651896, -0.0038892882876098156, 0.000821766210719943, 4.7008310502860695e-05, 0.0005266448715701699, 0.19474084675312042, 0.00013599770318251103, -0.000907463429030031, -0.0012136111035943031, 0.0006211597938090563, 0.0007279961719177663, -0.0019102797377854586, -0.0021515635307878256, 0.0010963628301396966, -0.0732651874423027, 0.0019330763025209308, 0.002107506850734353, 0.0012016203254461288, -2.8716011001961306e-05, -0.0019159488147124648, -0.0015521880704909563, -0.0024353181943297386, -0.0020603861194103956, 0.0017349357949569821, -0.0016230623004958034, -0.0014153642114251852, 0.001310766558162868, 0.001488858019001782, 0.0016663441201671958, 0.0018254319438710809, 0.0024388344027101994, -0.0009016821859404445, 0.07546431571245193, -0.0012602577917277813, 0.0017456549685448408, 0.0012205323437228799, 0.00033814305788837373, -0.0025566036347299814, 0.00130564346909523, 0.00119997828733176, 0.00132357282564044, 0.000850820739287883, 0.00023926336143631488, 0.0008439748780801892, -0.0014458457008004189, 0.14081107079982758, 0.000839119020383805, -0.00046436034608632326, -0.0011383205419406295, -0.0024229867849498987, -0.0011970826890319586, -0.0007554360199719667, 0.0016834212001413107, 0.0001794159907149151, 0.0003878429706674069, -0.004022049717605114, 0.30528026819229126, -0.0016906275413930416, -0.0010010339319705963, 0.0016334225656464696, -0.0009830307681113482, 0.0015193283325061202, 0.0018329325830563903, 0.0008684337954036891, 0.0007554229232482612, -0.0013552817981690168, -0.15109840035438538, 0.002244429662823677, 0.11094605922698975, 0.00016276723181363195, -0.0017068249871954322, -0.0016716322861611843}, {-0.0020565874874591827, 0.0004156098875682801, -0.0003158159088343382, 0.00019885289657395333, -0.0013484855880960822, 0.00012958447041455656, 4.8226298531517386e-05, 0.0007971396553330123, -0.0008347639814019203, 0.0018647657707333565, 0.0021091883536428213, 0.0005832553142681718, 0.0002820800291374326, 0.000532653764821589, 5.6823289924068376e-05, 0.002294765552505851, 2.1967082375340397e-06, -0.4095191955566406, -0.0008325675735250115, -0.04503864422440529, -0.44105005264282227, 0.002380387159064412, -0.002103760838508606, 0.002491309540346265, -0.0005531848291866481, 0.00026169660850428045, 0.000808578566648066, -0.2808479964733124, -0.000476084096590057, -0.0006140734767541289, -0.0005828795838169754, 0.30272039771080017, 0.001348834834061563, -0.0002575473044998944, 0.0022982279770076275, -0.0004470723797567189, 0.00014820226351730525, 0.00047264029853977263, -0.002153261099010706, 7.695287058595568e-05, 0.0004967303248122334, -0.0025680353865027428, 0.0014671008102595806, -0.386121928691864, 0.0006896788836456835, -0.00031484110513702035, -0.00037704527494497597, 0.37257981300354004, 0.0489690862596035, 0.0022541985381394625, -0.0005816870834678411, 0.0006981585174798965, -0.002211670856922865, -0.0006180336349643767, 0.0019750550854951143, 0.0006512615946121514, 0.001753958989866078, -0.003532952629029751, 0.0005504625733010471, 6.262844544835389e-05, 0.000523464463185519, 0.19570711255073547, 3.7522855564020574e-05, -7.692338840570301e-05, -0.0006537842564284801, 0.0005317522445693612, 0.0008462168625555933, -0.001959105022251606, -0.0021206268575042486, 0.0013142080279067159, -0.07286752015352249, -0.00018311169696971774, 0.0005134599632583559, 0.0003746749134734273, -0.00018636566528584808, -0.00180395832285285, -0.0015815624501556158, -0.002390111330896616, -0.0029882933013141155, 0.00198241975158453, -0.0022571031004190445, -0.0005373275489546359, 0.0009119437891058624, 0.0015167081728577614, 0.0022941664792597294, 0.0024511320516467094, 0.0015295482007786632, -0.00017519625544082373, 0.0752183273434639, -0.0009086542995646596, 0.0022648631129413843, 0.0002875965728890151, 0.00023600264103151858, -0.0016883629141375422, 0.0004282286681700498, 0.00025138401542790234, 0.0006658604834228754, 0.0005756120081059635, 0.0002167821367038414, 0.0008501539705321193, -0.0006803615833632648, 0.1479097306728363, 0.0004522966919466853, -0.0002648507943376899, -0.000181955547304824, -0.00021226891840342432, -0.0002861968823708594, -0.00042069811024703085, 0.001987660303711891, 0.0002041509433183819, -0.0002011546166613698, -0.004234379157423973, 0.28067129850387573, 0.0004454958834685385, 8.219587471103296e-05, 0.002099054865539074, -0.001007545506581664, 0.0021866895258426666, 0.0024581411853432655, 0.0006752919871360064, -0.0007529024151153862, -0.0007495007012039423, -0.15667705237865448, -3.9656874832871836e-06, -0.0153578482568264, 0.001200825092382729, -0.0022916439920663834, -0.0019731679931282997}, {-0.0029506904538720846, 0.0007545671542175114, 0.00025700521655380726, 0.001587261795066297, -0.004217327572405338, 0.00034811231307685375, -0.0021977871656417847, 0.00023275577405001968, -0.00024322803074028343, 0.0016569038853049278, 0.0018964203773066401, -0.0006294742925092578, 6.31033763056621e-05, 0.00013130740262567997, -0.0018934633117169142, 0.0021087739150971174, -4.7066489059943706e-05, -0.35626471042633057, -0.0037763414438813925, 0.0015456597320735455, -0.3770938813686371, 0.0021937047131359577, -0.0013909584376960993, 0.002051087561994791, -4.386096043162979e-05, 0.0025120647624135017, -0.0002062350104097277, -0.27969682216644287, 0.0012652123114094138, 0.0001547522988403216, 0.0005131364450789988, 0.30294036865234375, 0.0006402382859960198, -0.0004010084376204759, 0.0021061149891465902, -0.00013685732847079635, 0.0019085099920630455, 0.0023171729408204556, -0.0019417403964325786, -0.0005446713184937835, 0.0027780551463365555, -0.0023972894996404648, 0.0007650611805729568, -0.36173567175865173, -0.0008417247445322573, -0.0007842560298740864, -0.0005861874669790268, 0.4208935499191284, 0.1705024093389511, 0.0021079303696751595, 0.0005195994745008647, -0.0005151305231265724, -0.0014444084372371435, 0.0008391077280975878, 0.001675211824476719, -0.00098223180975765, 0.001486271619796753, -0.004035819787532091, 0.00038808450335636735, -0.0003827968903351575, -1.8029029888566583e-05, 0.20511704683303833, -0.000416828173911199, -0.0011282098712399602, 0.0005893409834243357, 0.00016245713050011545, 0.00016574606706853956, -0.004494793247431517, -0.004739498719573021, 0.0006894140387885273, -0.07779478281736374, 0.001649618847295642, 0.0023343688808381557, 0.002374241128563881, 0.000910741975530982, -0.0013985869009047747, -0.00402357243001461, -0.004820895381271839, -0.0025271596387028694, 0.001740391948260367, -0.001752755488269031, 0.0007756149279884994, 0.0032763725612312555, 0.0008504441357217729, 0.0021244401577860117, 0.0022423977497965097, 0.00451157009229064, -0.0008608244243077934, 0.08057869970798492, -0.000354163785232231, 0.002088583540171385, -0.0016960728680714965, 0.0006055395933799446, -0.00037480576429516077, 0.0025861053727567196, 0.0010512643493711948, -0.0002258696040371433, -1.6026133380364627e-05, -0.00030903914012014866, 0.00036882690619677305, 0.0008751754648983479, 0.16400308907032013, -0.0008429711451753974, 0.00018912972882390022, -0.0016798702999949455, -0.002374232979491353, 0.0013297913828864694, 0.00013885846419725567, 0.001701663015410304, 0.0006524190539494157, 0.000883435073774308, -0.005298808682709932, 0.28356775641441345, 0.002492455765604973, 0.002142027486115694, 0.0019152233144268394, -0.0012851799838244915, 0.001694588689133525, 0.002243913011625409, 0.0002945506130345166, 0.00036104852915741503, 4.062244624947198e-05, -0.24777883291244507, -0.0016076074680313468, -0.00626232847571373, 0.004339795093983412, -0.0020592673681676388, -0.004760207142680883}, {-0.003331949235871434, -4.0892882680054754e-05, -0.0004109063884243369, -2.1086707420181483e-06, -0.002926705637946725, 3.585101876524277e-05, -0.00015815399819985032, 0.0011701962212100625, -0.0011255416320636868, 0.002179102273657918, 0.002486106939613819, 0.0008896252838894725, -0.0002387767017353326, -0.0011096902890130877, -0.00015551221440546215, 0.0027023539878427982, 2.7639940526569262e-05, -0.40583112835884094, -0.0017331629060208797, -0.029486749321222305, -0.45447495579719543, 0.002751121763139963, -0.0025494361761957407, 0.0028328809421509504, -0.0009335164213553071, 0.0013004833599552512, 0.0011456080246716738, -0.26588016748428345, -0.000602804240770638, -0.0008550725760869682, -0.0009532556869089603, 0.2807413935661316, 0.0013647619634866714, -2.7464890081319027e-05, 0.0027129834052175283, -0.00018683182133827358, -7.748845382593572e-05, 0.0003490635135676712, -0.0025576057378202677, -2.1125486455275677e-05, 0.0010451632551848888, -0.002996979746967554, 0.0015348340384662151, -0.37765058875083923, 0.0009027579217217863, -3.4427212085574865e-05, 0.00012875125685241073, 0.38213446736335754, 0.11137402802705765, 0.0026604989543557167, -0.0009111365652643144, 0.000994408968836069, -0.0026553587522357702, -0.0008110794587992132, 0.0023513617925345898, 0.0008465417777188122, 0.0015149812679737806, -0.0031341516878455877, 0.0002727591199800372, 0.0004368622903712094, 0.0009110817918553948, 0.1947687715291977, 0.00041373385465703905, -0.00012227467959746718, -0.0009479971486143768, 0.0008413728792220354, 0.0013732871739193797, -0.0032364886719733477, -0.003510132897645235, 0.0017637410201132298, -0.07332050055265427, -0.0007650210172869265, 0.00010666855814633891, 0.0003193803713656962, -0.0006685390835627913, -0.002076671691611409, -0.002642506267875433, -0.003509791800752282, -0.0033502185251563787, 0.0023313371930271387, -0.0026897916104644537, -0.0006276239291764796, 0.001306070014834404, 0.0019930715207010508, 0.002687974600121379, 0.002818382577970624, 0.0019328201888129115, -8.293447899632156e-05, 0.07587842643260956, -0.0007134348852559924, 0.002671621972694993, 0.0002340987848583609, -0.00013989549188409, -0.001899084192700684, 0.0003903180768247694, 3.2254868074232945e-06, 0.0008636124548502266, 0.0009019455756060779, 0.0006136886077001691, 0.0011912055779248476, -0.0008732904097996652, 0.15018098056316376, 0.0007456718594767153, -0.0005592887755483389, -0.0003920785093214363, 0.00030499856802634895, -0.00012405008601490408, -0.0006917426944710314, 0.0023517096415162086, -4.333762262831442e-05, -0.0006480803131125867, -0.004230167716741562, 0.28339871764183044, 0.0022204259876161814, 0.00045824365224689245, 0.00251378258690238, -0.0010311987716704607, 0.002609747229143977, 0.0028190328739583492, 0.0005000720848329365, -0.0008592265076003969, -0.0009725180570967495, -0.1580607295036316, -0.001789203961379826, 0.008088696748018265, 0.0023889595177024603, -0.0026480539236217737, -0.0033368065487593412}, {-0.0029771511908620596, -0.00016064156079664826, -0.0006140838377177715, -0.0005318192997947335, -0.0020084783900529146, -6.565928924828768e-05, 0.00028937181923538446, 0.0012257108464837074, -0.000785422686021775, 0.002290806034579873, 0.002735873218625784, 0.0010311256628483534, 2.2738329789717682e-05, -0.0026761051267385483, -9.96322778519243e-05, 0.0030857298988848925, 5.400697045843117e-05, -0.23286482691764832, -0.0007928378181532025, -0.10041722655296326, -0.45500168204307556, 0.003019180614501238, -0.0028313614893704653, 0.003378347959369421, -0.0011111063649877906, 0.00046174763701856136, 0.001087985117919743, -0.2941955029964447, -0.0009271810995414853, -0.00045463923015631735, -0.0011152330553159118, 0.28410446643829346, 0.00132179434876889, -0.0003559986362233758, 0.0031218735966831446, -0.0007121391827240586, -0.0008371776784770191, -0.001057412358932197, -0.002744546625763178, 0.00025715804076753557, 0.0006247364799492061, -0.0034098410978913307, 0.001436182064935565, -0.4989854097366333, 0.001129545969888568, 0.0001442620123270899, 0.0001594096829649061, 0.33782368898391724, 0.03487856313586235, 0.002913504373282194, -0.0010122667299583554, 0.0010594823397696018, -0.0027997635770589113, -0.0008522623684257269, 0.002342397114261985, 0.0012068073265254498, 0.0017833111342042685, 0.003498406382277608, 0.0005968738696537912, 0.0006317885126918554, 0.0011864412808790803, 0.19930404424667358, 0.0003267911961302161, 0.000845862552523613, -0.0010458066826686263, 0.0007928937557153404, 0.0019456041045486927, -0.0020110448822379112, -0.002182021038606763, 0.0023722893092781305, -0.07801629602909088, -0.0028912299312651157, -0.0012788743479177356, -0.001206743298098445, -0.001038335612975061, -0.001968970987945795, -0.001541198929771781, -0.002722546923905611, -0.003948226571083069, 0.0024532799143344164, -0.0033834590576589108, -0.0003175104793626815, -0.00019280138076283038, 0.0023317933082580566, 0.002970215631648898, 0.0030916668474674225, 0.0002845256822183728, 0.00036277686012908816, 0.08131980895996094, -0.0008593249949626625, 0.002969582797959447, 0.0005029243184253573, -0.00012195096496725455, -0.001964419614523649, -0.0011603136081248522, -0.00046738795936107635, 0.000407179060857743, 0.0007638490642420948, 0.0008159516146406531, 0.001307619153521955, -0.0010353976394981146, 0.14412279427051544, 0.0010200662072747946, -0.0003795282682403922, 0.0012775447685271502, 0.0028285610023885965, 2.5214074412360787e-05, -0.000397032912587747, 0.002602526918053627, 0.00027434295043349266, -0.0012943876208737493, 0.0045511797070503235, 0.3439413905143738, 0.0023458534851670265, 0.00032887927955016494, 0.002786875469610095, -0.0008532764622941613, 0.0033378086518496275, 0.002999675925821066, 0.000835572776850313, -0.003226080909371376, -0.000485347758512944, -0.07152353227138519, -0.002399630146101117, -0.008674799464643002, 0.0011913954513147473, -0.0029480860102921724, -0.0020369715057313442}, {-0.001990820048376918, -8.720098412595689e-05, -0.0005033875349909067, -0.0006384809967130423, -0.0003561238117981702, 3.3998279832303524e-05, 0.0010668343165889382, 0.001052230829373002, -0.0010985820554196835, 0.001706133596599102, 0.001917694229632616, 0.0012402317952364683, 1.3035473784839269e-06, -9.156153828371316e-05, 0.0009423712035641074, 0.0020096355583518744, 1.7848315110313706e-05, -0.43734368681907654, 0.00037676753709092736, -0.05527802184224129, -0.41683220863342285, 0.0020864035468548536, -0.002039351500570774, 0.00218240637332201, -0.0008597137639299035, -0.000274342397460714, 0.001302206190302968, -0.2782334089279175, -0.0013251245254650712, -0.001011074986308813, -0.0011859493097290397, 0.2792664170265198, 0.0013516845647245646, 4.496056862990372e-05, 0.0020640254952013493, -0.00024634660803712904, -0.0007774603436701, -0.0002405871491646394, -0.0019386527128517628, 0.00022729708871338516, -0.0004796567955054343, -0.002212348859757185, 0.0014794730814173818, -0.4280397593975067, 0.001438919804058969, -3.8839352782815695e-05, 0.00011184611503267661, 0.34785526990890503, 0.008173007518053055, 0.001996308797970414, -0.0011963944416493177, 0.0013299823040142655, -0.0021578092128038406, -0.0013252964708954096, 0.0018309085862711072, 0.0014509146567434072, 0.0016388549702242017, -0.001572221633978188, 0.0002809795259963721, 0.00046065659262239933, 0.000847704941406846, 0.18911805748939514, 0.0004873547295574099, 0.00017295812722295523, -0.0012992887059226632, 0.0007440319168381393, 0.0012044972972944379, -0.0011235937708988786, -0.0012682127999141812, 0.0014753865543752909, -0.07065396010875702, -0.0008815909386612475, -0.0004507621633820236, -0.0004612519114743918, -0.00088812957983464, -0.00172174081671983, -0.0007336583221331239, -0.0014650875236839056, -0.002692288951948285, 0.0018229112029075623, -0.002048865891993046, -0.0011335458839312196, -4.005815935670398e-05, 0.0016366862691938877, 0.0019931597635149956, 0.0021439362317323685, 0.00011611740046646446, 5.028383748140186e-05, 0.07268989831209183, -0.000794793595559895, 0.0020142123103141785, 0.0012093607801944017, -0.00022583702229894698, -0.0019556868355721235, -0.0006812348728999496, -0.00013387408398557454, 0.0010979663347825408, 0.0009100254974327981, 0.0006380382110364735, 0.0010246819583699107, -0.0014336645836010575, 0.1353500634431839, 0.0011825300753116608, -0.0006022931193001568, 0.00017469454905949533, 0.0007072651642374694, -0.0009913976537063718, -0.0007607964798808098, 0.001849201857112348, -0.0002354085008846596, -0.0009113091509789228, -0.001855263253673911, 0.2969418466091156, 3.405039751669392e-05, -0.0007725371397100389, 0.0018745771376416087, -0.0009567348170094192, 0.001982496352866292, 0.0021385832224041224, 0.0005129249766469002, -0.0008411338203586638, -0.0011349988635629416, -0.11360866576433182, 8.526957390131429e-05, 0.08131718635559082, -3.864415339194238e-05, -0.0020133634097874165, -0.0009910265216603875}, {-0.001656288281083107, -2.8794476747862063e-05, -0.0005589425563812256, -0.0008167586056515574, 0.0004951962037011981, 2.0944660718669184e-05, 0.0015699595678597689, 0.0010057815816253424, -0.0011231923708692193, 0.0016090467106550932, 0.0017584558809176087, 0.001410018652677536, 0.00015031063230708241, 0.0004476862959563732, 0.001394300372339785, 0.0017683238256722689, 2.250766374345403e-05, -0.444904088973999, 0.0011328757973387837, -0.06436607986688614, -0.4066789746284485, 0.0018901332514360547, -0.0019698496907949448, 0.0019229816971346736, -0.0007891352288424969, -0.0008841181988827884, 0.0014223797479644418, -0.2800252139568329, -0.0016580416122451425, -0.0011076845694333315, -0.0012754995841532946, 0.2816864252090454, 0.0014812903245911002, -2.1163414203329012e-05, 0.0018446471076458693, -0.00036296164034865797, -0.0010410483228042722, -0.0005440201493911445, -0.0017656448762863874, 0.00034371408401057124, -0.0010316226398572326, -0.0019080182537436485, 0.0015989236999303102, -0.43533873558044434, 0.0017178342677652836, -2.1582498447969556e-05, 1.4906046089890879e-05, 0.34165844321250916, -0.011076165363192558, 0.0017819356871768832, -0.0013337035197764635, 0.0015156824374571443, -0.0021461951546370983, -0.001593279535882175, 0.0017278611194342375, 0.0017476077191531658, 0.001824866863898933, -0.0020711247343569994, 0.00039302368531934917, 0.0003751647600438446, 0.0007757779094390571, 0.1887880563735962, 0.00044536360655911267, 0.0004260335408616811, -0.001485183835029602, 0.000657042081002146, 0.001139191910624504, -0.00045765654067508876, -0.0005707359523512423, 0.0013861937914043665, -0.07053244113922119, -0.0012418668484315276, -0.000635767646599561, -0.0008167353225871921, -0.000972537905909121, -0.0017112629720941186, -0.00011643304605968297, -0.0008441272657364607, -0.0024511124938726425, 0.001708803465589881, -0.001812037080526352, -0.0014004273107275367, -0.0005339874187484384, 0.0015790851321071386, 0.0017630783841013908, 0.0019512851722538471, -0.00044342264300212264, 0.00016307421901728958, 0.0725075900554657, -0.0009440208086743951, 0.0018052730010822415, 0.0016383156180381775, -0.00014811608707532287, -0.0021800107788294554, -0.0009980377508327365, -0.00023148744367063046, 0.0012435748940333724, 0.0009091600077226758, 0.0005727977259084582, 0.0009451036457903683, -0.0017278083832934499, 0.1336335986852646, 0.0013650191249325871, -0.0005673085106536746, 0.0005442623514682055, 0.000979582779109478, -0.0013660034164786339, -0.0007731836521998048, 0.0017330606933683157, -0.00023748156672809273, -0.0009673028253018856, -0.0022153242025524378, 0.29852375388145447, -0.0007358716102316976, -0.0012698429636657238, 0.0016659412067383528, -0.0009460768196731806, 0.0017365822568535805, 0.001953211845830083, 0.000626341556198895, -0.001066311844624579, -0.0012541991891339421, -0.09715035557746887, 0.000809254648629576, 0.07696756720542908, -0.000875972444191575, -0.0018357065273448825, -0.0002487217716407031}};

#endif

The command to generate the test_audio_float.raw file is arecord -D plughw:1,0 -f FLOAT_LE -c1 -r16000 -d1 test_audio_float.raw.

@aman-17
Copy link
Contributor

aman-17 commented Sep 9, 2024

@Stypox Thank you for providing C++ version of this library.

@TheSeriousProgrammer
Copy link
Contributor

If you could make the same as a github gist we will happily include the link of the same in our readme

@Stypox
Copy link
Author

Stypox commented Sep 18, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants