Add audio tagging APIs for node-addon-api (#875)

This commit is contained in:
Fangjun Kuang
2024-05-14 17:32:30 +08:00
committed by GitHub
parent 388e6a98fc
commit d19f50b799
12 changed files with 520 additions and 16 deletions

View File

@@ -0,0 +1,26 @@
const addon = require('./addon.js');
const non_streaming_asr = require('./non-streaming-asr.js');
class AudioTagging {
constructor(config) {
this.handle = addon.createAudioTagging(config);
this.config = config;
}
createStream() {
return new non_streaming_asr.OfflineStream(
addon.audioTaggingCreateOfflineStream(this.handle));
}
/* Return an array. Each element is
* an object {name: "xxx", prob: xxx, index: xxx};
*
*/
compute(stream, topK = -1) {
return addon.audioTaggingCompute(this.handle, stream.handle, topK);
}
}
module.exports = {
AudioTagging,
}

View File

@@ -5,6 +5,7 @@ const non_streaming_tts = require('./non-streaming-tts.js');
const vad = require('./vad.js');
const slid = require('./spoken-language-identification.js');
const sid = require('./speaker-identification.js');
const at = require('./audio-tagg.js');
module.exports = {
OnlineRecognizer: streaming_asr.OnlineRecognizer,
@@ -18,4 +19,5 @@ module.exports = {
SpokenLanguageIdentification: slid.SpokenLanguageIdentification,
SpeakerEmbeddingExtractor: sid.SpeakerEmbeddingExtractor,
SpeakerEmbeddingManager: sid.SpeakerEmbeddingManager,
AudioTagging: at.AudioTagging,
}