Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/old-bananas-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/agents-plugin-silero': patch
---

persist RNN state between VAD inference calls
5 changes: 2 additions & 3 deletions plugins/silero/src/onnx_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class OnnxModel {
#contextSize: number;
#sampleRateNd: BigInt64Array;
#context: Float32Array;
// #state: Float32Array;
#rnnState: Float32Array;
#inputBuffer: Float32Array;

Expand Down Expand Up @@ -73,8 +72,8 @@ export class OnnxModel {
sr: new Tensor('int64', this.#sampleRateNd),
})
.then((result) => {
// this.#state = result.output.data as Float32Array,
this.#context = this.#inputBuffer.subarray(0, this.#contextSize);
this.#rnnState.set(result.stateN!.data as Float32Array);
this.#context = this.#inputBuffer.slice(-this.#contextSize);
return (result.output!.data as Float32Array).at(0)!;
});
}
Expand Down