transcribe-cpp 0.4.0__tar.gz → 0.4.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.
Files changed (36) hide show
  1. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/PKG-INFO +10 -3
  2. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/README.md +7 -0
  3. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/pyproject.toml +3 -3
  4. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/src/transcribe_cpp/__init__.py +16 -5
  5. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/src/transcribe_cpp/_generated.py +3 -3
  6. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/uv.lock +3 -3
  7. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/.gitignore +0 -0
  8. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/LICENSE +0 -0
  9. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/_generate/README.md +0 -0
  10. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/_generate/check_version_sync.py +0 -0
  11. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/_generate/generate.py +0 -0
  12. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/examples/stream_wav.py +0 -0
  13. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/examples/transcribe_wav.py +0 -0
  14. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/src/transcribe_cpp/_abi.py +0 -0
  15. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/src/transcribe_cpp/_library.py +0 -0
  16. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/src/transcribe_cpp/errors.py +0 -0
  17. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/src/transcribe_cpp/py.typed +0 -0
  18. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/conftest.py +0 -0
  19. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_abi.py +0 -0
  20. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_backends.py +0 -0
  21. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_compute_lock.py +0 -0
  22. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_device_select.py +0 -0
  23. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_diarize.py +0 -0
  24. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_errors.py +0 -0
  25. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_example.py +0 -0
  26. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_family_ext.py +0 -0
  27. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_langid.py +0 -0
  28. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_lifetime.py +0 -0
  29. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_pcm.py +0 -0
  30. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_prompting.py +0 -0
  31. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_provider_discovery.py +0 -0
  32. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_streaming.py +0 -0
  33. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_text_controls.py +0 -0
  34. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_transcribe.py +0 -0
  35. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_utf8_paths.py +0 -0
  36. {transcribe_cpp-0.4.0 → transcribe_cpp-0.4.1}/tests/test_vad.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: transcribe-cpp
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: Python bindings for transcribe.cpp
5
5
  Project-URL: Homepage, https://github.com/handy-computer/transcribe.cpp
6
6
  Project-URL: Repository, https://github.com/handy-computer/transcribe.cpp
@@ -21,9 +21,9 @@ Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
22
22
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
23
  Requires-Python: >=3.9
24
- Requires-Dist: transcribe-cpp-native==0.4.0.*
24
+ Requires-Dist: transcribe-cpp-native==0.4.1.*
25
25
  Provides-Extra: cu12
26
- Requires-Dist: transcribe-cpp-native-cu12==0.4.0.*; extra == 'cu12'
26
+ Requires-Dist: transcribe-cpp-native-cu12==0.4.1.*; extra == 'cu12'
27
27
  Provides-Extra: test
28
28
  Requires-Dist: numpy; extra == 'test'
29
29
  Requires-Dist: pytest>=7; extra == 'test'
@@ -181,9 +181,16 @@ with transcribe_cpp.Model("model.gguf", device=device) as model:
181
181
  print(model.device)
182
182
  ```
183
183
 
184
+ Weights are memory-mapped from the model file where the device can use host
185
+ memory (CPU, Metal on Apple silicon), so they live in reclaimable page cache
186
+ rather than process memory. Don't truncate or rewrite a model file in place
187
+ while it is loaded; write a new file and rename it over the old one.
188
+ `Model(no_mmap=True)` copies the weights instead.
189
+
184
190
  | Variable | Effect |
185
191
  |---|---|
186
192
  | `TRANSCRIBE_BACKEND` | overrides the `"auto"` default; explicit `backend=` still wins |
193
+ | `TRANSCRIBE_NO_MMAP` | `1` copies weights instead of memory-mapping them, like `no_mmap=True` |
187
194
  | `TRANSCRIBE_NATIVE_PROVIDER` | forces an installed native provider package, for example `cu12` |
188
195
  | `TRANSCRIBE_LIBRARY` | loads exactly this shared library |
189
196
 
@@ -150,9 +150,16 @@ with transcribe_cpp.Model("model.gguf", device=device) as model:
150
150
  print(model.device)
151
151
  ```
152
152
 
153
+ Weights are memory-mapped from the model file where the device can use host
154
+ memory (CPU, Metal on Apple silicon), so they live in reclaimable page cache
155
+ rather than process memory. Don't truncate or rewrite a model file in place
156
+ while it is loaded; write a new file and rename it over the old one.
157
+ `Model(no_mmap=True)` copies the weights instead.
158
+
153
159
  | Variable | Effect |
154
160
  |---|---|
155
161
  | `TRANSCRIBE_BACKEND` | overrides the `"auto"` default; explicit `backend=` still wins |
162
+ | `TRANSCRIBE_NO_MMAP` | `1` copies weights instead of memory-mapping them, like `no_mmap=True` |
156
163
  | `TRANSCRIBE_NATIVE_PROVIDER` | forces an installed native provider package, for example `cu12` |
157
164
  | `TRANSCRIBE_LIBRARY` | loads exactly this shared library |
158
165
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "transcribe-cpp"
7
- version = "0.4.0"
7
+ version = "0.4.1"
8
8
  description = "Python bindings for transcribe.cpp"
9
9
  readme = "README.md"
10
10
  # 3.8 is EOL (2024-10); 3.9 is the floor. The binding is ctypes-only, so there
@@ -34,13 +34,13 @@ classifiers = [
34
34
  # packaging fix still resolves); the import-time version/header-hash check in
35
35
  # _library.py is the runtime backstop. check_version_sync.py gates this pin
36
36
  # against include/transcribe.h.
37
- dependencies = ["transcribe-cpp-native==0.4.0.*"]
37
+ dependencies = ["transcribe-cpp-native==0.4.1.*"]
38
38
 
39
39
  [project.optional-dependencies]
40
40
  # Opt-in accelerator providers — ADDITIVE: they install alongside the default
41
41
  # provider and the best one wins at runtime. Same base-version pin contract
42
42
  # as the hard dependency (gated by check_version_sync.py).
43
- cu12 = ["transcribe-cpp-native-cu12==0.4.0.*"]
43
+ cu12 = ["transcribe-cpp-native-cu12==0.4.1.*"]
44
44
  # Test-only deps. Run with: uv run --extra test pytest (from bindings/python).
45
45
  # numpy is here so the numpy PCM-input tests run in every lane instead of
46
46
  # silently skipping wherever numpy happens to be absent.
@@ -55,7 +55,7 @@ from .errors import (
55
55
  raise_for_status,
56
56
  )
57
57
 
58
- __version__ = "0.4.0"
58
+ __version__ = "0.4.1"
59
59
 
60
60
  # String-enum types, exported so callers (and type checkers) can name them.
61
61
  Backend = Literal["auto", "cpu", "metal", "vulkan", "cpu_accel", "cuda", "rocm"]
@@ -1057,10 +1057,18 @@ class Model:
1057
1057
  the escape hatch for machines whose best-ranked device misbehaves (e.g.
1058
1058
  CI's paravirtualized Metal, a broken GPU driver) without touching code.
1059
1059
  An explicit ``backend=`` argument always wins over the environment.
1060
+
1061
+ The weights are memory-mapped from the model file where the device can
1062
+ use host memory (the CPU everywhere, Metal on Apple silicon): they stay
1063
+ in reclaimable page cache instead of process memory. Do not truncate or
1064
+ rewrite the file in place while the model is open (write a new file and
1065
+ rename it over the old one). ``no_mmap=True``, or the
1066
+ ``TRANSCRIBE_NO_MMAP=1`` environment variable, copies them instead.
1060
1067
  """
1061
1068
 
1062
1069
  def __init__(self, path: str | os.PathLike, *,
1063
- backend: Backend = "auto", device: BackendDevice | None = None):
1070
+ backend: Backend = "auto", device: BackendDevice | None = None,
1071
+ no_mmap: bool = False):
1064
1072
  # Live sessions, tracked weakly: close() must free them before the
1065
1073
  # model, because transcribe_model_free is only valid once every
1066
1074
  # derived session is gone (use-after-free otherwise). Created before
@@ -1078,6 +1086,7 @@ class Model:
1078
1086
  if not isinstance(device, BackendDevice) or device._handle is None:
1079
1087
  raise TypeError("device must be a BackendDevice returned by backends()")
1080
1088
  params.device = device._handle
1089
+ params.no_mmap = bool(no_mmap)
1081
1090
 
1082
1091
  handle = ctypes.c_void_p()
1083
1092
  status = _lib.transcribe_model_load_file(
@@ -2260,6 +2269,7 @@ def transcribe(
2260
2269
  *,
2261
2270
  backend: Backend = "auto",
2262
2271
  device: BackendDevice | None = None,
2272
+ no_mmap: bool = False,
2263
2273
  n_threads: int = 0,
2264
2274
  kv_type: KVType = "auto",
2265
2275
  n_ctx: int = 0,
@@ -2282,8 +2292,9 @@ def transcribe(
2282
2292
  *model* may be a path (loaded and freed within this call) or an existing
2283
2293
  Model (reused and left open). Loading a model is not free, so to transcribe
2284
2294
  many clips keep a Model and call ``model.session().run(...)`` yourself; this
2285
- helper is for the one-shot case. ``backend`` / ``device`` apply only when
2286
- *model* is a path — they are ignored when an already-loaded Model is passed.
2295
+ helper is for the one-shot case. ``backend`` / ``device`` / ``no_mmap``
2296
+ apply only when *model* is a path — they are ignored when an already-loaded
2297
+ Model is passed.
2287
2298
  ``family`` / ``spec_k_drafts`` and the prompting inputs (``vocabulary``,
2288
2299
  ``prompt``, ``prefix``) pass through to :meth:`Session.run`.
2289
2300
  """
@@ -2298,6 +2309,6 @@ def transcribe(
2298
2309
  with model.session(**session_opts) as session:
2299
2310
  return session.run(pcm, **run_opts)
2300
2311
 
2301
- with Model(model, backend=backend, device=device) as owned:
2312
+ with Model(model, backend=backend, device=device, no_mmap=no_mmap) as owned:
2302
2313
  with owned.session(**session_opts) as session:
2303
2314
  return session.run(pcm, **run_opts)
@@ -13,7 +13,7 @@ import ctypes as _c
13
13
  # Stable digest of the ABI surface below (structs, enums, macros, layout,
14
14
  # prototypes). A native provider package echoes this back so the API
15
15
  # package can reject an ABI-mismatched provider before dlopen.
16
- PUBLIC_HEADER_HASH = "98540564cd329b85"
16
+ PUBLIC_HEADER_HASH = "f99ad4169374b8f3"
17
17
 
18
18
  # === enum constants ===
19
19
  TRANSCRIBE_OK = 0
@@ -228,7 +228,7 @@ class transcribe_whisper_chunk_trace(_c.Structure):
228
228
  transcribe_ext._fields_ = [("size", _c.c_uint64), ("kind", _c.c_uint32)]
229
229
  transcribe_backend_init_params._fields_ = [("struct_size", _c.c_uint64), ("artifact_dir", _c.c_char_p), ("allowed_backends", _c.c_uint32)]
230
230
  transcribe_device_info._fields_ = [("struct_size", _c.c_uint64), ("name", _c.c_char_p), ("description", _c.c_char_p), ("kind", _c.c_char_p), ("device_id", _c.c_char_p), ("memory_total", _c.c_uint64), ("memory_free", _c.c_uint64), ("device_type", _c.c_int)]
231
- transcribe_model_load_params._fields_ = [("struct_size", _c.c_uint64), ("backend", _c.c_int), ("device", _c.c_void_p)]
231
+ transcribe_model_load_params._fields_ = [("struct_size", _c.c_uint64), ("backend", _c.c_int), ("device", _c.c_void_p), ("no_mmap", _c.c_bool)]
232
232
  transcribe_session_params._fields_ = [("struct_size", _c.c_uint64), ("n_threads", _c.c_int), ("kv_type", _c.c_int), ("n_ctx", _c.c_int32)]
233
233
  transcribe_run_params._fields_ = [("struct_size", _c.c_uint64), ("task", _c.c_int), ("timestamps", _c.c_int), ("pnc", _c.c_int), ("itn", _c.c_int), ("diarize", _c.c_int), ("language", _c.c_char_p), ("target_language", _c.c_char_p), ("keep_special_tags", _c.c_bool), ("family", _c.POINTER(transcribe_ext)), ("spec_k_drafts", _c.c_int32), ("vocabulary", _c.POINTER(_c.c_char_p)), ("n_vocabulary", _c.c_int32), ("prompt", _c.c_char_p), ("prefix", _c.c_char_p)]
234
234
  transcribe_capabilities._fields_ = [("struct_size", _c.c_uint64), ("native_sample_rate", _c.c_int32), ("n_languages", _c.c_int), ("languages", _c.POINTER(_c.c_char_p)), ("max_timestamp_kind", _c.c_int), ("supports_language_detect", _c.c_bool), ("supports_translate", _c.c_bool), ("supports_streaming", _c.c_bool), ("supports_spec_decode", _c.c_bool), ("max_audio_ms", _c.c_int64), ("n_translate_target_languages", _c.c_int), ("translate_target_languages", _c.POINTER(_c.c_char_p))]
@@ -301,7 +301,7 @@ STRUCT_LAYOUT = {
301
301
  'transcribe_ext': {'size': 16, 'align': 8, 'offsets': {'size': 0, 'kind': 8}},
302
302
  'transcribe_backend_init_params': {'size': 24, 'align': 8, 'offsets': {'struct_size': 0, 'artifact_dir': 8, 'allowed_backends': 16}},
303
303
  'transcribe_device_info': {'size': 64, 'align': 8, 'offsets': {'struct_size': 0, 'name': 8, 'description': 16, 'kind': 24, 'device_id': 32, 'memory_total': 40, 'memory_free': 48, 'device_type': 56}},
304
- 'transcribe_model_load_params': {'size': 24, 'align': 8, 'offsets': {'struct_size': 0, 'backend': 8, 'device': 16}},
304
+ 'transcribe_model_load_params': {'size': 32, 'align': 8, 'offsets': {'struct_size': 0, 'backend': 8, 'device': 16, 'no_mmap': 24}},
305
305
  'transcribe_session_params': {'size': 24, 'align': 8, 'offsets': {'struct_size': 0, 'n_threads': 8, 'kv_type': 12, 'n_ctx': 16}},
306
306
  'transcribe_run_params': {'size': 104, 'align': 8, 'offsets': {'struct_size': 0, 'task': 8, 'timestamps': 12, 'pnc': 16, 'itn': 20, 'diarize': 24, 'language': 32, 'target_language': 40, 'keep_special_tags': 48, 'family': 56, 'spec_k_drafts': 64, 'vocabulary': 72, 'n_vocabulary': 80, 'prompt': 88, 'prefix': 96}},
307
307
  'transcribe_capabilities': {'size': 56, 'align': 8, 'offsets': {'struct_size': 0, 'native_sample_rate': 8, 'n_languages': 12, 'languages': 16, 'max_timestamp_kind': 24, 'supports_language_detect': 28, 'supports_translate': 29, 'supports_streaming': 30, 'supports_spec_decode': 31, 'max_audio_ms': 32, 'n_translate_target_languages': 40, 'translate_target_languages': 48}},
@@ -387,7 +387,7 @@ wheels = [
387
387
 
388
388
  [[package]]
389
389
  name = "transcribe-cpp"
390
- version = "0.4.0"
390
+ version = "0.4.1"
391
391
  source = { editable = "." }
392
392
 
393
393
  [package.optional-dependencies]
@@ -403,8 +403,8 @@ test = [
403
403
  requires-dist = [
404
404
  { name = "numpy", marker = "extra == 'test'" },
405
405
  { name = "pytest", marker = "extra == 'test'", specifier = ">=7" },
406
- { name = "transcribe-cpp-native", specifier = "==0.4.0.*" },
407
- { name = "transcribe-cpp-native-cu12", marker = "extra == 'cu12'", specifier = "==0.4.0.*" },
406
+ { name = "transcribe-cpp-native", specifier = "==0.4.1.*" },
407
+ { name = "transcribe-cpp-native-cu12", marker = "extra == 'cu12'", specifier = "==0.4.1.*" },
408
408
  ]
409
409
  provides-extras = ["cu12", "test"]
410
410
 
File without changes