Last active
November 1, 2020 04:08
-
-
Save buddyeorl/aa92fafe4e7bea2e158012354f981c54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ds = require('deepspeech-tflite'); | |
const fs = require('fs'); | |
let model = new ds.Model('./pathTodeepspeech.tflite'); | |
model.enableExternalScorer('./pathTodeepspeech.scorer'); | |
const deepSpeech = async (req, res, next) => { | |
//if no file was received | |
if (!req.file) { | |
res.send({ message: 'No audio file has been received' }); | |
return | |
} | |
let speechToText = await model.stt(req.file.buffer); | |
console.log('recognized speech = ', speechToText); | |
if (speechToText.length > 0) { | |
req.locals = speechToText; | |
next(); | |
} else { | |
res.send({ | |
error: 'No speech was recognized', | |
}) | |
} | |
return | |
} | |
module.exports = { deepSpeech }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment