s2t 0.1.0.post1.dev2__py3-none-any.whl → 0.1.1__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.
- s2t/cli.py +2 -0
- s2t/whisper_engine.py +22 -1
- {s2t-0.1.0.post1.dev2.dist-info → s2t-0.1.1.dist-info}/METADATA +1 -1
- s2t-0.1.1.dist-info/RECORD +14 -0
- s2t-0.1.0.post1.dev2.dist-info/RECORD +0 -14
- {s2t-0.1.0.post1.dev2.dist-info → s2t-0.1.1.dist-info}/WHEEL +0 -0
- {s2t-0.1.0.post1.dev2.dist-info → s2t-0.1.1.dist-info}/entry_points.txt +0 -0
- {s2t-0.1.0.post1.dev2.dist-info → s2t-0.1.1.dist-info}/top_level.txt +0 -0
s2t/cli.py
CHANGED
@@ -256,6 +256,8 @@ def run_session(opts: SessionOptions) -> int:
|
|
256
256
|
else:
|
257
257
|
print("—" * 60)
|
258
258
|
print("Transcript (clipboard text):")
|
259
|
+
# Visual separator before the actual transcript text
|
260
|
+
print("=" * 60)
|
259
261
|
print(text_final.rstrip("\n"))
|
260
262
|
|
261
263
|
if opts.profile:
|
s2t/whisper_engine.py
CHANGED
@@ -75,10 +75,31 @@ class WhisperEngine:
|
|
75
75
|
frames: int,
|
76
76
|
initial_prompt: str | None = None,
|
77
77
|
) -> TranscriptionResult:
|
78
|
+
# Load audio without ffmpeg by reading via soundfile and passing a numpy array
|
79
|
+
# to Whisper. We ensure mono float32 at 16 kHz as expected by Whisper's API.
|
78
80
|
task = "translate" if self.translate else "transcribe"
|
81
|
+
import numpy as np
|
82
|
+
|
83
|
+
try:
|
84
|
+
import soundfile as sf
|
85
|
+
except Exception as e:
|
86
|
+
raise RuntimeError("soundfile is required to read recorded audio.") from e
|
87
|
+
|
88
|
+
from .utils import resample_linear
|
89
|
+
|
90
|
+
# Read audio from file (supports WAV/FLAC via libsndfile), convert to mono
|
91
|
+
data, sr = sf.read(str(audio_path), dtype="float32", always_2d=True)
|
92
|
+
# data shape: (n_frames, n_channels). Convert to mono by averaging if needed
|
93
|
+
if data.ndim == 2 and data.shape[1] > 1:
|
94
|
+
mono = data.mean(axis=1)
|
95
|
+
else:
|
96
|
+
mono = data.reshape(-1)
|
97
|
+
# Resample to 16k expected by Whisper when passing arrays
|
98
|
+
mono_16k: np.ndarray = resample_linear(mono, int(sr), 16000)
|
99
|
+
|
79
100
|
t0 = time.perf_counter()
|
80
101
|
res: dict[str, Any] = model.transcribe(
|
81
|
-
|
102
|
+
mono_16k,
|
82
103
|
task=task,
|
83
104
|
language=self.language,
|
84
105
|
fp16=False,
|
@@ -0,0 +1,14 @@
|
|
1
|
+
s2t/__init__.py,sha256=wV4E9i-7KrUn1dOtLUQB3ZGEKx9gRWH3hPHlpw-ZdWc,332
|
2
|
+
s2t/cli.py,sha256=_7zIhcdI7DI_3Dxs2EcvQkE-fSGclkJ2TjCvDYlI65E,15871
|
3
|
+
s2t/config.py,sha256=mzz6ljGEupNDAzlUwf5kvl0iKqO8WZ4TWsU4nSVtp0M,409
|
4
|
+
s2t/outputs.py,sha256=Lo8VcARZ7QPuuQQNu8myD5J4c4NO1Rs0L1DLnzLe9tM,1546
|
5
|
+
s2t/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
6
|
+
s2t/recorder.py,sha256=uBD9mYf-uUCkRJw8fQitVnDrX6PwRNXJycyY4dBfXL0,8076
|
7
|
+
s2t/types.py,sha256=BuMyWuueS7EZbk7I_CkIWSb69Yi6g9-wr7CZLAZKflw,242
|
8
|
+
s2t/utils.py,sha256=YU6YhiuONmqhrKte4DY5tiC5PP-yFExJMMBzFUiA8qA,3416
|
9
|
+
s2t/whisper_engine.py,sha256=T_M2ghXfUbFgJqiDI46ZQB1GugzjIRb7hv22fqls65M,5996
|
10
|
+
s2t-0.1.1.dist-info/METADATA,sha256=G2dB1li8K3NRKXhpKgySgKAo94AiqxXa141Wb_-v1-4,4557
|
11
|
+
s2t-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
12
|
+
s2t-0.1.1.dist-info/entry_points.txt,sha256=JISIUlZAJ3DX1dB6zT3X_E3vcXI-eWEQKwHiT35fPKs,37
|
13
|
+
s2t-0.1.1.dist-info/top_level.txt,sha256=o8N0JcuHdIrfX3iGHvntHiDC2XgN7__joyNu08ZOh0s,4
|
14
|
+
s2t-0.1.1.dist-info/RECORD,,
|
@@ -1,14 +0,0 @@
|
|
1
|
-
s2t/__init__.py,sha256=wV4E9i-7KrUn1dOtLUQB3ZGEKx9gRWH3hPHlpw-ZdWc,332
|
2
|
-
s2t/cli.py,sha256=5Z0YxLPwvfV8wrU-vN1s1HzzOLmA0HYi5uVf6brUtQQ,15786
|
3
|
-
s2t/config.py,sha256=mzz6ljGEupNDAzlUwf5kvl0iKqO8WZ4TWsU4nSVtp0M,409
|
4
|
-
s2t/outputs.py,sha256=Lo8VcARZ7QPuuQQNu8myD5J4c4NO1Rs0L1DLnzLe9tM,1546
|
5
|
-
s2t/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
6
|
-
s2t/recorder.py,sha256=uBD9mYf-uUCkRJw8fQitVnDrX6PwRNXJycyY4dBfXL0,8076
|
7
|
-
s2t/types.py,sha256=BuMyWuueS7EZbk7I_CkIWSb69Yi6g9-wr7CZLAZKflw,242
|
8
|
-
s2t/utils.py,sha256=YU6YhiuONmqhrKte4DY5tiC5PP-yFExJMMBzFUiA8qA,3416
|
9
|
-
s2t/whisper_engine.py,sha256=s9NBPtyptdhKauKQB4moq2SeGDQp2z7qc13e8C00SxY,5075
|
10
|
-
s2t-0.1.0.post1.dev2.dist-info/METADATA,sha256=c-7jrltbRiLjW0ixPZwgf49L8Ar7p7N5Dc7b0QO_pUo,4568
|
11
|
-
s2t-0.1.0.post1.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
12
|
-
s2t-0.1.0.post1.dev2.dist-info/entry_points.txt,sha256=JISIUlZAJ3DX1dB6zT3X_E3vcXI-eWEQKwHiT35fPKs,37
|
13
|
-
s2t-0.1.0.post1.dev2.dist-info/top_level.txt,sha256=o8N0JcuHdIrfX3iGHvntHiDC2XgN7__joyNu08ZOh0s,4
|
14
|
-
s2t-0.1.0.post1.dev2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|