Discord STT bot using Mozilla DeepSpeech

npm i deepspeech
const DeepSpeech = require('deepspeech');
const LM_ALPHA = 0.75;
const LM_BETA = 1.85;
const BEAM_WIDTH = 1024;
let modelPath = './models/output_graph.pbmm';
let lmPath = './models/lm.binary';
let triePath = './models/trie';
let model = new DeepSpeech.Model(modelPath, BEAM_WIDTH);
let desiredSampleRate = model.sampleRate();
model.enableDecoderWithLM(lmPath, triePath, LM_ALPHA, LM_BETA);
async function transcribe_deepspeech(file) {
const audioBuffer = fs.readFileSync(file)
const audioLength = (audioBuffer.length / 2) * (1 / desiredSampleRate);
console.log('audio length', audioLength);
let result = model.stt(audioBuffer.slice(0, audioBuffer.length / 2));
console.log('result:', result);
return result;
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store