haybale-speech 0.0.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 (44) hide show
  1. haybale_speech-0.0.1/.gitignore +47 -0
  2. haybale_speech-0.0.1/PKG-INFO +14 -0
  3. haybale_speech-0.0.1/README.md +33 -0
  4. haybale_speech-0.0.1/haybale_speech/OVERVIEW.md +19 -0
  5. haybale_speech-0.0.1/haybale_speech/QUICKREF.md +16 -0
  6. haybale_speech-0.0.1/haybale_speech/__init__.py +100 -0
  7. haybale_speech-0.0.1/haybale_speech/adapters/__init__.py +0 -0
  8. haybale_speech-0.0.1/haybale_speech/catalog/README.md +9 -0
  9. haybale_speech-0.0.1/haybale_speech/catalog/whisper-small.json +35 -0
  10. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.catalog.whisper-small.md +5 -0
  11. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.node.CollectClipNode.md +43 -0
  12. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.node.LoadSttModelNode.md +40 -0
  13. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.node.TranscribeNode.md +35 -0
  14. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.panel.SpeechSettingsPanel.md +14 -0
  15. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.setting.SpeechSettings.md +9 -0
  16. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.type.STT_MODEL.md +17 -0
  17. haybale_speech-0.0.1/haybale_speech/docs/haybale-speech.type.TRANSCRIPT.md +15 -0
  18. haybale_speech-0.0.1/haybale_speech/editors/__init__.py +0 -0
  19. haybale_speech-0.0.1/haybale_speech/haybale.toml +48 -0
  20. haybale_speech-0.0.1/haybale_speech/macros/.gitkeep +0 -0
  21. haybale_speech-0.0.1/haybale_speech/nodes/__init__.py +0 -0
  22. haybale_speech-0.0.1/haybale_speech/nodes/collect_clip.py +101 -0
  23. haybale_speech-0.0.1/haybale_speech/nodes/load_stt_model.py +162 -0
  24. haybale_speech-0.0.1/haybale_speech/nodes/transcribe.py +100 -0
  25. haybale_speech-0.0.1/haybale_speech/panels/__init__.py +0 -0
  26. haybale_speech-0.0.1/haybale_speech/panels/speech_settings_panel.py +28 -0
  27. haybale_speech-0.0.1/haybale_speech/runtime/__init__.py +1 -0
  28. haybale_speech-0.0.1/haybale_speech/runtime/audio.py +22 -0
  29. haybale_speech-0.0.1/haybale_speech/runtime/clip.py +61 -0
  30. haybale_speech-0.0.1/haybale_speech/runtime/devices.py +62 -0
  31. haybale_speech-0.0.1/haybale_speech/runtime/whisper.py +100 -0
  32. haybale_speech-0.0.1/haybale_speech/settings/__init__.py +0 -0
  33. haybale_speech-0.0.1/haybale_speech/settings/speech_settings.py +33 -0
  34. haybale_speech-0.0.1/haybale_speech/skins/__init__.py +0 -0
  35. haybale_speech-0.0.1/haybale_speech/states/__init__.py +0 -0
  36. haybale_speech-0.0.1/haybale_speech/themes/__init__.py +0 -0
  37. haybale_speech-0.0.1/haybale_speech/types/__init__.py +0 -0
  38. haybale_speech-0.0.1/haybale_speech/types/stt_model.py +62 -0
  39. haybale_speech-0.0.1/haybale_speech/types/transcript.py +51 -0
  40. haybale_speech-0.0.1/haybale_speech/value/__init__.py +6 -0
  41. haybale_speech-0.0.1/haybale_speech/value/stt_model.py +31 -0
  42. haybale_speech-0.0.1/haybale_speech/value/transcript.py +34 -0
  43. haybale_speech-0.0.1/haybale_speech/widgets/__init__.py +0 -0
  44. haybale_speech-0.0.1/pyproject.toml +38 -0
@@ -0,0 +1,47 @@
1
+ # Patterns below are anchored with a leading slash (/build/) so they match only
2
+ # at the repo root. An unanchored pattern (build/) matches at EVERY depth —
3
+ # including inside barn/, where it would silently exclude your library's own
4
+ # files. See the note at the end of this file before adding patterns.
5
+
6
+ # Byte-compiled / optimized / DLL files
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+
11
+ # Distribution / packaging (root only)
12
+ /build/
13
+ /dist/
14
+ *.egg-info/
15
+ *.egg
16
+
17
+ # Virtual environments (root only)
18
+ /.venv/
19
+ /venv/
20
+ /env/
21
+
22
+ # Test / type-check caches
23
+ .pytest_cache/
24
+ .ruff_cache/
25
+ .mypy_cache/
26
+ .tox/
27
+ .coverage
28
+ htmlcov/
29
+
30
+ # Editor / OS
31
+ .DS_Store
32
+ .idea/
33
+ .vscode/
34
+
35
+ # Haywire per-session UI state (open graph, pan/zoom) — not project state
36
+ .haywire/workspace_state.json
37
+
38
+ # ── Before you add a pattern ────────────────────────────────────────────────
39
+ # Anything ignored inside barn/<your-library>/ will be MISSING for everyone who
40
+ # installs your library — haywire share publishes by git URL, so consumers get
41
+ # a clone of this repo, not a built package. If a pattern is only meant for the
42
+ # repo root, anchor it with a leading slash: /build/ not build/.
43
+
44
+ # Machine-local studio files (the worktree setup's port, `haywire studio start`)
45
+ .haywire/settings.json
46
+ .haywire/studio.*
47
+ .haywire/.gitignore
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.5
2
+ Name: haybale-speech
3
+ Version: 0.0.1
4
+ Summary: Speech-to-text for audio clips, with faster-whisper
5
+ License: MIT
6
+ Keywords: audio,models,speech,stt
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: ctranslate2
9
+ Requires-Dist: faster-whisper>=1.2.1
10
+ Requires-Dist: haybale-audio>=0.6.1
11
+ Requires-Dist: haybale-models>=0.6.1
12
+ Requires-Dist: haywire-core>=0.6.1
13
+ Requires-Dist: numpy
14
+ Requires-Dist: samplerate>=0.2.4
@@ -0,0 +1,33 @@
1
+ # Speech
2
+
3
+ <!-- marketstall:share-url:start -->
4
+ Always the latest (tracks the current branch):
5
+
6
+ ```sh
7
+ https://github.com/going-haywire/haybale-speech/blob/master/marketstall.toml
8
+ ```
9
+
10
+ Frozen to this version:
11
+
12
+ ```sh
13
+ https://github.com/going-haywire/haybale-speech/blob/v0.0.1/marketstall.toml
14
+ ```
15
+ <!-- marketstall:share-url:end -->
16
+
17
+ Speech-to-text for audio clips, with faster-whisper
18
+
19
+ ## Nodes
20
+ ### Speech
21
+ - **Collect Clip** — Gathers the audio blocks of a flow into one clip, sent on Stop
22
+ - **Load STT Model** — Loads a speech-to-text model onto the CPU or GPU, for Transcribe
23
+ - **Transcribe** — Turns the speech in an audio clip into text with a loaded model
24
+
25
+ ## Types
26
+ - **STT Model** — A speech-to-text model loaded on a device, ready to run. Never saved with the graph.
27
+ - **Transcript** — The text of a clip, with its language and timed segments. Never saved with the graph.
28
+
29
+ ## Settings
30
+ - **Speech** — Device, compute type and threads for models
31
+
32
+ ## Panels
33
+ - **Speech** — Device, compute type and threads for speech models.
@@ -0,0 +1,19 @@
1
+ # Speech
2
+
3
+ Speech-to-text for audio clips, with faster-whisper
4
+
5
+ ## Nodes
6
+ ### Speech
7
+ - **Collect Clip** — Gathers the audio blocks of a flow into one clip, sent on Stop
8
+ - **Load STT Model** — Loads a speech-to-text model onto the CPU or GPU, for Transcribe
9
+ - **Transcribe** — Turns the speech in an audio clip into text with a loaded model
10
+
11
+ ## Types
12
+ - **STT Model** — A speech-to-text model loaded on a device, ready to run. Never saved with the graph.
13
+ - **Transcript** — The text of a clip, with its language and timed segments. Never saved with the graph.
14
+
15
+ ## Settings
16
+ - **Speech** — Device, compute type and threads for models
17
+
18
+ ## Panels
19
+ - **Speech** — Device, compute type and threads for speech models.
@@ -0,0 +1,16 @@
1
+ # haybale-speech — component index (v0.0.1)
2
+
3
+ ## node
4
+ - `haybale-speech:node:CollectClipNode` — Collect Clip — Gathers the audio blocks of a flow into one clip, sent on Stop _tags: audio, clip, collect, gather, buffer, speech, record, segment_
5
+ - `haybale-speech:node:LoadSttModelNode` — Load STT Model — Loads a speech-to-text model onto the CPU or GPU, for Transcribe _tags: model, load, speech, stt, asr, whisper, faster-whisper, transcribe_
6
+ - `haybale-speech:node:TranscribeNode` — Transcribe — Turns the speech in an audio clip into text with a loaded model _tags: speech, stt, asr, transcribe, text, whisper, dictation, subtitle_
7
+
8
+ ## type
9
+ - `haybale-speech:type:STT_MODEL` — STT Model — A speech-to-text model loaded on a device, ready to run. Never saved with the graph.
10
+ - `haybale-speech:type:TRANSCRIPT` — Transcript — The text of a clip, with its language and timed segments. Never saved with the graph.
11
+
12
+ ## setting
13
+ - `haybale-speech:setting:SpeechSettings` — Speech — Device, compute type and threads for models
14
+
15
+ ## panel
16
+ - `haybale-speech:panel:SpeechSettingsPanel` — Speech — Device, compute type and threads for speech models.
@@ -0,0 +1,100 @@
1
+ """Haybale-Speech: speech-to-text for audio clips.
2
+
3
+ Component folders (registered in ``register_components``):
4
+ - ``settings``, ``types``, ``nodes``, ``catalog`` and the scaffold's other folders.
5
+
6
+ ``runtime`` holds the faster-whisper code the nodes call; it loads the engine only when a
7
+ model runs.
8
+ """
9
+
10
+ from pathlib import Path
11
+
12
+ from haywire.api import (
13
+ AdapterRegistry,
14
+ BaseLibrary,
15
+ CatalogRegistry,
16
+ MacroRegistry,
17
+ NodeRegistry,
18
+ SettingsRegistry,
19
+ SkinRegistry,
20
+ ThemeRegistry,
21
+ TypeRegistry,
22
+ WidgetRegistry,
23
+ library,
24
+ )
25
+ from haywire.api.workbench import EditorRegistry, StateRegistry, PanelRegistry
26
+
27
+
28
+ @library(
29
+ file_watcher=True,
30
+ )
31
+ class Library(BaseLibrary):
32
+ """Speech library — load speech models and turn audio clips into text."""
33
+
34
+ def register_components(self):
35
+ """Register all components with the global registries."""
36
+ base_path = Path(__file__).parent
37
+
38
+ self.add_folder_to_registry(
39
+ folder_path=str(base_path / "settings"),
40
+ registry_cls=SettingsRegistry,
41
+ )
42
+
43
+ self.add_folder_to_registry(
44
+ folder_path=str(base_path / "states"),
45
+ registry_cls=StateRegistry,
46
+ )
47
+
48
+ self.add_folder_to_registry(
49
+ folder_path=str(base_path / "themes"),
50
+ registry_cls=ThemeRegistry,
51
+ )
52
+
53
+ self.add_folder_to_registry(
54
+ folder_path=str(base_path / "types"),
55
+ registry_cls=TypeRegistry,
56
+ )
57
+
58
+ self.add_folder_to_registry(
59
+ folder_path=str(base_path / "adapters"),
60
+ registry_cls=AdapterRegistry,
61
+ )
62
+
63
+ self.add_folder_to_registry(
64
+ folder_path=str(base_path / "widgets"),
65
+ registry_cls=WidgetRegistry,
66
+ )
67
+
68
+ self.add_folder_to_registry(
69
+ folder_path=str(base_path / "skins"),
70
+ registry_cls=SkinRegistry,
71
+ )
72
+
73
+ self.add_folder_to_registry(
74
+ folder_path=str(base_path / "nodes"),
75
+ registry_cls=NodeRegistry,
76
+ )
77
+
78
+ self.add_folder_to_registry(
79
+ folder_path=str(base_path / "macros"),
80
+ registry_cls=MacroRegistry,
81
+ )
82
+
83
+ self.add_folder_to_registry(
84
+ folder_path=str(base_path / "catalog"),
85
+ registry_cls=CatalogRegistry,
86
+ )
87
+
88
+ self.add_folder_to_registry(
89
+ folder_path=str(base_path / "panels"),
90
+ registry_cls=PanelRegistry,
91
+ )
92
+
93
+ self.add_folder_to_registry(
94
+ folder_path=str(base_path / "editors"),
95
+ registry_cls=EditorRegistry,
96
+ )
97
+
98
+ def validate(self) -> bool:
99
+ """Validate library structure."""
100
+ return True
@@ -0,0 +1,9 @@
1
+ # Speech model catalog
2
+
3
+ Each `.json` file here is one model catalog entry, registered as
4
+ `haybale-speech:catalog:<file name without .json>`.
5
+
6
+ - `whisper-small.json`: OpenAI's Whisper `small`, MIT licensed, as Systran's CTranslate2
7
+ conversion for faster-whisper (`Systran/faster-whisper-small` on Hugging Face, pinned to
8
+ commit `536b0662742c02347bc0e980a01041f333bce120`, checked on 2026-11-23). A whole-repo
9
+ address: it resolves to the snapshot folder, which Load STT Model hands to faster-whisper.
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "Whisper small",
3
+ "author": "OpenAI (CTranslate2 conversion by Systran)",
4
+ "license": "MIT",
5
+ "commercial": true,
6
+ "recommended": true,
7
+ "tags": [
8
+ "speech-to-text",
9
+ "whisper",
10
+ "multilingual"
11
+ ],
12
+ "description": "[Whisper](https://github.com/openai/whisper) `small` (244 M parameters, 99 languages), converted to CTranslate2 for [faster-whisper](https://github.com/SYSTRAN/faster-whisper) by Systran. The weights are float16; Load STT Model runs them in int8 on the CPU and float16 on a GPU.",
13
+ "date": "2022-09-21",
14
+ "architecture": "whisper",
15
+ "purpose": ["stt"],
16
+ "size": ["244M"],
17
+ "resources": [
18
+ {
19
+ "platform": "ctranslate2",
20
+ "type": "ctranslate2",
21
+ "backend": "faster-whisper",
22
+ "precision": "fp16",
23
+ "size": 486212372,
24
+ "urls": [
25
+ "hf://Systran/faster-whisper-small@536b0662742c02347bc0e980a01041f333bce120"
26
+ ],
27
+ "include": [
28
+ "config.json",
29
+ "model.bin",
30
+ "tokenizer.json",
31
+ "vocabulary.txt"
32
+ ]
33
+ }
34
+ ]
35
+ }
@@ -0,0 +1,5 @@
1
+ # Whisper small
2
+
3
+ `haybale-speech:catalog:whisper-small` · kind: catalog
4
+
5
+ [Whisper](https://github.com/openai/whisper) `small` (244 M parameters, 99 languages), converted to CTranslate2 for [faster-whisper](https://github.com/SYSTRAN/faster-whisper) by Systran. The weights are float16; Load STT Model runs them in int8 on the CPU and float16 on a GPU.
@@ -0,0 +1,43 @@
1
+ # Collect Clip
2
+
3
+ `haybale-speech:node:CollectClipNode` · kind: node
4
+
5
+ Gathers the audio blocks of a flow into one clip, sent on Stop
6
+
7
+ ## Ports
8
+
9
+ | id | direction | type | description |
10
+ |---|---|---|---|
11
+ | `add` | inlet | `haybale-audio:type:AUDIO_EXEC` | Signal for sequencing the nodes of an audio flow |
12
+ | `stop` | inlet | `haywire-core:type:EXEC` | Signal for controlling execution flow between nodes |
13
+ | `audio` | inlet | `haybale-audio:type:AUDIO` | Block to append |
14
+ | `max_seconds` | config | `haywire-core:type:FLOAT` | Longest clip kept; later blocks are dropped |
15
+ | `status` | config | `haywire-core:type:STRING` | Text data |
16
+ | `next` | outlet | `haybale-audio:type:AUDIO_EXEC` | Signal for sequencing the nodes of an audio flow |
17
+ | `done` | outlet | `haywire-core:type:EXEC` | Runs after Stop, once Clip is set |
18
+ | `clip` | outlet | `haybale-audio:type:AUDIO` | The gathered audio |
19
+ | `seconds` | outlet | `haywire-core:type:FLOAT` | Length of the clip so far |
20
+
21
+ ## Notes
22
+
23
+ Appends each block to a clip in memory; `Stop` sends the clip and starts a new one.
24
+
25
+ The first block fixes the clip's channel count and sample rate; a later block that differs
26
+ is an error. Blocks past `Max Seconds` are dropped, and the status says so.
27
+
28
+ ```text
29
+ File Player → Audio Event → Collect Clip (Add)
30
+ Run Button → Tick Event → Collect Clip (Stop) → Done → Print (Transcribe's Text)
31
+ ```
32
+
33
+ Inputs:
34
+ add: Append the block on `audio` (wire it to an Audio Event's Block Ready)
35
+ stop: Send the clip on `clip` and continue on `done`; an empty clip sends nothing
36
+ audio: The block to append
37
+ max_seconds: Longest clip kept
38
+
39
+ Outputs:
40
+ next: Control flow after a block is appended
41
+ done: Control flow after `stop`, once `clip` holds the clip
42
+ clip: The gathered audio, one block
43
+ seconds: Length of the clip so far
@@ -0,0 +1,40 @@
1
+ # Load STT Model
2
+
3
+ `haybale-speech:node:LoadSttModelNode` · kind: node
4
+
5
+ Loads a speech-to-text model onto the CPU or GPU, for Transcribe
6
+
7
+ ## Ports
8
+
9
+ | id | direction | type | description |
10
+ |---|---|---|---|
11
+ | `model` | inlet | `haybale-models:type:MODEL_REF` | Model to load: a catalog entry |
12
+ | `status.loaded` | config | `haywire-core:type:STRING` | Name, backend, device and compute type of the loaded model |
13
+ | `loaded` | outlet | `haybale-speech:type:STT_MODEL` | The loaded model |
14
+
15
+ ## Settings
16
+
17
+ | name | bag | default | description |
18
+ |---|---|---|---|
19
+ | `device` | settings | `None` | Where models run: auto (a CUDA GPU when there is one, else the CPU), cpu or cuda |
20
+ | `compute_type` | settings | `None` | Number format the model computes in: auto is int8 on the CPU and float16 on a GPU; a format the device cannot run falls back to float32 |
21
+ | `threads` | settings | `None` | Threads a model uses on the CPU; 0 lets the engine choose |
22
+ | `loaded` | status | `'< shows after the first run >'` | Name, backend, device and compute type of the loaded model |
23
+
24
+ ## Notes
25
+
26
+ Loads a speech-to-text model onto the CPU or GPU, for Transcribe.
27
+
28
+ Pick the model on the card: a catalog entry, such as *Whisper small*. A model that is not on
29
+ this machine is an error until it is fetched in the Models editor. The model runs with
30
+ faster-whisper (CTranslate2), so it must be a CTranslate2 Whisper folder.
31
+
32
+ - `Device`: where the model runs. `auto` uses a CUDA GPU when there is one, else the CPU.
33
+ A device this machine lacks runs on the CPU, with a note.
34
+ - `Compute type`: the number format. `auto` is `int8` on the CPU and `float16` on a GPU.
35
+ A format the device cannot run falls back to `float32`, with a note.
36
+ - `CPU threads`: `0` lets the engine choose.
37
+
38
+ All three default to the library's *Speech* settings. Nodes that pick the same model with
39
+ the same settings share one loaded copy. The model is loaded when the graph runs and freed
40
+ when it stops.
@@ -0,0 +1,35 @@
1
+ # Transcribe
2
+
3
+ `haybale-speech:node:TranscribeNode` · kind: node
4
+
5
+ Turns the speech in an audio clip into text with a loaded model
6
+
7
+ ## Ports
8
+
9
+ | id | direction | type | description |
10
+ |---|---|---|---|
11
+ | `audio` | inlet | `haybale-audio:type:AUDIO` | The clip to transcribe |
12
+ | `model` | inlet | `haybale-speech:type:STT_MODEL` | A loaded speech-to-text model |
13
+ | `language` | config | `haywire-core:type:STRING` | Language code of the speech; auto detects it |
14
+ | `progress.main` | config | `haywire-core:type:PROGRESS` | |
15
+ | `transcript` | outlet | `haybale-speech:type:TRANSCRIPT` | Text, language and segments |
16
+ | `text` | outlet | `haywire-core:type:STRING` | The transcribed text |
17
+
18
+ ## Settings
19
+
20
+ | name | bag | default | description |
21
+ |---|---|---|---|
22
+ | `main` | progress | `PROGRESS(active=False, fraction=None, label='')` | |
23
+
24
+ ## Notes
25
+
26
+ Turns the speech in an audio clip into text with a loaded model.
27
+
28
+ Connect `Model` to Load STT Model and `Audio` to a clip, such as Collect Clip's. Any channel
29
+ count and sample rate will do: the clip is mixed to mono and resampled to the model's rate.
30
+
31
+ - `Language`: `auto` detects it; a code such as `en` or `de` skips detection and is
32
+ more reliable on short clips.
33
+
34
+ `Transcript` holds the text, the language and the segments with their start and end
35
+ times; `Text` is the text alone. Stopping the graph stops after the current segment.
@@ -0,0 +1,14 @@
1
+ # Speech
2
+
3
+ `haybale-speech:panel:SpeechSettingsPanel` · kind: panel
4
+
5
+ Device, compute type and threads for speech models.
6
+
7
+ ## Details
8
+
9
+ - **surface**: `barns`
10
+ - **order**: `20`
11
+
12
+ ## Notes
13
+
14
+ Device, compute type and threads for speech models.
@@ -0,0 +1,9 @@
1
+ # Speech
2
+
3
+ `haybale-speech:setting:SpeechSettings` · kind: setting
4
+
5
+ Device, compute type and threads for models
6
+
7
+ ## Notes
8
+
9
+ Where and how speech models run; Load STT Model can change each one per node.
@@ -0,0 +1,17 @@
1
+ # STT Model
2
+
3
+ `haybale-speech:type:STT_MODEL` · kind: type
4
+
5
+ A speech-to-text model loaded on a device, ready to run. Never saved with the graph.
6
+
7
+ ## Details
8
+
9
+ - **wire_type**: `haywire-core:wire:DataWire`
10
+ - **default**: `{'value': {}}`
11
+ - **color**: `#8a7ad9`
12
+
13
+ ## Notes
14
+
15
+ A speech-to-text model loaded on a device, ready to transcribe.
16
+
17
+ Load STT Model gives it; Transcribe takes it.
@@ -0,0 +1,15 @@
1
+ # Transcript
2
+
3
+ `haybale-speech:type:TRANSCRIPT` · kind: type
4
+
5
+ The text of a clip, with its language and timed segments. Never saved with the graph.
6
+
7
+ ## Details
8
+
9
+ - **wire_type**: `haywire-core:wire:DataWire`
10
+ - **default**: `{'value': {}}`
11
+ - **color**: `#b07ad9`
12
+
13
+ ## Notes
14
+
15
+ What a speech-to-text model heard: text, language and segments with start and end times.
@@ -0,0 +1,48 @@
1
+ # Library metadata. Canon for everything descriptive about this haybale; ships
2
+ # in the wheel beside __init__.py and is read from disk at runtime. Full field
3
+ # reference: docs/reference/files/haybale-toml.md
4
+
5
+ # ── identity — immutable ──────────────────────────────────────────────────
6
+ name = "haybale-speech" # pip distribution name; also prefixes every
7
+ # component's registry key, e.g. haybale-speech:node:Add
8
+
9
+ # ── written by scripts/bump_version.py / the share wizard, not by hand ──────
10
+ version = "0.0.1" # PEP 440, no "v" — canon here; pyproject.toml carries the synced copy
11
+
12
+ # ── display ───────────────────────────────────────────────────────────────
13
+ label = "Speech" # human display name
14
+ description = "Speech-to-text for audio clips, with faster-whisper" # one line
15
+ tags = ["audio", "speech", "stt", "models"] # filter tags in the library browser
16
+
17
+ # ── behaviour ─────────────────────────────────────────────────────────────
18
+ # os = ["macos", "linux"] # macos/linux/windows; empty/absent = every platform
19
+ # on_reload = "none" # none (default) / refresh (reload tab) / restart (restart studio)
20
+
21
+ # Sibling haybales this library subscribes to, as MODULE names (not
22
+ # distribution names). Required for hot-reload scope tracking.
23
+ linked_libraries = ["haybale_audio", "haybale_models"]
24
+
25
+ # ── declared paths, relative to the project root ────────────────────────────
26
+ # examples_path = "examples/"
27
+ # tests_path = "tests/"
28
+
29
+ # One supplementary human-readable page: a bare filename in this directory.
30
+ # notes = "NOTES.md"
31
+
32
+ # ── absolute URLs, used verbatim ─────────────────────────────────────────────
33
+ # homepage_url = "https://example.com"
34
+ # documentation_url = "https://example.com/docs/"
35
+ # issues_url = "https://example.com/issues"
36
+
37
+ # Repeatable; url is optional. Written by the studio's library overview edit modal.
38
+ # [[authors]]
39
+ # name = "Your Name"
40
+ # url = "https://your.site"
41
+
42
+ # Omitted unless the library is being retired — hand-edited, no edit-modal field.
43
+ # [deprecated]
44
+ # since = "0.1.0"
45
+ # reason = "Superseded by haybale-successor."
46
+ # successor = "haybale-successor"
47
+ origin = "https://github.com/going-haywire/haybale-speech"
48
+ origin_provider = "github"
File without changes
File without changes
@@ -0,0 +1,101 @@
1
+ """Collect Clip — gathers the audio blocks of a flow into one clip, until Stop."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from haybale_audio.emitter import set_status
6
+ from haybale_audio.value import AudioBlock
7
+ from haywire.api import EXEC, FLOAT, STRING, BaseNode, ExecutionContext, LabelWidget, NodeType, node
8
+
9
+ from haybale_speech.runtime.clip import ClipBuffer
10
+
11
+
12
+ @node(
13
+ label="Collect Clip",
14
+ description="Gathers the audio blocks of a flow into one clip, sent on Stop",
15
+ menu="speech",
16
+ search_tags=["audio", "clip", "collect", "gather", "buffer", "speech", "record", "segment"],
17
+ node_type=NodeType.CONTROL,
18
+ )
19
+ class CollectClipNode(BaseNode):
20
+ """Appends each block to a clip in memory; `Stop` sends the clip and starts a new one.
21
+
22
+ The first block fixes the clip's channel count and sample rate; a later block that differs
23
+ is an error. Blocks past `Max Seconds` are dropped, and the status says so.
24
+
25
+ ```text
26
+ File Player → Audio Event → Collect Clip (Add)
27
+ Run Button → Tick Event → Collect Clip (Stop) → Done → Print (Transcribe's Text)
28
+ ```
29
+
30
+ Inputs:
31
+ add: Append the block on `audio` (wire it to an Audio Event's Block Ready)
32
+ stop: Send the clip on `clip` and continue on `done`; an empty clip sends nothing
33
+ audio: The block to append
34
+ max_seconds: Longest clip kept
35
+
36
+ Outputs:
37
+ next: Control flow after a block is appended
38
+ done: Control flow after `stop`, once `clip` holds the clip
39
+ clip: The gathered audio, one block
40
+ seconds: Length of the clip so far
41
+ """
42
+
43
+ def init(self) -> None:
44
+ from haybale_audio.types.audio import AUDIO
45
+ from haybale_audio.types.audio_exec import AUDIO_EXEC
46
+
47
+ self.add(AUDIO_EXEC.as_inlet("add", label="Add"))
48
+ self.add(EXEC.as_inlet("stop", label="Stop"))
49
+ self.add(AUDIO.as_inlet("audio", label="Audio", description="Block to append"))
50
+ self.add(
51
+ FLOAT.as_config(
52
+ "max_seconds",
53
+ default=300.0,
54
+ label="Max Seconds",
55
+ description="Longest clip kept; later blocks are dropped",
56
+ )
57
+ )
58
+ self.add(STRING.as_config("status", default="Idle", label="Status", widget=LabelWidget.config()))
59
+ self.add(AUDIO_EXEC.as_outlet("next", label="Next"))
60
+ self.add(EXEC.as_outlet("done", label="Done", description="Runs after Stop, once Clip is set"))
61
+ self.add(AUDIO.as_outlet("clip", label="Clip", description="The gathered audio"))
62
+ self.add(FLOAT.as_outlet("seconds", label="Seconds", description="Length of the clip so far"))
63
+
64
+ def post_init(self) -> None:
65
+ self.hb_buffer = ClipBuffer(300.0)
66
+
67
+ def on_shutdown(self, context: ExecutionContext) -> None:
68
+ self.hb_reset()
69
+
70
+ def on_teardown(self) -> None:
71
+ self.hb_reset()
72
+
73
+ def hb_reset(self) -> None:
74
+ # post_init() may never have run (init() failed during a reset or reload).
75
+ buffer = getattr(self, "hb_buffer", None)
76
+ if buffer is not None:
77
+ buffer.take()
78
+
79
+ def worker(
80
+ self, context: ExecutionContext, audio: AudioBlock | None = None, max_seconds: float = 300.0
81
+ ) -> str | None:
82
+ buffer = self.hb_buffer
83
+ if context.control_pin == "stop":
84
+ clip = buffer.take()
85
+ if clip is None:
86
+ set_status(self, "Empty")
87
+ return None
88
+ self.out("clip", clip)
89
+ self.out("seconds", clip.duration)
90
+ set_status(self, f"Sent {clip.duration:.1f} s")
91
+ return "done"
92
+ if audio is None:
93
+ raise ValueError("add needs an audio block")
94
+ buffer.max_seconds = float(max_seconds)
95
+ if buffer.add(audio):
96
+ seconds = buffer.seconds
97
+ self.out("seconds", seconds)
98
+ set_status(self, f"Collecting {seconds:.1f} s")
99
+ else:
100
+ set_status(self, f"Full at {buffer.seconds:.1f} s — {buffer.dropped} blocks dropped")
101
+ return "next"