Support not using external buffers for node-addon (#925)

This commit is contained in:
Fangjun Kuang
2024-05-28 11:50:23 +08:00
committed by GitHub
parent cd65e7627d
commit b1c7d04ce2
11 changed files with 226 additions and 80 deletions

View File

@@ -18,9 +18,9 @@ class SpeakerEmbeddingExtractor {
}
// return a float32 array
compute(stream) {
compute(stream, enableExternalBuffer = true) {
return addon.speakerEmbeddingExtractorComputeEmbedding(
this.handle, stream.handle);
this.handle, stream.handle, enableExternalBuffer);
}
}

View File

@@ -11,8 +11,9 @@ class CircularBuffer {
}
// return a float32 array
get(startIndex, n) {
return addon.circularBufferGet(this.handle, startIndex, n);
get(startIndex, n, enableExternalBuffer = true) {
return addon.circularBufferGet(
this.handle, startIndex, n, enableExternalBuffer);
}
pop(n) {
@@ -48,23 +49,23 @@ config = {
}
acceptWaveform(samples) {
addon.voiceActivityDetectorAcceptWaveform(this.handle, samples)
addon.voiceActivityDetectorAcceptWaveform(this.handle, samples);
}
isEmpty() {
return addon.voiceActivityDetectorIsEmpty(this.handle)
return addon.voiceActivityDetectorIsEmpty(this.handle);
}
isDetected() {
return addon.voiceActivityDetectorIsDetected(this.handle)
return addon.voiceActivityDetectorIsDetected(this.handle);
}
pop() {
addon.voiceActivityDetectorPop(this.handle)
addon.voiceActivityDetectorPop(this.handle);
}
clear() {
addon.VoiceActivityDetectorClearWrapper(this.handle)
addon.VoiceActivityDetectorClearWrapper(this.handle);
}
/*
@@ -73,12 +74,12 @@ config = {
start: a int32
}
*/
front() {
return addon.voiceActivityDetectorFront(this.handle)
front(enableExternalBuffer = true) {
return addon.voiceActivityDetectorFront(this.handle, enableExternalBuffer);
}
reset() {
return addon.VoiceActivityDetectorResetWrapper(this.handle)
return addon.VoiceActivityDetectorResetWrapper(this.handle);
}
}