Skip to content

Commit 722bdb8

Browse files
localai-botmudler
andauthored
chore: ⬆️ Update mudler/parakeet.cpp to b8012f11e5269126eddb7f4fd02f891a2ccc29b0 (#10281)
* ⬆️ Update mudler/parakeet.cpp Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(parakeet-cpp): close streaming segments on <EOB> after ABI v5 eou/eob split parakeet.cpp ABI v5 (the pin this PR bumps to) splits the streaming JSON "eou" flag: in v4 "eou":1 fired for either <EOU> (end of utterance) or <EOB> (backchannel); in v5 "eou" means <EOU> only, with a new separate "eob" field for the backchannel token. The streamSegmenter closed a segment on "eou" alone, so after the bump a backchannel token would silently stop ending a segment and merge into the next utterance. Read the new "eob" field and flush on either signal to preserve the v4 segmentation boundaries. The flat stream_feed eou_out path is unaffected: its mask is still non-zero for either event. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Co-authored-by: mudler <2420543+mudler@users.noreply.github.com> Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
1 parent 50dea8c commit 722bdb8

3 files changed

Lines changed: 33 additions & 12 deletions

File tree

backend/go/parakeet-cpp/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# parakeet-cpp backend Makefile.
22
#
3-
# Upstream pin lives below as PARAKEET_VERSION?=9db92be63179a27201d3b88d5d40c545b2ac48ae
3+
# Upstream pin lives below as PARAKEET_VERSION?=b8012f11e5269126eddb7f4fd02f891a2ccc29b0
44
# (.github/bump_deps.sh) can find and update it - matches the
55
# whisper.cpp / ds4 / vibevoice-cpp convention.
66
#
@@ -15,7 +15,7 @@
1515
# That's what the L0 smoke test uses. The default target below does the
1616
# proper clone-at-pin + cmake build so CI doesn't need a side-checkout.
1717

18-
PARAKEET_VERSION?=9db92be63179a27201d3b88d5d40c545b2ac48ae
18+
PARAKEET_VERSION?=b8012f11e5269126eddb7f4fd02f891a2ccc29b0
1919
PARAKEET_REPO?=https://github.com/mudler/parakeet.cpp
2020

2121
GOCMD?=go

backend/go/parakeet-cpp/goparakeetcpp.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,21 @@ type transcriptJSON struct {
9898
}
9999

100100
// streamFeedJSON mirrors the document returned by
101-
// parakeet_capi_stream_feed_json / parakeet_capi_stream_finalize_json (ABI v4):
101+
// parakeet_capi_stream_feed_json / parakeet_capi_stream_finalize_json (ABI v5):
102102
//
103-
// {"text":"...","eou":0,"frame_sec":0.080000,
103+
// {"text":"...","eou":0,"eob":0,"frame_sec":0.080000,
104104
// "words":[{"w":"...","start":0.480,"end":0.640,"conf":0.9100}, ...]}
105105
//
106106
// "text" is the newly-finalized text since the last call; "eou" is 1 when an
107-
// <EOU>/<EOB> fired this feed; "words" are the words finalized this call with
108-
// absolute (stream-relative) start/end seconds.
107+
// <EOU> (end of utterance) fired this feed and "eob" is 1 when an <EOB>
108+
// (backchannel) fired. ABI v4 conflated the two into "eou"; v5 split them, so
109+
// we read both and treat either as an utterance boundary for segmentation.
110+
// "words" are the words finalized this call with absolute (stream-relative)
111+
// start/end seconds.
109112
type streamFeedJSON struct {
110113
Text string `json:"text"`
111114
Eou int `json:"eou"`
115+
Eob int `json:"eob"`
112116
FrameSec float64 `json:"frame_sec"`
113117
Words []transcriptWord `json:"words"`
114118
}
@@ -483,7 +487,10 @@ type streamSegmenter struct {
483487

484488
func (s *streamSegmenter) add(doc streamFeedJSON) {
485489
s.cur = append(s.cur, doc.Words...)
486-
if doc.Eou != 0 {
490+
// Close the segment on either turn signal: <EOU> (end of utterance) or
491+
// <EOB> (backchannel). ABI v4 reported both via "eou"; v5 split them, so we
492+
// OR them here to keep the v4 segmentation boundaries.
493+
if doc.Eou != 0 || doc.Eob != 0 {
487494
s.flush()
488495
}
489496
}
@@ -671,11 +678,12 @@ func (p *ParakeetCpp) AudioTranscriptionStream(ctx context.Context, opts *pb.Tra
671678
return nil
672679
}
673680

674-
// streamJSON drives the ABI v4 streaming JSON entry points: each feed/finalize
675-
// returns a {text,eou,frame_sec,words} document. The newly-finalized text is
676-
// emitted as a delta (unchanged streaming contract) while words are accumulated
677-
// into per-utterance segments (closed on EOU) so the closing FinalResult carries
678-
// timestamped segments. Runs under engineMu (already held by the caller).
681+
// streamJSON drives the streaming JSON entry points (present since ABI v4): each
682+
// feed/finalize returns a {text,eou,eob,frame_sec,words} document. The
683+
// newly-finalized text is emitted as a delta (unchanged streaming contract)
684+
// while words are accumulated into per-utterance segments (closed on <EOU> or
685+
// <EOB>) so the closing FinalResult carries timestamped segments. Runs under
686+
// engineMu (already held by the caller).
679687
func (p *ParakeetCpp) streamJSON(ctx context.Context, stream uintptr, data []float32,
680688
duration float32, results chan *pb.TranscriptStreamResponse) error {
681689
var (

backend/go/parakeet-cpp/segments_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,17 @@ var _ = Describe("streaming segment assembly", func() {
124124
Expect(acc.segments()).To(HaveLen(1))
125125
Expect(acc.segments()[0].Text).To(Equal("hi there"))
126126
})
127+
128+
// ABI v5 split <EOB> (backchannel) out of the "eou" flag into its own "eob"
129+
// field; a backchannel must still close the segment as it did in v4.
130+
It("closes a segment on EOB (backchannel) too", func() {
131+
acc := &streamSegmenter{}
132+
acc.add(streamFeedJSON{Text: "uh huh", Eou: 0, Eob: 1, Words: []transcriptWord{
133+
{W: "uh", Start: 0.0, End: 0.2}, {W: "huh", Start: 0.2, End: 0.5},
134+
}})
135+
segs := acc.segments()
136+
Expect(segs).To(HaveLen(1))
137+
Expect(segs[0].Text).To(Equal("uh huh"))
138+
Expect(segs[0].End).To(Equal(secondsToNanos(0.5)))
139+
})
127140
})

0 commit comments

Comments
 (0)