KoljaB / RealtimeSTT

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

Exception in Thread 1 #130

Closed Marlon154 closed 2 hours ago

Marlon154 commented 3 hours 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 3 hours ago

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

Marlon154 commented 2 hours ago

It work, thank you!