-
Notifications
You must be signed in to change notification settings - Fork 9
await toPCM is never completing #9
Copy link
Copy link
Open
Description
I am working with VoskJS & node-record-lpcm16 to do real time voice decoding
Here is my code
const voskJs = require("./voskjs/");
const record = require('node-record-lpcm16');
const wav = require('node-wav');
const fs = require('fs');
const model = voskJs.loadModel("./vosk-model-small-fr-0.22/")
console.log("Model Loaded.");
const recorder = record.record({
sampleRate: 16000,
channels: 1,
threshold: 0.5,
endOnSilence: true,
silence: 9999999,
audioType: "wav"
});
// var artificialData = fs.readFileSync("./mp3-output-ttsfree(dot)com (1).wav");
recorder.stream().on('data', async data =>
{
console.log(`Data in ${data.length}`);
var pcmBuffer = await voskJs.toPCM(data);
console.log(`PCM translated in ${pcmBuffer.length}`);
const transcriptEvents = await voskJs.transcriptFromBuffer(
pcmBuffer,
model,
{
multiThreads: false,
sampleRate: 16000,
grammar: null,
alternatives: 0,
words: true
}
)
console.log(transcriptEvents)
transcriptEvents.on('partial', res => { // New Word
console.log(res)
});
transcriptEvents.on('endOfSpeech', res => { // Sentence Detected (silence)
console.log(res)
});
transcriptEvents.on('final', res => { // Last Sentence
console.log(res)
});
})
/* We need the model all day, we do not clear it
voskJs.freeModel(model)
*/
This is the console Output:
LOG (VoskAPI:ReadDataFiles():model.cc:282) Loading HCL and G from ./vosk-model-small-fr-0.22//graph/HCLr.fst ./vosk-model-small-fr-0.22//graph/Gr.fst
LOG (VoskAPI:ReadDataFiles():model.cc:303) Loading winfo ./vosk-model-small-fr-0.22//graph/phones/word_boundary.int
Model Loaded.
Data in 8192
Data in 8192
Data in 8192
Data in 8192
Data in 8192
Data in 8192
Data in 8192
Seems like the toPCM is never finishing its promise
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels