Commit 47552dd
authored
feat: add partial callback for real-time ghost text (#230)
## Why is this change needed?
I have a use case where I need to show streaming speech to text as it
lands. Currently there's no partials for me to latch onto in the
`StreamingEouAsrManager`. This adds that support; tested and using
successfully on this fork.
https://github.com/user-attachments/assets/5c1f1d49-0f10-4a93-8eaa-4d35338a4b0f
## Summary
Add `setPartialCallback()` to `StreamingEouAsrManager` that fires after
each chunk with the current accumulated transcript.
This enables real-time "ghost text" display during speech - useful for
live transcription UIs that want to show text as it's being spoken
before the utterance is finalized.
## Changes
- Add `PartialCallback` type alias (matching existing `EouCallback`
pattern)
- Add `partialCallback` private property
- Add `setPartialCallback(_:)` public method
- Invoke callback after each chunk's token accumulation in
`processChunkAndDecode()`
## Usage
```swift
await manager.setPartialCallback { transcript in
// Update UI with partial transcript (ghost text)
print("Partial: \(transcript)")
}
```
The callback receives the full accumulated transcript after each 320ms
chunk is processed, allowing UIs to display evolving text before EOU is
detected.
---------1 parent 2aafbb6 commit 47552dd
File tree
1 file changed
+18
-0
lines changed- Sources/FluidAudio/ASR/Streaming
1 file changed
+18
-0
lines changedLines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
| |||
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| 192 | + | |
| 193 | + | |
188 | 194 | | |
189 | 195 | | |
190 | 196 | | |
| |||
229 | 235 | | |
230 | 236 | | |
231 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
232 | 244 | | |
233 | 245 | | |
234 | 246 | | |
| |||
421 | 433 | | |
422 | 434 | | |
423 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
424 | 442 | | |
425 | 443 | | |
426 | 444 | | |
| |||
0 commit comments