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

Exception in Thread 1 #130

Closed Marlon154 closed 1 month ago

Marlon154 commented 1 month ago

Hello, I can not run the tests. I setup the environment with cuda in conda (on linux), but running the tests from the repo always fails. I tried different python versions: 3.9, 3.11 but none of them work. The exception is always the ValueError: signal only works in main thread of the main interpreter

python realtimestt_test.py                                                                                                                                                                                                                                                                          INT ✘  5s   realtimestt  
System initializing, please wait
Exception in thread Thread-3 (_audio_data_worker):
Traceback (most recent call last):
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
Exception in thread Thread-2 (_transcription_worker):
Traceback (most recent call last):
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
    self.run()
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/threading.py", line 982, in run
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
    self._target(*self._args, **self._kwargs)
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/site-packages/RealtimeSTT/audio_recorder.py", line 897, in _audio_data_worker
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/site-packages/RealtimeSTT/audio_recorder.py", line 862, in _transcription_worker
    system_signal.signal(system_signal.SIGINT, system_signal.SIG_IGN)
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/signal.py", line 58, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: signal only works in main thread of the main interpreter
    worker.run()
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/site-packages/RealtimeSTT/audio_recorder.py", line 124, in run
    system_signal.signal(system_signal.SIGINT, system_signal.SIG_IGN)
  File "/home/marlon/.conda/envs/realtimestt/lib/python3.11/signal.py", line 58, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: signal only works in main thread of the main interpreter

Even this simple example fails:

from RealtimeSTT import AudioToTextRecorder

def process_text(text):
    print(text)

if __name__ == '__main__':
    recorder = AudioToTextRecorder()

    while True:
        recorder.text(process_text)

with the same error as above.

KoljaB commented 1 month ago

Please look here (check current version from repo, release coming soon)

Marlon154 commented 1 month ago

It work, thank you!