@@ -436,6 +436,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
436
436
..on < EngineActiveSpeakersUpdateEvent > (
437
437
(event) => _onEngineActiveSpeakersUpdateEvent (event.speakers))
438
438
..on < EngineDataPacketReceivedEvent > (_onDataMessageEvent)
439
+ ..on < EngineTranscriptionReceivedEvent > (_onTranscriptionEvent)
439
440
..on < AudioPlaybackStarted > ((event) {
440
441
_handleAudioPlaybackStarted ();
441
442
})
@@ -683,6 +684,37 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
683
684
}
684
685
}
685
686
687
+ void _onTranscriptionEvent (EngineTranscriptionReceivedEvent event) {
688
+ final participant = getParticipantByIdentity (
689
+ event.transcription.transcribedParticipantIdentity);
690
+ if (participant == null ) {
691
+ return ;
692
+ }
693
+
694
+ final publication =
695
+ participant.getTrackPublicationBySid (event.transcription.trackId);
696
+
697
+ var segments = event.transcription.segments.map ((e) {
698
+ return TranscriptionSegment (
699
+ text: e.text,
700
+ id: e.id,
701
+ startTime: DateTime .fromMillisecondsSinceEpoch (e.startTime.toInt ()),
702
+ endTime: DateTime .fromMillisecondsSinceEpoch (e.endTime.toInt ()),
703
+ isFinal: e.final_5,
704
+ language: e.language,
705
+ );
706
+ }).toList ();
707
+
708
+ final transcription = TranscriptionEvent (
709
+ participant: participant,
710
+ publication: publication,
711
+ segments: segments,
712
+ );
713
+
714
+ participant.events.emit (transcription);
715
+ events.emit (transcription);
716
+ }
717
+
686
718
void _onDataMessageEvent (EngineDataPacketReceivedEvent dataPacketEvent) {
687
719
// participant may be null if data is sent from Server-API
688
720
final senderSid = dataPacketEvent.packet.participantSid;
0 commit comments