@@ -116,6 +116,9 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
116116 RegionUrlProvider ? _regionUrlProvider;
117117 String ? _regionUrl;
118118
119+ // Agents
120+ final Map <String , DateTime > _transcriptionReceivedTimes = {};
121+
119122 Room ({
120123 @Deprecated ('deprecated, please use connectOptions in room.connect()' )
121124 ConnectOptions connectOptions = const ConnectOptions (),
@@ -790,24 +793,31 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
790793 void _onTranscriptionEvent (EngineTranscriptionReceivedEvent event) {
791794 final participant = getParticipantByIdentity (
792795 event.transcription.transcribedParticipantIdentity);
793- if (participant == null ) {
796+ if (participant == null || event.transcription.segments.isEmpty ) {
794797 return ;
795798 }
796799
797800 final publication =
798801 participant.getTrackPublicationBySid (event.transcription.trackId);
799802
800- var segments = event.transcription.segments.map ((e ) {
803+ var segments = event.transcription.segments.map ((segment ) {
801804 return TranscriptionSegment (
802- text: e.text,
803- id: e.id,
804- startTime: DateTime .fromMillisecondsSinceEpoch (e.startTime.toInt ()),
805- endTime: DateTime .fromMillisecondsSinceEpoch (e.endTime.toInt ()),
806- isFinal: e.final_5,
807- language: e.language,
805+ text: segment.text,
806+ id: segment.id,
807+ firstReceivedTime:
808+ _transcriptionReceivedTimes[segment.id] ?? DateTime .now (),
809+ lastReceivedTime: DateTime .now (),
810+ isFinal: segment.final_5,
811+ language: segment.language,
808812 );
809813 }).toList ();
810814
815+ for (var segment in segments) {
816+ segment.isFinal
817+ ? _transcriptionReceivedTimes.remove (segment.id)
818+ : _transcriptionReceivedTimes[segment.id] = DateTime .now ();
819+ }
820+
811821 final transcription = TranscriptionEvent (
812822 participant: participant,
813823 publication: publication,
0 commit comments