RealTimeSTT 0.2.42__tar.gz → 0.3.1__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.
- {RealtimeSTT-0.2.42/RealtimeSTT.egg-info → realtimestt-0.3.1}/PKG-INFO +158 -11
- RealtimeSTT-0.2.42/PKG-INFO → realtimestt-0.3.1/README.md +150 -30
- realtimestt-0.3.1/RealtimeSTT/__init__.py +2 -0
- {RealtimeSTT-0.2.42 → realtimestt-0.3.1}/RealtimeSTT/audio_recorder.py +606 -245
- realtimestt-0.3.1/RealtimeSTT/audio_recorder_client.py +665 -0
- RealtimeSTT-0.2.42/README.md → realtimestt-0.3.1/RealtimeSTT.egg-info/PKG-INFO +176 -4
- {RealtimeSTT-0.2.42 → realtimestt-0.3.1}/RealtimeSTT.egg-info/SOURCES.txt +6 -3
- realtimestt-0.3.1/RealtimeSTT.egg-info/entry_points.txt +3 -0
- realtimestt-0.3.1/RealtimeSTT.egg-info/requires.txt +12 -0
- {RealtimeSTT-0.2.42 → realtimestt-0.3.1}/RealtimeSTT.egg-info/top_level.txt +1 -0
- realtimestt-0.3.1/server/__init__.py +0 -0
- realtimestt-0.3.1/server/install_packages.py +105 -0
- realtimestt-0.3.1/server/stt_cli_client.py +554 -0
- realtimestt-0.3.1/server/stt_server.py +543 -0
- {RealtimeSTT-0.2.42 → realtimestt-0.3.1}/setup.py +8 -2
- RealtimeSTT-0.2.42/RealtimeSTT/__init__.py +0 -1
- RealtimeSTT-0.2.42/RealtimeSTT/audio_recorder - Kopie (2).py +0 -3046
- RealtimeSTT-0.2.42/RealtimeSTT/audio_recorder - Kopie.py +0 -2234
- RealtimeSTT-0.2.42/RealtimeSTT.egg-info/requires.txt +0 -10
- RealtimeSTT-0.2.42/tests/test_piper.py +0 -58
- {RealtimeSTT-0.2.42 → realtimestt-0.3.1}/LICENSE +0 -0
- {RealtimeSTT-0.2.42 → realtimestt-0.3.1}/RealtimeSTT.egg-info/dependency_links.txt +0 -0
- {RealtimeSTT-0.2.42 → realtimestt-0.3.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: RealtimeSTT
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
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
|
|
@@ -15,22 +15,30 @@ License-File: LICENSE
|
|
|
15
15
|
Requires-Dist: PyAudio==0.2.14
|
|
16
16
|
Requires-Dist: faster-whisper==1.0.3
|
|
17
17
|
Requires-Dist: pvporcupine==1.9.5
|
|
18
|
-
Requires-Dist: webrtcvad==2.0.
|
|
18
|
+
Requires-Dist: webrtcvad-wheels==2.0.14
|
|
19
19
|
Requires-Dist: halo==0.0.31
|
|
20
|
-
Requires-Dist: torch
|
|
21
|
-
Requires-Dist: torchaudio
|
|
22
|
-
Requires-Dist: scipy==1.
|
|
20
|
+
Requires-Dist: torch
|
|
21
|
+
Requires-Dist: torchaudio
|
|
22
|
+
Requires-Dist: scipy==1.14.1
|
|
23
23
|
Requires-Dist: websockets==v12.0
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
|
|
24
|
+
Requires-Dist: websocket-client==1.8.0
|
|
25
|
+
Requires-Dist: openwakeword>=0.4.0
|
|
26
|
+
Requires-Dist: numpy<2.0.0
|
|
26
27
|
|
|
27
28
|
# RealtimeSTT
|
|
29
|
+
[](https://pypi.org/project/RealtimeSTT/)
|
|
30
|
+
[](https://pepy.tech/project/KoljaB/RealtimeSTT)
|
|
31
|
+
[](https://GitHub.com/KoljaB/RealtimeSTT/releases/)
|
|
32
|
+
[](https://GitHub.com/Naereen/KoljaB/RealtimeSTT/commit/)
|
|
33
|
+
[](https://GitHub.com/KoljaB/RealtimeSTT/network/)
|
|
34
|
+
[](https://GitHub.com/KoljaB/RealtimeSTT/stargazers/)
|
|
28
35
|
|
|
29
36
|
*Easy-to-use, low-latency speech-to-text library for realtime applications*
|
|
30
37
|
|
|
31
38
|
## New
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
- AudioToTextRecorderClient class, which automatically starts a server if none is running and connects to it. The class shares the same interface as AudioToTextRecorder, making it easy to upgrade or switch between the two. (Work in progress, most parameters and callbacks of AudioToTextRecorder are already implemented into AudioToTextRecorderClient, but not all. Also the server can not handle concurrent (parallel) requests yet.)
|
|
41
|
+
- reworked CLI interface ("stt-server" to start the server, "stt" to start the client, look at "server" folder for more info)
|
|
34
42
|
|
|
35
43
|
## About the Project
|
|
36
44
|
|
|
@@ -43,16 +51,53 @@ It's ideal for:
|
|
|
43
51
|
- **Voice Assistants**
|
|
44
52
|
- Applications requiring **fast and precise** speech-to-text conversion
|
|
45
53
|
|
|
46
|
-
https://github.com/
|
|
54
|
+
https://github.com/user-attachments/assets/797e6552-27cd-41b1-a7f3-e5cbc72094f5
|
|
47
55
|
|
|
48
56
|
### Updates
|
|
49
57
|
|
|
50
|
-
Latest Version: v0.
|
|
58
|
+
Latest Version: v0.3.1
|
|
51
59
|
|
|
52
60
|
See [release history](https://github.com/KoljaB/RealtimeSTT/releases).
|
|
53
61
|
|
|
54
62
|
> **Hint:** *Since we use the `multiprocessing` module now, ensure to include the `if __name__ == '__main__':` protection in your code to prevent unexpected behavior, especially on platforms like Windows. For a detailed explanation on why this is important, visit the [official Python documentation on `multiprocessing`](https://docs.python.org/3/library/multiprocessing.html#multiprocessing-programming).*
|
|
55
63
|
|
|
64
|
+
## Quick Examples
|
|
65
|
+
|
|
66
|
+
### Print everything being said:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
70
|
+
import pyautogui
|
|
71
|
+
|
|
72
|
+
def process_text(text):
|
|
73
|
+
print(text)
|
|
74
|
+
|
|
75
|
+
if __name__ == '__main__':
|
|
76
|
+
print("Wait until it says 'speak now'")
|
|
77
|
+
recorder = AudioToTextRecorder()
|
|
78
|
+
|
|
79
|
+
while True:
|
|
80
|
+
recorder.text(process_text)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Type everything being said:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
87
|
+
import pyautogui
|
|
88
|
+
|
|
89
|
+
def process_text(text):
|
|
90
|
+
pyautogui.typewrite(text + " ")
|
|
91
|
+
|
|
92
|
+
if __name__ == '__main__':
|
|
93
|
+
print("Wait until it says 'speak now'")
|
|
94
|
+
recorder = AudioToTextRecorder()
|
|
95
|
+
|
|
96
|
+
while True:
|
|
97
|
+
recorder.text(process_text)
|
|
98
|
+
```
|
|
99
|
+
*Will type everything being said into your selected text box*
|
|
100
|
+
|
|
56
101
|
### Features
|
|
57
102
|
|
|
58
103
|
- **Voice Activity Detection**: Automatically detects when you start and stop speaking.
|
|
@@ -183,6 +228,19 @@ recorder.stop()
|
|
|
183
228
|
print(recorder.text())
|
|
184
229
|
```
|
|
185
230
|
|
|
231
|
+
#### Standalone Example:
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
235
|
+
|
|
236
|
+
if __name__ == '__main__':
|
|
237
|
+
recorder = AudioToTextRecorder()
|
|
238
|
+
recorder.start()
|
|
239
|
+
input("Press Enter to stop recording...")
|
|
240
|
+
recorder.stop()
|
|
241
|
+
print("Transcription: ", recorder.text())
|
|
242
|
+
```
|
|
243
|
+
|
|
186
244
|
### Automatic Recording
|
|
187
245
|
|
|
188
246
|
Recording based on voice activity detection.
|
|
@@ -192,8 +250,19 @@ with AudioToTextRecorder() as recorder:
|
|
|
192
250
|
print(recorder.text())
|
|
193
251
|
```
|
|
194
252
|
|
|
253
|
+
#### Standalone Example:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
257
|
+
|
|
258
|
+
if __name__ == '__main__':
|
|
259
|
+
with AudioToTextRecorder() as recorder:
|
|
260
|
+
print("Transcription: ", recorder.text())
|
|
261
|
+
```
|
|
262
|
+
|
|
195
263
|
When running recorder.text in a loop it is recommended to use a callback, allowing the transcription to be run asynchronously:
|
|
196
264
|
|
|
265
|
+
|
|
197
266
|
```python
|
|
198
267
|
def process_text(text):
|
|
199
268
|
print (text)
|
|
@@ -202,6 +271,21 @@ while True:
|
|
|
202
271
|
recorder.text(process_text)
|
|
203
272
|
```
|
|
204
273
|
|
|
274
|
+
#### Standalone Example:
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
278
|
+
|
|
279
|
+
def process_text(text):
|
|
280
|
+
print(text)
|
|
281
|
+
|
|
282
|
+
if __name__ == '__main__':
|
|
283
|
+
recorder = AudioToTextRecorder()
|
|
284
|
+
|
|
285
|
+
while True:
|
|
286
|
+
recorder.text(process_text)
|
|
287
|
+
```
|
|
288
|
+
|
|
205
289
|
### Wakewords
|
|
206
290
|
|
|
207
291
|
Keyword activation before detecting voice. Write the comma-separated list of your desired activation keywords into the wake_words parameter. You can choose wake words from these list: alexa, americano, blueberry, bumblebee, computer, grapefruits, grasshopper, hey google, hey siri, jarvis, ok google, picovoice, porcupine, terminator.
|
|
@@ -213,6 +297,18 @@ print('Say "Jarvis" then speak.')
|
|
|
213
297
|
print(recorder.text())
|
|
214
298
|
```
|
|
215
299
|
|
|
300
|
+
#### Standalone Example:
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
304
|
+
|
|
305
|
+
if __name__ == '__main__':
|
|
306
|
+
recorder = AudioToTextRecorder(wake_words="jarvis")
|
|
307
|
+
|
|
308
|
+
print('Say "Jarvis" to start recording.')
|
|
309
|
+
print(recorder.text())
|
|
310
|
+
```
|
|
311
|
+
|
|
216
312
|
### Callbacks
|
|
217
313
|
|
|
218
314
|
You can set callback functions to be executed on different events (see [Configuration](#configuration)) :
|
|
@@ -228,6 +324,22 @@ recorder = AudioToTextRecorder(on_recording_start=my_start_callback,
|
|
|
228
324
|
on_recording_stop=my_stop_callback)
|
|
229
325
|
```
|
|
230
326
|
|
|
327
|
+
#### Standalone Example:
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
331
|
+
|
|
332
|
+
def start_callback():
|
|
333
|
+
print("Recording started!")
|
|
334
|
+
|
|
335
|
+
def stop_callback():
|
|
336
|
+
print("Recording stopped!")
|
|
337
|
+
|
|
338
|
+
if __name__ == '__main__':
|
|
339
|
+
recorder = AudioToTextRecorder(on_recording_start=start_callback,
|
|
340
|
+
on_recording_stop=stop_callback)
|
|
341
|
+
```
|
|
342
|
+
|
|
231
343
|
### Feed chunks
|
|
232
344
|
|
|
233
345
|
If you don't want to use the local microphone set use_microphone parameter to false and provide raw PCM audiochunks in 16-bit mono (samplerate 16000) with this method:
|
|
@@ -236,6 +348,20 @@ If you don't want to use the local microphone set use_microphone parameter to fa
|
|
|
236
348
|
recorder.feed_audio(audio_chunk)
|
|
237
349
|
```
|
|
238
350
|
|
|
351
|
+
#### Standalone Example:
|
|
352
|
+
|
|
353
|
+
```python
|
|
354
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
355
|
+
|
|
356
|
+
if __name__ == '__main__':
|
|
357
|
+
recorder = AudioToTextRecorder(use_microphone=False)
|
|
358
|
+
with open("audio_chunk.pcm", "rb") as f:
|
|
359
|
+
audio_chunk = f.read()
|
|
360
|
+
|
|
361
|
+
recorder.feed_audio(audio_chunk)
|
|
362
|
+
print("Transcription: ", recorder.text())
|
|
363
|
+
```
|
|
364
|
+
|
|
239
365
|
### Shutdown
|
|
240
366
|
|
|
241
367
|
You can shutdown the recorder safely by using the context manager protocol:
|
|
@@ -245,12 +371,25 @@ with AudioToTextRecorder() as recorder:
|
|
|
245
371
|
[...]
|
|
246
372
|
```
|
|
247
373
|
|
|
374
|
+
|
|
248
375
|
Or you can call the shutdown method manually (if using "with" is not feasible):
|
|
249
376
|
|
|
250
377
|
```python
|
|
251
378
|
recorder.shutdown()
|
|
252
379
|
```
|
|
253
380
|
|
|
381
|
+
#### Standalone Example:
|
|
382
|
+
|
|
383
|
+
```python
|
|
384
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
385
|
+
|
|
386
|
+
if __name__ == '__main__':
|
|
387
|
+
with AudioToTextRecorder() as recorder:
|
|
388
|
+
[...]
|
|
389
|
+
# or manually shutdown if "with" is not used
|
|
390
|
+
recorder.shutdown()
|
|
391
|
+
```
|
|
392
|
+
|
|
254
393
|
## Testing the Library
|
|
255
394
|
|
|
256
395
|
The test subdirectory contains a set of scripts to help you evaluate and understand the capabilities of the RealtimeTTS library.
|
|
@@ -335,6 +474,14 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
|
|
|
335
474
|
|
|
336
475
|
- **debug_mode** (bool, default=False): If set, the system prints additional debug information to the console.
|
|
337
476
|
|
|
477
|
+
- **print_transcription_time** (bool, default=False): Logs the processing time of the main model transcription. This can be useful for performance monitoring and debugging.
|
|
478
|
+
|
|
479
|
+
- **early_transcription_on_silence** (int, default=0): If set, the system will transcribe audio faster when silence is detected. Transcription will start after the specified milliseconds. Keep this value lower than `post_speech_silence_duration`, ideally around `post_speech_silence_duration` minus the estimated transcription time with the main model. If silence lasts longer than `post_speech_silence_duration`, the recording is stopped, and the transcription is submitted. If voice activity resumes within this period, the transcription is discarded. This results in faster final transcriptions at the cost of additional GPU load due to some unnecessary final transcriptions.
|
|
480
|
+
|
|
481
|
+
- **allowed_latency_limit** (int, default=100): Specifies the maximum number of unprocessed chunks in the queue before discarding chunks. This helps prevent the system from being overwhelmed and losing responsiveness in real-time applications.
|
|
482
|
+
|
|
483
|
+
- **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.
|
|
484
|
+
|
|
338
485
|
#### Real-time Transcription Parameters
|
|
339
486
|
|
|
340
487
|
> **Note**: *When enabling realtime description a GPU installation is strongly advised. Using realtime transcription may create high GPU loads.*
|
|
@@ -437,7 +584,7 @@ Shoutout to [Steven Linn](https://github.com/stevenlafl) for providing docker su
|
|
|
437
584
|
|
|
438
585
|
## License
|
|
439
586
|
|
|
440
|
-
MIT
|
|
587
|
+
[MIT](https://github.com/KoljaB/RealtimeSTT?tab=MIT-1-ov-file)
|
|
441
588
|
|
|
442
589
|
## Author
|
|
443
590
|
|
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: RealtimeSTT
|
|
3
|
-
Version: 0.2.42
|
|
4
|
-
Summary: A fast Voice Activity Detection and Transcription System
|
|
5
|
-
Home-page: https://github.com/KoljaB/RealTimeSTT
|
|
6
|
-
Author: Kolja Beigel
|
|
7
|
-
Author-email: kolja.beigel@web.de
|
|
8
|
-
Keywords: real-time,audio,transcription,speech-to-text,voice-activity-detection,VAD,real-time-transcription,ambient-noise-detection,microphone-input,faster_whisper,speech-recognition,voice-assistants,audio-processing,buffered-transcription,pyaudio,ambient-noise-level,voice-deactivity
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.6
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: PyAudio==0.2.14
|
|
16
|
-
Requires-Dist: faster-whisper==1.0.3
|
|
17
|
-
Requires-Dist: pvporcupine==1.9.5
|
|
18
|
-
Requires-Dist: webrtcvad==2.0.10
|
|
19
|
-
Requires-Dist: halo==0.0.31
|
|
20
|
-
Requires-Dist: torch==2.3.1
|
|
21
|
-
Requires-Dist: torchaudio==2.3.1
|
|
22
|
-
Requires-Dist: scipy==1.12.0
|
|
23
|
-
Requires-Dist: websockets==v12.0
|
|
24
|
-
Requires-Dist: openwakeword==0.6.0
|
|
25
|
-
|
|
26
|
-
|
|
27
1
|
# RealtimeSTT
|
|
2
|
+
[](https://pypi.org/project/RealtimeSTT/)
|
|
3
|
+
[](https://pepy.tech/project/KoljaB/RealtimeSTT)
|
|
4
|
+
[](https://GitHub.com/KoljaB/RealtimeSTT/releases/)
|
|
5
|
+
[](https://GitHub.com/Naereen/KoljaB/RealtimeSTT/commit/)
|
|
6
|
+
[](https://GitHub.com/KoljaB/RealtimeSTT/network/)
|
|
7
|
+
[](https://GitHub.com/KoljaB/RealtimeSTT/stargazers/)
|
|
28
8
|
|
|
29
9
|
*Easy-to-use, low-latency speech-to-text library for realtime applications*
|
|
30
10
|
|
|
31
11
|
## New
|
|
32
12
|
|
|
33
|
-
|
|
13
|
+
- AudioToTextRecorderClient class, which automatically starts a server if none is running and connects to it. The class shares the same interface as AudioToTextRecorder, making it easy to upgrade or switch between the two. (Work in progress, most parameters and callbacks of AudioToTextRecorder are already implemented into AudioToTextRecorderClient, but not all. Also the server can not handle concurrent (parallel) requests yet.)
|
|
14
|
+
- reworked CLI interface ("stt-server" to start the server, "stt" to start the client, look at "server" folder for more info)
|
|
34
15
|
|
|
35
16
|
## About the Project
|
|
36
17
|
|
|
@@ -43,16 +24,53 @@ It's ideal for:
|
|
|
43
24
|
- **Voice Assistants**
|
|
44
25
|
- Applications requiring **fast and precise** speech-to-text conversion
|
|
45
26
|
|
|
46
|
-
https://github.com/
|
|
27
|
+
https://github.com/user-attachments/assets/797e6552-27cd-41b1-a7f3-e5cbc72094f5
|
|
47
28
|
|
|
48
29
|
### Updates
|
|
49
30
|
|
|
50
|
-
Latest Version: v0.
|
|
31
|
+
Latest Version: v0.3.1
|
|
51
32
|
|
|
52
33
|
See [release history](https://github.com/KoljaB/RealtimeSTT/releases).
|
|
53
34
|
|
|
54
35
|
> **Hint:** *Since we use the `multiprocessing` module now, ensure to include the `if __name__ == '__main__':` protection in your code to prevent unexpected behavior, especially on platforms like Windows. For a detailed explanation on why this is important, visit the [official Python documentation on `multiprocessing`](https://docs.python.org/3/library/multiprocessing.html#multiprocessing-programming).*
|
|
55
36
|
|
|
37
|
+
## Quick Examples
|
|
38
|
+
|
|
39
|
+
### Print everything being said:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
43
|
+
import pyautogui
|
|
44
|
+
|
|
45
|
+
def process_text(text):
|
|
46
|
+
print(text)
|
|
47
|
+
|
|
48
|
+
if __name__ == '__main__':
|
|
49
|
+
print("Wait until it says 'speak now'")
|
|
50
|
+
recorder = AudioToTextRecorder()
|
|
51
|
+
|
|
52
|
+
while True:
|
|
53
|
+
recorder.text(process_text)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Type everything being said:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
60
|
+
import pyautogui
|
|
61
|
+
|
|
62
|
+
def process_text(text):
|
|
63
|
+
pyautogui.typewrite(text + " ")
|
|
64
|
+
|
|
65
|
+
if __name__ == '__main__':
|
|
66
|
+
print("Wait until it says 'speak now'")
|
|
67
|
+
recorder = AudioToTextRecorder()
|
|
68
|
+
|
|
69
|
+
while True:
|
|
70
|
+
recorder.text(process_text)
|
|
71
|
+
```
|
|
72
|
+
*Will type everything being said into your selected text box*
|
|
73
|
+
|
|
56
74
|
### Features
|
|
57
75
|
|
|
58
76
|
- **Voice Activity Detection**: Automatically detects when you start and stop speaking.
|
|
@@ -183,6 +201,19 @@ recorder.stop()
|
|
|
183
201
|
print(recorder.text())
|
|
184
202
|
```
|
|
185
203
|
|
|
204
|
+
#### Standalone Example:
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
208
|
+
|
|
209
|
+
if __name__ == '__main__':
|
|
210
|
+
recorder = AudioToTextRecorder()
|
|
211
|
+
recorder.start()
|
|
212
|
+
input("Press Enter to stop recording...")
|
|
213
|
+
recorder.stop()
|
|
214
|
+
print("Transcription: ", recorder.text())
|
|
215
|
+
```
|
|
216
|
+
|
|
186
217
|
### Automatic Recording
|
|
187
218
|
|
|
188
219
|
Recording based on voice activity detection.
|
|
@@ -192,8 +223,19 @@ with AudioToTextRecorder() as recorder:
|
|
|
192
223
|
print(recorder.text())
|
|
193
224
|
```
|
|
194
225
|
|
|
226
|
+
#### Standalone Example:
|
|
227
|
+
|
|
228
|
+
```python
|
|
229
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
230
|
+
|
|
231
|
+
if __name__ == '__main__':
|
|
232
|
+
with AudioToTextRecorder() as recorder:
|
|
233
|
+
print("Transcription: ", recorder.text())
|
|
234
|
+
```
|
|
235
|
+
|
|
195
236
|
When running recorder.text in a loop it is recommended to use a callback, allowing the transcription to be run asynchronously:
|
|
196
237
|
|
|
238
|
+
|
|
197
239
|
```python
|
|
198
240
|
def process_text(text):
|
|
199
241
|
print (text)
|
|
@@ -202,6 +244,21 @@ while True:
|
|
|
202
244
|
recorder.text(process_text)
|
|
203
245
|
```
|
|
204
246
|
|
|
247
|
+
#### Standalone Example:
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
251
|
+
|
|
252
|
+
def process_text(text):
|
|
253
|
+
print(text)
|
|
254
|
+
|
|
255
|
+
if __name__ == '__main__':
|
|
256
|
+
recorder = AudioToTextRecorder()
|
|
257
|
+
|
|
258
|
+
while True:
|
|
259
|
+
recorder.text(process_text)
|
|
260
|
+
```
|
|
261
|
+
|
|
205
262
|
### Wakewords
|
|
206
263
|
|
|
207
264
|
Keyword activation before detecting voice. Write the comma-separated list of your desired activation keywords into the wake_words parameter. You can choose wake words from these list: alexa, americano, blueberry, bumblebee, computer, grapefruits, grasshopper, hey google, hey siri, jarvis, ok google, picovoice, porcupine, terminator.
|
|
@@ -213,6 +270,18 @@ print('Say "Jarvis" then speak.')
|
|
|
213
270
|
print(recorder.text())
|
|
214
271
|
```
|
|
215
272
|
|
|
273
|
+
#### Standalone Example:
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
277
|
+
|
|
278
|
+
if __name__ == '__main__':
|
|
279
|
+
recorder = AudioToTextRecorder(wake_words="jarvis")
|
|
280
|
+
|
|
281
|
+
print('Say "Jarvis" to start recording.')
|
|
282
|
+
print(recorder.text())
|
|
283
|
+
```
|
|
284
|
+
|
|
216
285
|
### Callbacks
|
|
217
286
|
|
|
218
287
|
You can set callback functions to be executed on different events (see [Configuration](#configuration)) :
|
|
@@ -228,6 +297,22 @@ recorder = AudioToTextRecorder(on_recording_start=my_start_callback,
|
|
|
228
297
|
on_recording_stop=my_stop_callback)
|
|
229
298
|
```
|
|
230
299
|
|
|
300
|
+
#### Standalone Example:
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
304
|
+
|
|
305
|
+
def start_callback():
|
|
306
|
+
print("Recording started!")
|
|
307
|
+
|
|
308
|
+
def stop_callback():
|
|
309
|
+
print("Recording stopped!")
|
|
310
|
+
|
|
311
|
+
if __name__ == '__main__':
|
|
312
|
+
recorder = AudioToTextRecorder(on_recording_start=start_callback,
|
|
313
|
+
on_recording_stop=stop_callback)
|
|
314
|
+
```
|
|
315
|
+
|
|
231
316
|
### Feed chunks
|
|
232
317
|
|
|
233
318
|
If you don't want to use the local microphone set use_microphone parameter to false and provide raw PCM audiochunks in 16-bit mono (samplerate 16000) with this method:
|
|
@@ -236,6 +321,20 @@ If you don't want to use the local microphone set use_microphone parameter to fa
|
|
|
236
321
|
recorder.feed_audio(audio_chunk)
|
|
237
322
|
```
|
|
238
323
|
|
|
324
|
+
#### Standalone Example:
|
|
325
|
+
|
|
326
|
+
```python
|
|
327
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
328
|
+
|
|
329
|
+
if __name__ == '__main__':
|
|
330
|
+
recorder = AudioToTextRecorder(use_microphone=False)
|
|
331
|
+
with open("audio_chunk.pcm", "rb") as f:
|
|
332
|
+
audio_chunk = f.read()
|
|
333
|
+
|
|
334
|
+
recorder.feed_audio(audio_chunk)
|
|
335
|
+
print("Transcription: ", recorder.text())
|
|
336
|
+
```
|
|
337
|
+
|
|
239
338
|
### Shutdown
|
|
240
339
|
|
|
241
340
|
You can shutdown the recorder safely by using the context manager protocol:
|
|
@@ -245,12 +344,25 @@ with AudioToTextRecorder() as recorder:
|
|
|
245
344
|
[...]
|
|
246
345
|
```
|
|
247
346
|
|
|
347
|
+
|
|
248
348
|
Or you can call the shutdown method manually (if using "with" is not feasible):
|
|
249
349
|
|
|
250
350
|
```python
|
|
251
351
|
recorder.shutdown()
|
|
252
352
|
```
|
|
253
353
|
|
|
354
|
+
#### Standalone Example:
|
|
355
|
+
|
|
356
|
+
```python
|
|
357
|
+
from RealtimeSTT import AudioToTextRecorder
|
|
358
|
+
|
|
359
|
+
if __name__ == '__main__':
|
|
360
|
+
with AudioToTextRecorder() as recorder:
|
|
361
|
+
[...]
|
|
362
|
+
# or manually shutdown if "with" is not used
|
|
363
|
+
recorder.shutdown()
|
|
364
|
+
```
|
|
365
|
+
|
|
254
366
|
## Testing the Library
|
|
255
367
|
|
|
256
368
|
The test subdirectory contains a set of scripts to help you evaluate and understand the capabilities of the RealtimeTTS library.
|
|
@@ -335,6 +447,14 @@ When you initialize the `AudioToTextRecorder` class, you have various options to
|
|
|
335
447
|
|
|
336
448
|
- **debug_mode** (bool, default=False): If set, the system prints additional debug information to the console.
|
|
337
449
|
|
|
450
|
+
- **print_transcription_time** (bool, default=False): Logs the processing time of the main model transcription. This can be useful for performance monitoring and debugging.
|
|
451
|
+
|
|
452
|
+
- **early_transcription_on_silence** (int, default=0): If set, the system will transcribe audio faster when silence is detected. Transcription will start after the specified milliseconds. Keep this value lower than `post_speech_silence_duration`, ideally around `post_speech_silence_duration` minus the estimated transcription time with the main model. If silence lasts longer than `post_speech_silence_duration`, the recording is stopped, and the transcription is submitted. If voice activity resumes within this period, the transcription is discarded. This results in faster final transcriptions at the cost of additional GPU load due to some unnecessary final transcriptions.
|
|
453
|
+
|
|
454
|
+
- **allowed_latency_limit** (int, default=100): Specifies the maximum number of unprocessed chunks in the queue before discarding chunks. This helps prevent the system from being overwhelmed and losing responsiveness in real-time applications.
|
|
455
|
+
|
|
456
|
+
- **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.
|
|
457
|
+
|
|
338
458
|
#### Real-time Transcription Parameters
|
|
339
459
|
|
|
340
460
|
> **Note**: *When enabling realtime description a GPU installation is strongly advised. Using realtime transcription may create high GPU loads.*
|
|
@@ -437,7 +557,7 @@ Shoutout to [Steven Linn](https://github.com/stevenlafl) for providing docker su
|
|
|
437
557
|
|
|
438
558
|
## License
|
|
439
559
|
|
|
440
|
-
MIT
|
|
560
|
+
[MIT](https://github.com/KoljaB/RealtimeSTT?tab=MIT-1-ov-file)
|
|
441
561
|
|
|
442
562
|
## Author
|
|
443
563
|
|