Closed Priler closed 1 year ago
Playing aroung with Mutex solved the problem. But still, it's quite strange behavior. Since Vosk, Porcupine and other recognizers don't require mutable on inference.
static RUSTPOTTER: OnceCell<Mutex<Rustpotter>> = OnceCell::new();
let mut lock = RUSTPOTTER.get().unwrap().lock();
let rustpotter = lock.as_mut().unwrap();
let detection = rustpotter.process_i16(&frame_buffer);
Hi,
I'm not a rust expert but I think the reason those libraries are not declared as mutable is because they are bindings around c libraries, so probably they are not muting any values on the rust side.
All the rustpotter process methods need a mutable reference to the struct because it is going to be mutated (the internal audio window is updated on each call to them).
So I don't think this is a bug or something addressable.
Another option will be to have a separate rustpotter state to hold the current state, that could be interesting in order to make the process methods thread safe, but I don't see it as something needed right now.
I'm going to close this for now, feel free to re-open it if you think I'm wrong or missing something.
BR
Hey! Working with rustpotter now, great project!
But I get this error:
The question is like, why it requires a mutable reference? It should only infer, not mutate.
Guess it's a bug.
p.s. BTW I'm storing rustpotter instance in a OnceCell.
static RUSTPOTTER: OnceCell<Rustpotter> = OnceCell::new();