Add spoken language identification for node-addon-api (#872)

This commit is contained in:
Fangjun Kuang
2024-05-13 20:26:11 +08:00
committed by GitHub
parent 031134b4d4
commit 939fdd942c
13 changed files with 445 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
const addon = require('./addon.js');
const non_streaming_asr = require('./non-streaming-asr.js');
class SpokenLanguageIdentification {
constructor(config) {
this.handle = addon.createSpokenLanguageIdentification(config);
this.config = config;
}
createStream() {
return new non_streaming_asr.OfflineStream(
addon.createSpokenLanguageIdentificationOfflineStream(this.handle));
}
// return a string containing the language code (2 characters),
// e.g., en, de, fr, es, zh
// en -> English
// de -> German
// fr -> French
// es -> Spanish
// zh -> Chinese
compute(stream) {
return addon.spokenLanguageIdentificationCompute(
this.handle, stream.handle);
}
}
module.exports = {
SpokenLanguageIdentification,
}