KoljaB / RealtimeSTT

A robust, efficient, low-latency speech-to-text library with advanced voice activity detection, wake word activation and instant transcription.
MIT License
2.09k stars 190 forks source link

Interrupt the process uisng STT #93

Closed she7ata7 closed 3 months ago

she7ata7 commented 3 months ago

I need to interpret the playing WAV: 1- Once the user starts talking. 2- Stop playing WAV files. 3- Listen to user voice again (To go to LINE 1)

Do you know which method or callback from STT is suitable for this scenario?

while True:
                # LINE 1
                stt_sentence = self.recorder.start()

                # process the stt_sentence

                # convert text chunks to WAV files
                text_queue = Queue()

               # I need a way to break from this loop once the user talks again 
                while not text_queue.empty():
                    # Convert text to wav using any TTS
                    wav_file = ....
                    self.player = ....

                    # I need a way to break from this loop once the user talks again 
                    while self.player.getPos() != 0:
                             # This loop is used to keep the script here till the play finish playing the current WAV
KoljaB commented 3 months ago

1- Once the user starts talking.

Use on_recording_start callback