Add spoken language identification for node-addon-api (#872)
This commit is contained in:
@@ -37,4 +37,5 @@ class OfflineRecognizer {
|
||||
|
||||
module.exports = {
|
||||
OfflineRecognizer,
|
||||
OfflineStream,
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ const streaming_asr = require('./streaming-asr.js');
|
||||
const non_streaming_asr = require('./non-streaming-asr.js');
|
||||
const non_streaming_tts = require('./non-streaming-tts.js');
|
||||
const vad = require('./vad.js');
|
||||
const slid = require('./spoken-language-identification.js');
|
||||
|
||||
module.exports = {
|
||||
OnlineRecognizer: streaming_asr.OnlineRecognizer,
|
||||
@@ -13,4 +14,5 @@ module.exports = {
|
||||
Display: streaming_asr.Display,
|
||||
Vad: vad.Vad,
|
||||
CircularBuffer: vad.CircularBuffer,
|
||||
SpokenLanguageIdentification: slid.SpokenLanguageIdentification,
|
||||
}
|
||||
|
||||
30
scripts/node-addon-api/lib/spoken-language-identification.js
Normal file
30
scripts/node-addon-api/lib/spoken-language-identification.js
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user