infobot-sber-stt
v1.1.4
Published
Node.JS library for Sber SmartSpeech Speech-to-Text with streaming recognition
Downloads
7
Maintainers
Readme
infobot-sber-stt
Node.JS library for Sber SmartSpeech service. Library can work in stream mode or recognize stored audio file.
To work with this library you need to obtain from Sber SmartSpeech:
- Client ID
- Client Secret
Please check this page for information about credentials.
Audio file recognition example:
var STT = require('infobot-sber-stt');
var clientID = '*';
var clientSecret = '*';
var sttObj = new STT(clientID, clientSecret);
sttObj.recognizeFile('./test.wav',
{
sample_rate_hertz: 16000,
}).then(res => {
console.log(JSON.stringify(res));
}).catch(err => console.log(err));
Stream recognition example:
var STT = require('infobot-sber-stt');
var clientID = '*';
var clientSecret = '*';
var sttObj = new STT(clientID, clientSecret);
sttObj.startRecognitionSession({
language: 'ru-RU',
sample_rate_hertz: 16000,
enable_partial_results: true
}).then((recSess) => {
var Writable = require('stream').Writable;
var ws = Writable();
ws._write = function (chunk, enc, next) {
recSess.writeChunk(chunk);
next();
};
var readStream = fs.createReadStream(path);
readStream.pipe(ws);
readStream.on("end", function () {
recSess.finishStream();
});
recSess.on('data', function (data) {
if (data && data.results) {
console.log(`Transcript: ${data.results[0].text}`);
}
});
recSess.on('error', function (data) {
console.error(data);
});
}).catch((err) => {
console.error(err);
});
Provided by INFOBOT LLC. under Apache 2.0 license.