Skip to content

Commit 50062f4

Browse files
authored
transcription dedupe hotfix (#1151)
1 parent 3c1d973 commit 50062f4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/core/src/components/textStream.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export function setupTextStream(room: Room, topic: string): Observable<TextStrea
5757
const textStreamsSubject = new Subject<TextStreamData[]>();
5858
const textStreams: TextStreamData[] = [];
5959

60+
const segmentAttribute = 'lk.segment_id';
61+
6062
room.registerTextStreamHandler(topic, async (reader, participantInfo) => {
6163
// Create an observable from the reader
6264
const streamObservable = from(reader).pipe(
@@ -65,14 +67,17 @@ export function setupTextStream(room: Room, topic: string): Observable<TextStrea
6567
}, ''),
6668
);
6769

70+
const isTranscription = !!reader.info.attributes?.[segmentAttribute];
71+
6872
// Subscribe to the stream and update our array when new chunks arrive
6973
streamObservable.subscribe((accumulatedText) => {
7074
// Find and update the stream in our array
7175
const index = textStreams.findIndex(
7276
(stream) =>
7377
stream.streamInfo.id === reader.info.id ||
74-
stream.streamInfo.attributes?.['lk.segment_id'] ===
75-
reader.info.attributes?.['lk.segment_id'],
78+
(isTranscription &&
79+
stream.streamInfo.attributes?.[segmentAttribute] ===
80+
reader.info.attributes?.[segmentAttribute]),
7681
);
7782
if (index !== -1) {
7883
textStreams[index] = {

0 commit comments

Comments
 (0)