Live transcription
Real-time draft transcription.
Audio is always written to disk first (see audio.Recorder); this module only listens to the tracks,
cuts them into chunks at pauses, and transcribes each chunk on a single worker thread. The draft is
replaced by an accurate pass over the full recording after it stops.
LiveTranscriber
¶
Transcribes tracks in chunks while they are being recorded.
Source code in src/murmurvault/live.py
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 87 88 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 | |
__init__(engine, on_segment, *, language=None, min_chunk_s=3.0, max_chunk_s=12.0)
¶
Start the worker thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine
|
Engine
|
Engine for the draft pass. |
required |
on_segment
|
Callable[[Segment], None]
|
Called from the worker thread with each new segment. |
required |
language
|
str | None
|
Language code, or None to auto-detect. |
None
|
min_chunk_s
|
float
|
Minimum chunk length in seconds. |
3.0
|
max_chunk_s
|
float
|
Maximum chunk length in seconds. |
12.0
|
Source code in src/murmurvault/live.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
backlog()
¶
Number of chunks waiting for the engine.
Returns:
| Type | Description |
|---|---|
int
|
Queue length; growing means the engine is slower than real time. |
Source code in src/murmurvault/live.py
95 96 97 98 99 100 101 | |
listener(track, block)
¶
Receive a block from a track's writer thread and queue a chunk when one is complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
str
|
Track name. |
required |
block
|
ndarray
|
16 kHz mono samples. |
required |
Source code in src/murmurvault/live.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
stop()
¶
Flush what is still buffered and wait for the backlog.
Returns:
| Type | Description |
|---|---|
list[Segment]
|
The draft segments sorted by time, relative to each track's start. |
Source code in src/murmurvault/live.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
find_cut(buf, min_s, max_s)
¶
Decide where to end the current chunk.
Cut at the end when the buffer ends in a pause; once it exceeds max_s, cut at the quietest frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buf
|
ndarray
|
Buffered 16 kHz samples not yet transcribed. |
required |
min_s
|
float
|
Minimum chunk length in seconds. |
required |
max_s
|
float
|
Maximum chunk length in seconds. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Sample index to cut at, or None to keep buffering. |
Source code in src/murmurvault/live.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |