Skip to content

Commit c3ce83a

Browse files
committed
minor update
1 parent cd4e26e commit c3ce83a

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ https://github.com/user-attachments/assets/797e6552-27cd-41b1-a7f3-e5cbc72094f5
3030

3131
### Updates
3232

33-
Latest Version: v0.3.100
33+
Latest Version: v0.3.104
3434

3535
See [release history](https://github.com/KoljaB/RealtimeSTT/releases).
3636

@@ -477,6 +477,8 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
477477
478478
- **no_log_file** (bool, default=False): If set, the system will skip writing the debug log file, reducing disk I/O. Useful if logging to a file is not needed and performance is a priority.
479479
480+
- **start_callback_in_new_thread** (bool, default=False): If set, the system will create a new thread for all callback functions. This can be useful if the callback function is blocking and you want to avoid blocking the realtimestt application thread.
481+
480482
#### Real-time Transcription Parameters
481483
482484
> **Note**: *When enabling realtime description a GPU installation is strongly advised. Using realtime transcription may create high GPU loads.*

RealtimeSTT/audio_recorder.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ def __init__(self,
334334
use_extended_logging: bool = False,
335335
faster_whisper_vad_filter: bool = True,
336336
normalize_audio: bool = False,
337+
start_callback_in_new_thread: bool = False,
337338
):
338339
"""
339340
Initializes an audio recorder and transcription
@@ -566,6 +567,10 @@ def __init__(self,
566567
- normalize_audio (bool, default=False): If set to True, the system will
567568
normalize the audio to a specific range before processing. This can
568569
help improve the quality of the transcription.
570+
- start_callback_in_new_thread (bool, default=False): If set to True,
571+
the callback functions will be executed in a
572+
new thread. This can help improve performance by allowing the
573+
callback to run concurrently with other operations.
569574
570575
Raises:
571576
Exception: Errors related to initializing transcription
@@ -681,6 +686,7 @@ def __init__(self,
681686
self.faster_whisper_vad_filter = faster_whisper_vad_filter
682687
self.normalize_audio = normalize_audio
683688
self.awaiting_speech_end = False
689+
self.start_callback_in_new_thread = start_callback_in_new_thread
684690

685691
# ----------------------------------------------------------------------------
686692
# Named logger configuration
@@ -1015,8 +1021,12 @@ def _transcription_worker(*args, **kwargs):
10151021
worker.run()
10161022

10171023
def _run_callback(self, cb, *args, **kwargs):
1018-
if cb:
1024+
if self.start_callback_in_new_thread:
1025+
# Run the callback in a new thread to avoid blocking the main thread
10191026
threading.Thread(target=cb, args=args, kwargs=kwargs, daemon=True).start()
1027+
else:
1028+
# Run the callback in the main thread to avoid threading issues
1029+
cb(*args, **kwargs)
10201030

10211031
@staticmethod
10221032
def _audio_data_worker(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
setuptools.setup(
1616
name="realtimestt",
17-
version="0.3.103",
17+
version="0.3.104",
1818
author="Kolja Beigel",
1919
author_email="kolja.beigel@web.de",
2020
description="A fast Voice Activity Detection and Transcription System",

0 commit comments

Comments
 (0)