Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Division by zero in fe_track_snr following acmod_end_utt #78

Open
guidovranken opened this issue Apr 2, 2020 · 0 comments
Open

Division by zero in fe_track_snr following acmod_end_utt #78

guidovranken opened this issue Apr 2, 2020 · 0 comments

Comments

@guidovranken
Copy link

#include <sphinxbase/logmath.h>
#include <libpocketsphinx/acmod.h>
#include <pocketsphinx.h>
#include <sphinxbase/cmd_ln.h>
#include <string.h>
#include <stdlib.h>
#include <vector>

static void process(acmod_t* acmod, const std::vector<int16>& inout_raw_vector, const bool full_utt)
{
    acmod_start_utt(acmod);
    size_t inout_n_samps = inout_raw_vector.size();
    const int16* inout_raw = inout_raw_vector.data();
    const auto ret = acmod_process_raw(
            acmod,
            &inout_raw,
            &inout_n_samps,
            full_utt ? 1 : 0);
    acmod_end_utt(acmod);
}

int main(int argc, char** argv)
{
    logmath_t* lm = nullptr;
    acmod_t* acmod = nullptr;
    cmd_ln_t* config = nullptr;

    lm = logmath_init(1.0001, 0, 0);

    char* args[] = {
        strdup("-svspec"),
        strdup("0-12/13-25/26-38"),
    };

    config = cmd_ln_parse_r(NULL, ps_args(), sizeof(args) / sizeof(args[0]), args, FALSE);
    if ( config == nullptr ) {
        abort();
    }

#define MODELDIR "/mnt/2tb/fas/sphinx-26-02-2020/pocketsphinx/model/"
    cmd_ln_set_str_extra_r(config, "_mdef", MODELDIR "/en-us/en-us/mdef");
    cmd_ln_set_str_extra_r(config, "_mean", MODELDIR "/en-us/en-us/means");
    cmd_ln_set_str_extra_r(config, "_var", MODELDIR "/en-us/en-us/variances");
    cmd_ln_set_str_extra_r(config, "_tmat", MODELDIR "/en-us/en-us/transition_matrices");
    cmd_ln_set_str_extra_r(config, "_sendump", MODELDIR "/en-us/en-us/sendump");
    cmd_ln_set_str_extra_r(config, "_mixw", NULL);
    cmd_ln_set_str_extra_r(config, "_lda", NULL);
    cmd_ln_set_str_extra_r(config, "_senmgau", NULL);

    acmod = acmod_init(config, lm, nullptr, nullptr);

    {
        std::vector<int16> inout_raw_vector = {0};
        process(acmod, inout_raw_vector, true);
    }

    acmod_free(acmod);
    cmd_ln_free_r(config);
    logmath_free(lm);
}

The division occurs here:

snr = log(noise_stats->power[i] / noise_stats->noise[i]);

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

No branches or pull requests

1 participant