RealTimeSTT 0.3.7__tar.gz → 0.3.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {realtimestt-0.3.7 → realtimestt-0.3.9}/PKG-INFO +29 -8
  2. {realtimestt-0.3.7 → realtimestt-0.3.9}/README.md +27 -6
  3. realtimestt-0.3.9/RealtimeSTT/__init__.py +3 -0
  4. realtimestt-0.3.9/RealtimeSTT/audio_input.py +153 -0
  5. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT/audio_recorder.py +62 -19
  6. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT/audio_recorder_client.py +79 -77
  7. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT.egg-info/PKG-INFO +29 -8
  8. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT.egg-info/SOURCES.txt +1 -0
  9. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT_server/install_packages.py +0 -50
  10. realtimestt-0.3.9/RealtimeSTT_server/stt_cli_client.py +283 -0
  11. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT_server/stt_server.py +70 -10
  12. {realtimestt-0.3.7 → realtimestt-0.3.9}/setup.py +34 -34
  13. realtimestt-0.3.7/RealtimeSTT/__init__.py +0 -2
  14. realtimestt-0.3.7/RealtimeSTT_server/stt_cli_client.py +0 -659
  15. {realtimestt-0.3.7 → realtimestt-0.3.9}/LICENSE +0 -0
  16. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT.egg-info/dependency_links.txt +0 -0
  17. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT.egg-info/entry_points.txt +0 -0
  18. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT.egg-info/requires.txt +1 -1
  19. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT.egg-info/top_level.txt +0 -0
  20. {realtimestt-0.3.7 → realtimestt-0.3.9}/RealtimeSTT_server/__init__.py +0 -0
  21. {realtimestt-0.3.7 → realtimestt-0.3.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RealtimeSTT
3
- Version: 0.3.7
3
+ Version: 0.3.9
4
4
  Summary: A fast Voice Activity Detection and Transcription System
5
5
  Home-page: https://github.com/KoljaB/RealTimeSTT
6
6
  Author: Kolja Beigel
@@ -20,9 +20,9 @@ Requires-Dist: halo==0.0.31
20
20
  Requires-Dist: torch
21
21
  Requires-Dist: torchaudio
22
22
  Requires-Dist: scipy==1.14.1
23
+ Requires-Dist: openwakeword>=0.4.0
23
24
  Requires-Dist: websockets==v12.0
24
25
  Requires-Dist: websocket-client==1.8.0
25
- Requires-Dist: openwakeword>=0.4.0
26
26
  Requires-Dist: numpy<2.0.0
27
27
 
28
28
  # RealtimeSTT
@@ -55,7 +55,7 @@ https://github.com/user-attachments/assets/797e6552-27cd-41b1-a7f3-e5cbc72094f5
55
55
 
56
56
  ### Updates
57
57
 
58
- Latest Version: v0.3.7
58
+ Latest Version: v0.3.9
59
59
 
60
60
  See [release history](https://github.com/KoljaB/RealtimeSTT/releases).
61
61
 
@@ -129,10 +129,25 @@ pip install RealtimeSTT
129
129
 
130
130
  This will install all the necessary dependencies, including a **CPU support only** version of PyTorch.
131
131
 
132
- Although it is possible to run RealtimeSTT with a CPU installation only (use a small model like "tiny" or "base" in this case) you will get way better experience using:
132
+ Although it is possible to run RealtimeSTT with a CPU installation only (use a small model like "tiny" or "base" in this case) you will get way better experience using CUDA (please scroll down).
133
133
 
134
- ### GPU Support with CUDA (recommended)
134
+ ### Linux Installation
135
+
136
+ Before installing RealtimeSTT please execute:
137
+
138
+ ```bash
139
+ sudo apt-get install portaudio19-dev
140
+ ```
141
+
142
+ ### MacOS Installation
135
143
 
144
+ Before installing RealtimeSTT please execute:
145
+
146
+ ```bash
147
+ brew install portaudio
148
+ ```
149
+
150
+ ### GPU Support with CUDA (recommended)
136
151
 
137
152
  ### Updating PyTorch for CUDA Support
138
153
 
@@ -142,17 +157,17 @@ To upgrade your PyTorch installation to enable GPU support with CUDA, follow the
142
157
  To update PyTorch and Torchaudio to support CUDA 11.8, use the following commands:
143
158
 
144
159
  ```bash
145
- pip install torch==2.3.1+cu118 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu118
160
+ pip install torch==2.5.1+cu118 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118
146
161
  ```
147
162
 
148
163
  #### For CUDA 12.X:
149
164
  To update PyTorch and Torchaudio to support CUDA 12.X, execute the following:
150
165
 
151
166
  ```bash
152
- pip install torch==2.3.1+cu121 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
167
+ pip install torch==2.5.1+cu121 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu121
153
168
  ```
154
169
 
155
- Replace `2.3.1` with the version of PyTorch that matches your system and requirements.
170
+ Replace `2.5.1` with the version of PyTorch that matches your system and requirements.
156
171
 
157
172
  ### Steps That Might Be Necessary Before
158
173
 
@@ -462,6 +477,10 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
462
477
 
463
478
  - **level** (int, default=logging.WARNING): Logging level.
464
479
 
480
+ - **batch_size** (int, default=16): Batch size for the main transcription. Set to 0 to deactivate.
481
+
482
+ - **init_logging** (bool, default=True): Whether to initialize the logging framework. Set to False to manage this yourself.
483
+
465
484
  - **handle_buffer_overflow** (bool, default=True): If set, the system will log a warning when an input overflow occurs during recording and remove the data from the buffer.
466
485
 
467
486
  - **beam_size** (int, default=5): The beam size to use for beam search decoding.
@@ -499,6 +518,8 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
499
518
 
500
519
  - **on_realtime_transcription_stabilized**: A callback function that is triggered whenever there's an update in the real-time transcription and returns a higher quality, stabilized text as its argument.
501
520
 
521
+ - **realtime_batch_size**: (int, default=16): Batch size for the real-time transcription model. Set to 0 to deactivate.
522
+
502
523
  - **beam_size_realtime** (int, default=3): The beam size to use for real-time transcription beam search decoding.
503
524
 
504
525
  #### Voice Activation Parameters
@@ -28,7 +28,7 @@ https://github.com/user-attachments/assets/797e6552-27cd-41b1-a7f3-e5cbc72094f5
28
28
 
29
29
  ### Updates
30
30
 
31
- Latest Version: v0.3.7
31
+ Latest Version: v0.3.9
32
32
 
33
33
  See [release history](https://github.com/KoljaB/RealtimeSTT/releases).
34
34
 
@@ -102,10 +102,25 @@ pip install RealtimeSTT
102
102
 
103
103
  This will install all the necessary dependencies, including a **CPU support only** version of PyTorch.
104
104
 
105
- Although it is possible to run RealtimeSTT with a CPU installation only (use a small model like "tiny" or "base" in this case) you will get way better experience using:
105
+ Although it is possible to run RealtimeSTT with a CPU installation only (use a small model like "tiny" or "base" in this case) you will get way better experience using CUDA (please scroll down).
106
106
 
107
- ### GPU Support with CUDA (recommended)
107
+ ### Linux Installation
108
+
109
+ Before installing RealtimeSTT please execute:
110
+
111
+ ```bash
112
+ sudo apt-get install portaudio19-dev
113
+ ```
114
+
115
+ ### MacOS Installation
116
+
117
+ Before installing RealtimeSTT please execute:
108
118
 
119
+ ```bash
120
+ brew install portaudio
121
+ ```
122
+
123
+ ### GPU Support with CUDA (recommended)
109
124
 
110
125
  ### Updating PyTorch for CUDA Support
111
126
 
@@ -115,17 +130,17 @@ To upgrade your PyTorch installation to enable GPU support with CUDA, follow the
115
130
  To update PyTorch and Torchaudio to support CUDA 11.8, use the following commands:
116
131
 
117
132
  ```bash
118
- pip install torch==2.3.1+cu118 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu118
133
+ pip install torch==2.5.1+cu118 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118
119
134
  ```
120
135
 
121
136
  #### For CUDA 12.X:
122
137
  To update PyTorch and Torchaudio to support CUDA 12.X, execute the following:
123
138
 
124
139
  ```bash
125
- pip install torch==2.3.1+cu121 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
140
+ pip install torch==2.5.1+cu121 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu121
126
141
  ```
127
142
 
128
- Replace `2.3.1` with the version of PyTorch that matches your system and requirements.
143
+ Replace `2.5.1` with the version of PyTorch that matches your system and requirements.
129
144
 
130
145
  ### Steps That Might Be Necessary Before
131
146
 
@@ -435,6 +450,10 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
435
450
 
436
451
  - **level** (int, default=logging.WARNING): Logging level.
437
452
 
453
+ - **batch_size** (int, default=16): Batch size for the main transcription. Set to 0 to deactivate.
454
+
455
+ - **init_logging** (bool, default=True): Whether to initialize the logging framework. Set to False to manage this yourself.
456
+
438
457
  - **handle_buffer_overflow** (bool, default=True): If set, the system will log a warning when an input overflow occurs during recording and remove the data from the buffer.
439
458
 
440
459
  - **beam_size** (int, default=5): The beam size to use for beam search decoding.
@@ -472,6 +491,8 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
472
491
 
473
492
  - **on_realtime_transcription_stabilized**: A callback function that is triggered whenever there's an update in the real-time transcription and returns a higher quality, stabilized text as its argument.
474
493
 
494
+ - **realtime_batch_size**: (int, default=16): Batch size for the real-time transcription model. Set to 0 to deactivate.
495
+
475
496
  - **beam_size_realtime** (int, default=3): The beam size to use for real-time transcription beam search decoding.
476
497
 
477
498
  #### Voice Activation Parameters
@@ -0,0 +1,3 @@
1
+ from .audio_recorder import AudioToTextRecorder
2
+ from .audio_recorder_client import AudioToTextRecorderClient
3
+ from .audio_input import AudioInput
@@ -0,0 +1,153 @@
1
+ from colorama import init, Fore, Style
2
+ import pyaudio
3
+ import logging
4
+ import time
5
+
6
+
7
+ class AudioInput:
8
+ def __init__(self, input_device_index=None, debug_mode=False):
9
+ self.input_device_index = input_device_index
10
+ self.debug_mode = debug_mode
11
+ self.audio_interface = None
12
+ self.stream = None
13
+ self.device_sample_rate = None
14
+
15
+ # PyAudio constants
16
+ self.CHUNK = 1024
17
+ self.FORMAT = pyaudio.paInt16
18
+ self.CHANNELS = 1
19
+ self.DESIRED_RATE = 16000
20
+
21
+ def get_supported_sample_rates(self, device_index):
22
+ """Test which standard sample rates are supported by the specified device."""
23
+ standard_rates = [8000, 9600, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000]
24
+ supported_rates = []
25
+
26
+ device_info = self.audio_interface.get_device_info_by_index(device_index)
27
+ max_channels = device_info.get('maxInputChannels') # Changed from maxOutputChannels
28
+
29
+ for rate in standard_rates:
30
+ try:
31
+ if self.audio_interface.is_format_supported(
32
+ rate,
33
+ input_device=device_index, # Changed to input_device
34
+ input_channels=max_channels, # Changed to input_channels
35
+ input_format=self.FORMAT, # Changed to input_format
36
+ ):
37
+ supported_rates.append(rate)
38
+ except:
39
+ continue
40
+ return supported_rates
41
+
42
+ def _get_best_sample_rate(self, actual_device_index, desired_rate):
43
+ """Determines the best available sample rate for the device."""
44
+ try:
45
+ device_info = self.audio_interface.get_device_info_by_index(actual_device_index)
46
+ supported_rates = self.get_supported_sample_rates(actual_device_index)
47
+
48
+ if desired_rate in supported_rates:
49
+ return desired_rate
50
+
51
+ return max(supported_rates)
52
+
53
+ # lower_rates = [r for r in supported_rates if r <= desired_rate]
54
+ # if lower_rates:
55
+ # return max(lower_rates)
56
+
57
+ # higher_rates = [r for r in supported_rates if r > desired_rate]
58
+ # if higher_rates:
59
+ # return min(higher_rates)
60
+
61
+ return int(device_info.get('defaultSampleRate', 44100))
62
+
63
+ except Exception as e:
64
+ logging.warning(f"Error determining sample rate: {e}")
65
+ return 44100 # Safe fallback
66
+
67
+ def list_devices(self):
68
+ """List all available audio input devices with supported sample rates."""
69
+ try:
70
+ init() # Initialize colorama
71
+ self.audio_interface = pyaudio.PyAudio()
72
+ device_count = self.audio_interface.get_device_count()
73
+
74
+ print(f"Available audio input devices:")
75
+ #print(f"{Fore.LIGHTBLUE_EX}Available audio input devices:{Style.RESET_ALL}")
76
+ for i in range(device_count):
77
+ device_info = self.audio_interface.get_device_info_by_index(i)
78
+ device_name = device_info.get('name')
79
+ max_input_channels = device_info.get('maxInputChannels', 0)
80
+
81
+ if max_input_channels > 0: # Only consider devices with input capabilities
82
+ supported_rates = self.get_supported_sample_rates(i)
83
+ print(f"{Fore.LIGHTGREEN_EX}Device {Style.RESET_ALL}{i}{Fore.LIGHTGREEN_EX}: {device_name}{Style.RESET_ALL}")
84
+
85
+ # Format each rate in cyan
86
+ if supported_rates:
87
+ rates_formatted = ", ".join([f"{Fore.CYAN}{rate}{Style.RESET_ALL}" for rate in supported_rates])
88
+ print(f" {Fore.YELLOW}Supported sample rates: {rates_formatted}{Style.RESET_ALL}")
89
+ else:
90
+ print(f" {Fore.YELLOW}Supported sample rates: None{Style.RESET_ALL}")
91
+
92
+ except Exception as e:
93
+ print(f"Error listing devices: {e}")
94
+ finally:
95
+ if self.audio_interface:
96
+ self.audio_interface.terminate()
97
+
98
+ def setup(self):
99
+ """Initialize audio interface and open stream"""
100
+ try:
101
+ self.audio_interface = pyaudio.PyAudio()
102
+
103
+ if self.debug_mode:
104
+ print(f"Input device index: {self.input_device_index}")
105
+ actual_device_index = (self.input_device_index if self.input_device_index is not None
106
+ else self.audio_interface.get_default_input_device_info()['index'])
107
+
108
+ if self.debug_mode:
109
+ print(f"Actual selected device index: {actual_device_index}")
110
+ self.input_device_index = actual_device_index
111
+ self.device_sample_rate = self._get_best_sample_rate(actual_device_index, self.DESIRED_RATE)
112
+
113
+ if self.debug_mode:
114
+ print(f"Setting up audio on device {self.input_device_index} with sample rate {self.device_sample_rate}")
115
+
116
+ try:
117
+ self.stream = self.audio_interface.open(
118
+ format=self.FORMAT,
119
+ channels=self.CHANNELS,
120
+ rate=self.device_sample_rate,
121
+ input=True,
122
+ frames_per_buffer=self.CHUNK,
123
+ input_device_index=self.input_device_index,
124
+ )
125
+ if self.debug_mode:
126
+ print(f"Audio recording initialized successfully at {self.device_sample_rate} Hz")
127
+ return True
128
+ except Exception as e:
129
+ print(f"Failed to initialize audio stream at {self.device_sample_rate} Hz: {e}")
130
+ return False
131
+
132
+ except Exception as e:
133
+ print(f"Error initializing audio recording: {e}")
134
+ if self.audio_interface:
135
+ self.audio_interface.terminate()
136
+ return False
137
+
138
+ def read_chunk(self):
139
+ """Read a chunk of audio data"""
140
+ return self.stream.read(self.CHUNK, exception_on_overflow=False)
141
+
142
+ def cleanup(self):
143
+ """Clean up audio resources"""
144
+ try:
145
+ if self.stream:
146
+ self.stream.stop_stream()
147
+ self.stream.close()
148
+ self.stream = None
149
+ if self.audio_interface:
150
+ self.audio_interface.terminate()
151
+ self.audio_interface = None
152
+ except Exception as e:
153
+ print(f"Error cleaning up audio resources: {e}")
@@ -34,6 +34,7 @@ from openwakeword.model import Model
34
34
  from scipy.signal import resample
35
35
  from scipy import signal
36
36
  import signal as system_signal
37
+ from faster_whisper import WhisperModel, BatchedInferencePipeline
37
38
  import faster_whisper
38
39
  import openwakeword
39
40
  import collections
@@ -87,11 +88,12 @@ if platform.system() != 'Darwin':
87
88
 
88
89
 
89
90
  class TranscriptionWorker:
90
- def __init__(self, conn, stdout_pipe, model_path, compute_type, gpu_device_index, device,
91
- ready_event, shutdown_event, interrupt_stop_event, beam_size, initial_prompt, suppress_tokens):
91
+ def __init__(self, conn, stdout_pipe, model_path, download_root, compute_type, gpu_device_index, device,
92
+ ready_event, shutdown_event, interrupt_stop_event, beam_size, initial_prompt, suppress_tokens, batch_size):
92
93
  self.conn = conn
93
94
  self.stdout_pipe = stdout_pipe
94
95
  self.model_path = model_path
96
+ self.download_root = download_root
95
97
  self.compute_type = compute_type
96
98
  self.gpu_device_index = gpu_device_index
97
99
  self.device = device
@@ -101,6 +103,7 @@ class TranscriptionWorker:
101
103
  self.beam_size = beam_size
102
104
  self.initial_prompt = initial_prompt
103
105
  self.suppress_tokens = suppress_tokens
106
+ self.batch_size = batch_size
104
107
  self.queue = queue.Queue()
105
108
 
106
109
  def custom_print(self, *args, **kwargs):
@@ -134,7 +137,10 @@ class TranscriptionWorker:
134
137
  device=self.device,
135
138
  compute_type=self.compute_type,
136
139
  device_index=self.gpu_device_index,
140
+ download_root=self.download_root,
137
141
  )
142
+ if self.batch_size > 0:
143
+ model = BatchedInferencePipeline(model=model)
138
144
  except Exception as e:
139
145
  logging.exception(f"Error initializing main faster_whisper transcription model: {e}")
140
146
  raise
@@ -151,13 +157,24 @@ class TranscriptionWorker:
151
157
  try:
152
158
  audio, language = self.queue.get(timeout=0.1)
153
159
  try:
154
- segments, info = model.transcribe(
155
- audio,
156
- language=language if language else None,
157
- beam_size=self.beam_size,
158
- initial_prompt=self.initial_prompt,
159
- suppress_tokens=self.suppress_tokens
160
- )
160
+ if self.batch_size > 0:
161
+ segments, info = model.transcribe(
162
+ audio,
163
+ language=language if language else None,
164
+ beam_size=self.beam_size,
165
+ initial_prompt=self.initial_prompt,
166
+ suppress_tokens=self.suppress_tokens,
167
+ batch_size=self.batch_size
168
+ )
169
+ else:
170
+ segments, info = model.transcribe(
171
+ audio,
172
+ language=language if language else None,
173
+ beam_size=self.beam_size,
174
+ initial_prompt=self.initial_prompt,
175
+ suppress_tokens=self.suppress_tokens
176
+ )
177
+
161
178
  transcription = " ".join(seg.text for seg in segments).strip()
162
179
  logging.debug(f"Final text detected with main model: {transcription}")
163
180
  self.conn.send(('success', (transcription, info)))
@@ -195,6 +212,7 @@ class AudioToTextRecorder:
195
212
 
196
213
  def __init__(self,
197
214
  model: str = INIT_MODEL_TRANSCRIPTION,
215
+ download_root: str = None,
198
216
  language: str = "",
199
217
  compute_type: str = "default",
200
218
  input_device_index: int = None,
@@ -208,6 +226,7 @@ class AudioToTextRecorder:
208
226
  use_microphone=True,
209
227
  spinner=True,
210
228
  level=logging.WARNING,
229
+ batch_size: int = 16,
211
230
 
212
231
  # Realtime transcription parameters
213
232
  enable_realtime_transcription=False,
@@ -217,6 +236,7 @@ class AudioToTextRecorder:
217
236
  init_realtime_after_seconds=INIT_REALTIME_INITIAL_PAUSE,
218
237
  on_realtime_transcription_update=None,
219
238
  on_realtime_transcription_stabilized=None,
239
+ realtime_batch_size: int = 16,
220
240
 
221
241
  # Voice activation parameters
222
242
  silero_sensitivity: float = INIT_SILERO_SENSITIVITY,
@@ -280,6 +300,8 @@ class AudioToTextRecorder:
280
300
  'large-v2'.
281
301
  If a specific size is provided, the model is downloaded
282
302
  from the Hugging Face Hub.
303
+ - download_root (str, default=None): Specifies the root path were the Whisper models
304
+ are downloaded to. When empty, the default is used.
283
305
  - language (str, default=""): Language code for speech-to-text engine.
284
306
  If not specified, the model will attempt to detect the language
285
307
  automatically.
@@ -314,6 +336,7 @@ class AudioToTextRecorder:
314
336
  - spinner (bool, default=True): Show spinner animation with current
315
337
  state.
316
338
  - level (int, default=logging.WARNING): Logging level.
339
+ - batch_size (int, default=16): Batch size for the main transcription
317
340
  - enable_realtime_transcription (bool, default=False): Enables or
318
341
  disables real-time transcription of audio. When set to True, the
319
342
  audio will be transcribed continuously as it is being recorded.
@@ -345,6 +368,8 @@ class AudioToTextRecorder:
345
368
  triggered when the transcribed text stabilizes in quality. The
346
369
  stabilized text is generally more accurate but may arrive with a
347
370
  slight delay compared to the regular real-time updates.
371
+ - realtime_batch_size (int, default=16): Batch size for the real-time
372
+ transcription model.
348
373
  - silero_sensitivity (float, default=SILERO_SENSITIVITY): Sensitivity
349
374
  for the Silero Voice Activity Detection model ranging from 0
350
375
  (least sensitive) to 1 (most sensitive). Default is 0.5.
@@ -508,6 +533,7 @@ class AudioToTextRecorder:
508
533
  self.enable_realtime_transcription = enable_realtime_transcription
509
534
  self.use_main_model_for_realtime = use_main_model_for_realtime
510
535
  self.main_model_type = model
536
+ self.download_root = download_root
511
537
  self.realtime_model_type = realtime_model_type
512
538
  self.realtime_processing_pause = realtime_processing_pause
513
539
  self.init_realtime_after_seconds = init_realtime_after_seconds
@@ -522,6 +548,8 @@ class AudioToTextRecorder:
522
548
  self.beam_size = beam_size
523
549
  self.beam_size_realtime = beam_size_realtime
524
550
  self.allowed_latency_limit = allowed_latency_limit
551
+ self.batch_size = batch_size
552
+ self.realtime_batch_size = realtime_batch_size
525
553
 
526
554
  self.level = level
527
555
  self.audio_queue = mp.Queue()
@@ -630,7 +658,8 @@ class AudioToTextRecorder:
630
658
  args=(
631
659
  child_transcription_pipe,
632
660
  child_stdout_pipe,
633
- model,
661
+ self.main_model_type,
662
+ self.download_root,
634
663
  self.compute_type,
635
664
  self.gpu_device_index,
636
665
  self.device,
@@ -639,7 +668,8 @@ class AudioToTextRecorder:
639
668
  self.interrupt_stop_event,
640
669
  self.beam_size,
641
670
  self.initial_prompt,
642
- self.suppress_tokens
671
+ self.suppress_tokens,
672
+ self.batch_size
643
673
  )
644
674
  )
645
675
 
@@ -673,8 +703,11 @@ class AudioToTextRecorder:
673
703
  model_size_or_path=self.realtime_model_type,
674
704
  device=self.device,
675
705
  compute_type=self.compute_type,
676
- device_index=self.gpu_device_index
706
+ device_index=self.gpu_device_index,
707
+ download_root=self.download_root,
677
708
  )
709
+ if self.realtime_batch_size > 0:
710
+ self.realtime_model_type = BatchedInferencePipeline(model=self.realtime_model_type)
678
711
 
679
712
  except Exception as e:
680
713
  logging.exception("Error initializing faster_whisper "
@@ -2066,13 +2099,23 @@ class AudioToTextRecorder:
2066
2099
  continue
2067
2100
  else:
2068
2101
  # Perform transcription and assemble the text
2069
- segments, info = self.realtime_model_type.transcribe(
2070
- audio_array,
2071
- language=self.language if self.language else None,
2072
- beam_size=self.beam_size_realtime,
2073
- initial_prompt=self.initial_prompt,
2074
- suppress_tokens=self.suppress_tokens,
2075
- )
2102
+ if self.realtime_batch_size > 0:
2103
+ segments, info = self.realtime_model_type.transcribe(
2104
+ audio_array,
2105
+ language=self.language if self.language else None,
2106
+ beam_size=self.beam_size_realtime,
2107
+ initial_prompt=self.initial_prompt,
2108
+ suppress_tokens=self.suppress_tokens,
2109
+ batch_size=self.realtime_batch_size
2110
+ )
2111
+ else:
2112
+ segments, info = self.realtime_model_type.transcribe(
2113
+ audio_array,
2114
+ language=self.language if self.language else None,
2115
+ beam_size=self.beam_size_realtime,
2116
+ initial_prompt=self.initial_prompt,
2117
+ suppress_tokens=self.suppress_tokens
2118
+ )
2076
2119
 
2077
2120
  self.detected_realtime_language = info.language if info.language_probability > 0 else None
2078
2121
  self.detected_realtime_language_probability = info.language_probability