Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions core/http/endpoints/openai/transcription.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,36 @@ func streamTranscription(c echo.Context, req backend.TranscriptionRequest, ml *m
"delta": finalResult.Text,
})
}
_ = writeEvent(map[string]any{
// done carries the assembled text plus, when the backend produced them,
// per-segment timings, audio duration, and detected language. The OpenAI
// streaming spec only specifies `text`; the extra fields are an additive
// extension so streaming clients (e.g. notetaker) can build the same
// TranscriptionResultSeconds shape they get from the JSON response path
// without us forcing them off SSE just to recover segments. Spec-compliant
// clients ignore unknown fields.
doneEvent := map[string]any{
"type": "transcript.text.done",
"text": finalResult.Text,
})
}
if finalResult.Language != "" {
doneEvent["language"] = finalResult.Language
}
if finalResult.Duration > 0 {
doneEvent["duration"] = finalResult.Duration
}
if len(finalResult.Segments) > 0 {
segs := make([]map[string]any, 0, len(finalResult.Segments))
for _, seg := range finalResult.Segments {
segs = append(segs, map[string]any{
"id": seg.Id,
"start": seg.Start.Seconds(),
"end": seg.End.Seconds(),
"text": seg.Text,
})
}
doneEvent["segments"] = segs
}
_ = writeEvent(doneEvent)
_, _ = fmt.Fprintf(c.Response().Writer, "data: [DONE]\n\n")
c.Response().Flush()
return nil
Expand Down
Loading