Closed she7ata7 closed 3 months ago
I just created a singleton object from STT and reused it many times, so I need a way to How to shut down it and restart it safely.
For shutdown: I use self.recorder.stop()
And once I need to listen again: I use self.recorder.start()
But I got these errors: STT exception occurred: Ran out of input STT exception occurred: invalid load key, '\x00'.
self.recorder.stop() and self.recorder.start() are for triggering manual recording. You can just reuse the recorder after calling recorder.text(). There is shutdown(self) to destroy the recorder completely but i would not recommend to create and destroy a recorder multiple times during a session. There is no need for that and it consumes resources, because at the next creation the recorder will need to initialize and reload the model.
I stopped using them but I still get these errors when I try to reuse the the same STT instance again
STT exception occurred: Ran out of input
STT Restart again
STT exception occurred: invalid load key, '\x00'.
recorder_thread = threading.Thread(target=self.recorder_thread)
recorder_thread.start()
self.recorder_ready.wait()
def recorder_thread(self):
self.recorder_ready.set()
while self.recorder.is_running:
try:
stt_sentence = self.recorder.text()
print(f"\r STT_sentence: {stt_sentence}")
# .....
except Exception as e:
print(f"STT exception occurred: {e}")
continue
Do you have a way to clear the pipeline of processing the audio chunks ?
Do you have a way to clear the pipeline of processing the audio chunks ?
No, didn't feel there's a need for that. Just add a method that loops self.audio_queue.get until its empty.
For you other prob - please send me a short full working .py codefile reproducing that error to my mail kolja.beigel@web.de (or post full reproducing code here). When I loop self.recorder.text() this does not happen here, so I guess it's something around that.
Thanks so much I have solved the issue (It was a threading problem with my code).
When I try to speak with a low voice or not clear enough I get this exception
The code:
The exception: