python-voiceio 0.2.0__py3-none-any.whl
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.
- python_voiceio-0.2.0.dist-info/METADATA +260 -0
- python_voiceio-0.2.0.dist-info/RECORD +43 -0
- python_voiceio-0.2.0.dist-info/WHEEL +5 -0
- python_voiceio-0.2.0.dist-info/entry_points.txt +6 -0
- python_voiceio-0.2.0.dist-info/licenses/LICENSE +21 -0
- python_voiceio-0.2.0.dist-info/top_level.txt +1 -0
- voiceio/__init__.py +1 -0
- voiceio/__main__.py +3 -0
- voiceio/app.py +415 -0
- voiceio/backends.py +13 -0
- voiceio/cli.py +475 -0
- voiceio/config.py +136 -0
- voiceio/feedback.py +78 -0
- voiceio/health.py +194 -0
- voiceio/hotkeys/__init__.py +22 -0
- voiceio/hotkeys/base.py +27 -0
- voiceio/hotkeys/chain.py +83 -0
- voiceio/hotkeys/evdev.py +134 -0
- voiceio/hotkeys/pynput_backend.py +80 -0
- voiceio/hotkeys/socket_backend.py +77 -0
- voiceio/ibus/__init__.py +8 -0
- voiceio/ibus/engine.py +268 -0
- voiceio/platform.py +139 -0
- voiceio/recorder.py +208 -0
- voiceio/service.py +234 -0
- voiceio/sounds/__init__.py +0 -0
- voiceio/sounds/commit.wav +0 -0
- voiceio/sounds/start.wav +0 -0
- voiceio/sounds/stop.wav +0 -0
- voiceio/streaming.py +202 -0
- voiceio/transcriber.py +165 -0
- voiceio/tray.py +54 -0
- voiceio/typers/__init__.py +31 -0
- voiceio/typers/base.py +44 -0
- voiceio/typers/chain.py +79 -0
- voiceio/typers/clipboard.py +110 -0
- voiceio/typers/ibus.py +389 -0
- voiceio/typers/pynput_type.py +51 -0
- voiceio/typers/wtype.py +57 -0
- voiceio/typers/xdotool.py +45 -0
- voiceio/typers/ydotool.py +115 -0
- voiceio/wizard.py +882 -0
- voiceio/worker.py +39 -0
voiceio/worker.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Whisper transcription worker that runs in a subprocess.
|
|
2
|
+
|
|
3
|
+
Communicates with the parent process via stdin (JSON requests) and
|
|
4
|
+
stdout (JSON responses). Loads the model once, then processes requests
|
|
5
|
+
in a loop for low-latency repeated transcriptions.
|
|
6
|
+
|
|
7
|
+
Usage: python3 -m voiceio.worker '{"model": "base", ...}'
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import base64
|
|
12
|
+
import json
|
|
13
|
+
import sys
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
from faster_whisper import WhisperModel
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main() -> None:
|
|
20
|
+
args = json.loads(sys.argv[1])
|
|
21
|
+
model = WhisperModel(args["model"], device=args["device"], compute_type=args["compute_type"])
|
|
22
|
+
|
|
23
|
+
# Warmup: first transcription is always slow
|
|
24
|
+
segs, _ = model.transcribe(np.zeros(16000, dtype=np.float32), language=args.get("language"), beam_size=1)
|
|
25
|
+
list(segs)
|
|
26
|
+
print("READY", flush=True)
|
|
27
|
+
|
|
28
|
+
for line in sys.stdin:
|
|
29
|
+
if line.strip() == "QUIT":
|
|
30
|
+
break
|
|
31
|
+
req = json.loads(line)
|
|
32
|
+
audio = np.frombuffer(base64.b64decode(req["audio_b64"]), dtype=np.float32)
|
|
33
|
+
segs, _ = model.transcribe(audio, language=args.get("language"), beam_size=1, best_of=1)
|
|
34
|
+
text = " ".join(s.text.strip() for s in segs).strip()
|
|
35
|
+
print(json.dumps({"text": text}), flush=True)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
main()
|