Skip to content

Update docs with info on event interleaving#4

Open
kidq330 wants to merge 6 commits into
masterfrom
context_update_docs
Open

Update docs with info on event interleaving#4
kidq330 wants to merge 6 commits into
masterfrom
context_update_docs

Conversation

@kidq330

@kidq330 kidq330 commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@kidq330 kidq330 self-assigned this Apr 22, 2026
@kidq330 kidq330 added this to Smackore Apr 22, 2026
@kidq330 kidq330 moved this to In Progress in Smackore Apr 22, 2026
@kidq330

kidq330 commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator Author

Waiting for elixir-nx/bumblebee#454, adding a try block when the GenServer crashes would be a possible workaround

@kidq330 kidq330 marked this pull request as ready for review April 28, 2026 09:52
@varsill varsill self-requested a review April 28, 2026 14:02

assert_end_of_stream(pipeline_pid, :sink, :input, 20_000)

[

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not using this list anywhere, are you? :D

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I only used it to group the assertions together visually

@varsill varsill May 6, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I suppose we should assert on receiving these events and I don't see it hapenning 🤔

Comment thread lib/model_server.ex Outdated
@impl true
def init(opts) do
GenServer.cast(self(), :serving_start)
Process.flag(:trap_exit, true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this one?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx.Serving.run starts the serving in a separate process internally using spawn_link, and sends an EXIT signal to the ModelServer when it crashes. Without the trap, the ModelServer process gets killed before executing the code from the catch block.

I don't know if there's any machinations to avoid the trap, and I've had an LLM search through Bumblebee and Nx but it looks like the linking behaviour is not configurable

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about spawning it under a dedicated Agent which would by monitored by the ModelServer?

Comment thread lib/transcriber_filter.ex

The transcripts are sent via the `:output` pad along with the audio buffers, as `Membrane.Whisper.TranscriptEvent` events.
A sequence of audio buffers is followed by an event containing the transcript for said sequence, e.g.:
`<audio frames 0s - 10s> <event with transciption of 0s-10s> <audio frames 10s-20s> <event with transcription of 10s-20s> <audio frames 20s-30s> ...`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me what happens when e.g. there is a chunk of audio (0s-10s) but the voice starts at 5s - will the TranscriptionEvent be sent with 0s-10s timestamp or 5s-10s?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a mechanism for timestamping the events by default, hence the interleaving. The only way for TranscriptEvent.start_timestamp_seconds etc. to be non-nil is to enable timestamp generation in the Whisper serving via timestamps: :segments.

Unfortunately, enabling timestamps in Whisper seems to make the serving output transcripts correspond to audio of arbitrary length (the model doesn't respect the chunk duration anymore), violating the interleaving invariant. I'm working on something that might fix this by queueing buffers inside the filter and push them downstream based on the timestamps returned by Whisper when enabled, but that's outside the scope of this PR.

@kidq330 kidq330 requested a review from varsill April 30, 2026 07:35
@kidq330 kidq330 moved this from In Progress to In Review in Smackore May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants