Infoserv-Systems-Ltd / silero-rs

Rust bindings for silero's cpp wrapper
0 stars 0 forks source link

Implement stateful call interface #10

Closed SeanEClarke closed 3 hours ago

SeanEClarke commented 5 months ago

In order to off the most flexible API, it would be really useful if there could be some state management between successive calls.

This could be where the caller keeps state and passes it back in on every call, something like:

let mut my_vad = Silero::init( /* init params */);

let result = Silero::stateful_detect(&mut my_vad, &audio_segment_1);
let second_result = Silero::stateful_detect(&mut my_vad, &audio_segment_2);
let third_result = Silero::stateful_detect(&mut my_vad, &audio_segment_3);

or have state managed thin a stateful struct, such as:

let mut my_vad = Silero::init( /* init params */);

let result = my_vad.detect(&audio_segment_1);
let second_result = my_vad.detect(&audio_segment_2);
let third_result = my_vad.detect(&audio_segment_3);
SeanEClarke commented 3 months ago

Just adding some clarity...

I don't think this needs to maintain multiple states, that would probably complicate the interface, and the simpler these things are, the easier they are to integrate and maintain. I think if multiple simultaneous VAD streams were needed then it probably makes more sense to run multiple contexts - this is certainly how I use Whisper where I have separate instantiations of the Whisper model/struct which only deals with its one audio stream.