JavaScript API Usage example¶
Creating a model instance and loading model¶
1 2 3 4 5 6 7 8 9 10 | var model = new Ds.Model(args['model'], args['beam_width']);
const model_load_end = process.hrtime(model_load_start);
console.error('Loaded model in %ds.', totalTime(model_load_end));
var desired_sample_rate = model.sampleRate();
if (args['lm'] && args['trie']) {
console.error('Loading language model from files %s %s', args['lm'], args['trie']);
const lm_load_start = process.hrtime();
model.enableDecoderWithLM(args['lm'], args['trie'], args['lm_alpha'], args['lm_beta']);
|
Performing inference¶
1 2 3 | console.log(metadataToString(model.sttWithMetadata(audioBuffer.slice(0, audioBuffer.length / 2))));
} else {
console.log(model.stt(audioBuffer.slice(0, audioBuffer.length / 2)));
|
Full source code¶
See Full source code
.