s2t 0.1.0.post1.dev2__py3-none-any.whl → 0.1.2__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 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
@@ -29,7 +29,10 @@ class WhisperEngine:
29
29
  self.samplerate = samplerate
30
30
  self.channels = channels
31
31
  self.verbose = verbose
32
- self.profile = profile or {}
32
+ # Use the provided profile dict even if it's empty.
33
+ # Using `or {}` would create a new dict when an empty one is passed,
34
+ # breaking shared accumulation with the caller (CLI).
35
+ self.profile = profile if profile is not None else {}
33
36
  self._executor: ThreadPoolExecutor | None = None
34
37
 
35
38
  def preload(self) -> tuple[ThreadPoolExecutor | None, Future | None]:
@@ -75,10 +78,31 @@ class WhisperEngine:
75
78
  frames: int,
76
79
  initial_prompt: str | None = None,
77
80
  ) -> TranscriptionResult:
81
+ # Load audio without ffmpeg by reading via soundfile and passing a numpy array
82
+ # to Whisper. We ensure mono float32 at 16 kHz as expected by Whisper's API.
78
83
  task = "translate" if self.translate else "transcribe"
84
+ import numpy as np
85
+
86
+ try:
87
+ import soundfile as sf
88
+ except Exception as e:
89
+ raise RuntimeError("soundfile is required to read recorded audio.") from e
90
+
91
+ from .utils import resample_linear
92
+
93
+ # Read audio from file (supports WAV/FLAC via libsndfile), convert to mono
94
+ data, sr = sf.read(str(audio_path), dtype="float32", always_2d=True)
95
+ # data shape: (n_frames, n_channels). Convert to mono by averaging if needed
96
+ if data.ndim == 2 and data.shape[1] > 1:
97
+ mono = data.mean(axis=1)
98
+ else:
99
+ mono = data.reshape(-1)
100
+ # Resample to 16k expected by Whisper when passing arrays
101
+ mono_16k: np.ndarray = resample_linear(mono, int(sr), 16000)
102
+
79
103
  t0 = time.perf_counter()
80
104
  res: dict[str, Any] = model.transcribe(
81
- str(audio_path),
105
+ mono_16k,
82
106
  task=task,
83
107
  language=self.language,
84
108
  fp16=False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: s2t
3
- Version: 0.1.0.post1.dev2
3
+ Version: 0.1.2
4
4
  Summary: Speech to Text (s2t): Record audio, run Whisper, export formats, and copy transcript to clipboard.
5
5
  Author: Maintainers
6
6
  License-Expression: LicenseRef-Proprietary
@@ -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=Y7kTYnB-LtsVj2KvF60VcI37MNAVfmMcGSJMMxFyZgA,6220
10
+ s2t-0.1.2.dist-info/METADATA,sha256=YPufi9Xb9aqCARVeRkzrDQ_b2UNi7Pkq1dJAJ7vkr68,4557
11
+ s2t-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ s2t-0.1.2.dist-info/entry_points.txt,sha256=JISIUlZAJ3DX1dB6zT3X_E3vcXI-eWEQKwHiT35fPKs,37
13
+ s2t-0.1.2.dist-info/top_level.txt,sha256=o8N0JcuHdIrfX3iGHvntHiDC2XgN7__joyNu08ZOh0s,4
14
+ s2t-0.1.2.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,,