Assertion failed when running vosk in a Node.js code on Windows

140 Views Asked by At

I have a code that compare the accuracy and flunecy of a text file and an audio file.

I am getting an ASSERTION_FAILED error. Does anyone now how to fix this?

node .\compare-basic.js
LOG (VoskAPI:ReadDataFiles():model.cc:213) Decoding params beam=13 max-active=7000 lattice-beam=6
LOG (VoskAPI:ReadDataFiles():model.cc:216) Silence phones 1:2:3:4:5:11:12:13:14:15
LOG (VoskAPI:RemoveOrphanNodes():nnet-nnet.cc:948) Removed 0 orphan nodes.
LOG (VoskAPI:RemoveOrphanComponents():nnet-nnet.cc:847) Removing 0 orphan components.
LOG (VoskAPI:ReadDataFiles():model.cc:248) Loading i-vector extractor from node_modules/vosk/model/vosk-model-en-us-0.22-lgraph/ivector/final.ie
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:183) Computing derived variables for iVector extractor
LOG (VoskAPI:ComputeDerivedVars():ivector-extractor.cc:204) Done.
LOG (VoskAPI:ReadDataFiles():model.cc:282) Loading HCL and G from node_modules/vosk/model/vosk-model-en-us-0.22-lgraph/graph/HCLr.fst node_modules/vosk/model/vosk-model-en-us-0.22-lgraph/graph/Gr.fst
LOG (VoskAPI:ReadDataFiles():model.cc:303) Loading winfo node_modules/vosk/model/vosk-model-en-us-0.22-lgraph/graph/phones/word_boundary.int
ASSERTION_FAILED (VoskAPI:SubVector():matrix/kaldi-vector.h:512) Assertion failed: (static_cast<UnsignedMatrixIndexT>(origin)+ static_cast<UnsignedMatrixIndexT>(length) <= static_cast<UnsignedMatrixIndexT>(t.Dim()))

Here is the code.

const fs = require('fs');
const Vosk = require('vosk');

// Load the language model
const modelName = 'node_modules/vosk/model/vosk-model-en-us-0.22-lgraph';
const model = new Vosk.Model(modelName);

// Load the audio file
const audioFile = fs.readFileSync('input.wav');

// Load the text file
const text = fs.readFileSync('input.txt').toString();

// Create a recognizer object
const recognizer = new Vosk.Recognizer({model: model});

// Transcribe the audio file
recognizer.acceptWaveform(audioFile);

// Get the transcribed text
const transcribedText = recognizer.result();

// Calculate the accuracy and fluency
let accuracy = 0;
let fluency = 0;
let wordCount = 0;
let correctWordCount = 0;

transcribedText.text.split(' ').forEach((word, index) => {
  if (word === text.split(' ')[index]) {
    correctWordCount++;
  }
  wordCount++;
});

accuracy = (correctWordCount / wordCount) * 100;

fluency = transcribedText.confidence * 100;

console.log(`Accuracy: ${accuracy}%`);
console.log(`Fluency: ${fluency}%`);

I don't know what I can try. I can't find any post about this error.

0

There are 0 best solutions below