Engines
Transcription engines. Every engine takes 16 kHz mono float32 audio and returns timed segments.
Engine
¶
Bases: Protocol
A speech-to-text engine.
Source code in src/murmurvault/engines.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
transcribe(audio, language=None, fast=False)
¶
Transcribe audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio
|
ndarray
|
16 kHz mono float32 samples. |
required |
language
|
str | None
|
Language code, or None to auto-detect. |
None
|
fast
|
bool
|
Trade accuracy for speed, for the live draft. |
False
|
Returns:
| Type | Description |
|---|---|
list[Segment]
|
Segments with times relative to the start of |
Source code in src/murmurvault/engines.py
27 28 29 30 31 32 33 34 35 36 37 | |
FasterWhisperEngine
¶
The built-in engine: faster-whisper (CTranslate2) running locally.
Source code in src/murmurvault/engines.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
__init__(name, model='small', device='auto', compute_type='default')
¶
Configure the engine; the model loads on first use and is cached per process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Engine name from the config. |
required |
model
|
str
|
Whisper model name or path, e.g. |
'small'
|
device
|
str
|
|
'auto'
|
compute_type
|
str
|
CTranslate2 compute type. |
'default'
|
Source code in src/murmurvault/engines.py
46 47 48 49 50 51 52 53 54 55 | |
transcribe(audio, language=None, fast=False)
¶
Transcribe with voice-activity filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio
|
ndarray
|
16 kHz mono float32 samples. |
required |
language
|
str | None
|
Language code, or None to auto-detect. |
None
|
fast
|
bool
|
Greedy decoding without conditioning on previous text. |
False
|
Returns:
| Type | Description |
|---|---|
list[Segment]
|
Non-empty segments. |
Source code in src/murmurvault/engines.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
OpenAICompatibleEngine
¶
Any server implementing POST /v1/audio/transcriptions: OpenAI, Groq, speaches, whisper.cpp, ...
Source code in src/murmurvault/engines.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
__init__(name, base_url, model, api_key=None, chunk_s=CHUNK_S)
¶
Configure the endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Engine name from the config. |
required |
base_url
|
str
|
API base URL, e.g. |
required |
model
|
str
|
Model name as the server knows it. |
required |
api_key
|
str | None
|
Bearer token, if the server needs one. |
None
|
chunk_s
|
float
|
Maximum upload length in seconds, at least 0.1; uploads end at the quietest moment in their second half, and the last may run up to 100 ms over. Keep it under 10 minutes for hosted APIs' ~25 MB upload limit. |
CHUNK_S
|
Source code in src/murmurvault/engines.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
transcribe(audio, language=None, fast=False)
¶
Upload the audio in chunks cut at pauses and collect the segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio
|
ndarray
|
16 kHz mono float32 samples. |
required |
language
|
str | None
|
Language code, or None to auto-detect. |
None
|
fast
|
bool
|
Ignored; the server decides how to decode. |
False
|
Returns:
| Type | Description |
|---|---|
list[Segment]
|
Segments with times relative to the start of |
Source code in src/murmurvault/engines.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
get_engine(cfg, name=None, model=None)
¶
Build an engine from the [engines] config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
dict
|
The configuration. |
required |
name
|
str | None
|
Engine name; defaults to |
None
|
model
|
str | None
|
Override the engine's configured model. |
None
|
Returns:
| Type | Description |
|---|---|
Engine
|
The engine. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no engine has that name. |
ValueError
|
If the engine's |
Source code in src/murmurvault/engines.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |