mirror of https://github.com/OpenVidu/openvidu.git
openvidu-testapp: add lk.transcription handler
parent
709779b7fd
commit
96132553ae
|
@ -28,9 +28,11 @@ import {
|
||||||
RoomOptions,
|
RoomOptions,
|
||||||
ScreenShareCaptureOptions,
|
ScreenShareCaptureOptions,
|
||||||
SubscriptionError,
|
SubscriptionError,
|
||||||
|
TextStreamReader,
|
||||||
Track,
|
Track,
|
||||||
TrackPublication,
|
TrackPublication,
|
||||||
TrackPublishOptions,
|
TrackPublishOptions,
|
||||||
|
TranscriptionSegment,
|
||||||
} from 'livekit-client';
|
} from 'livekit-client';
|
||||||
import { ParticipantPermission } from 'livekit-server-sdk';
|
import { ParticipantPermission } from 'livekit-server-sdk';
|
||||||
import {
|
import {
|
||||||
|
@ -47,10 +49,10 @@ import PCTransport from 'livekit-client/dist/src/room/PCTransport';
|
||||||
import { InfoDialogComponent } from '../dialogs/info-dialog/info-dialog.component';
|
import { InfoDialogComponent } from '../dialogs/info-dialog/info-dialog.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-openvidu-instance',
|
selector: 'app-openvidu-instance',
|
||||||
templateUrl: './openvidu-instance.component.html',
|
templateUrl: './openvidu-instance.component.html',
|
||||||
styleUrls: ['./openvidu-instance.component.css'],
|
styleUrls: ['./openvidu-instance.component.css'],
|
||||||
standalone: false
|
standalone: false,
|
||||||
})
|
})
|
||||||
export class OpenviduInstanceComponent {
|
export class OpenviduInstanceComponent {
|
||||||
@Input()
|
@Input()
|
||||||
|
@ -262,7 +264,11 @@ export class OpenviduInstanceComponent {
|
||||||
this.room?.removeAllListeners(RoomEvent.Disconnected);
|
this.room?.removeAllListeners(RoomEvent.Disconnected);
|
||||||
if (this.roomEvents.get(RoomEvent.Disconnected)) {
|
if (this.roomEvents.get(RoomEvent.Disconnected)) {
|
||||||
this.room!.on(RoomEvent.Disconnected, (reason?: DisconnectReason) => {
|
this.room!.on(RoomEvent.Disconnected, (reason?: DisconnectReason) => {
|
||||||
this.updateEventList(RoomEvent.Disconnected, {}, `Reason: ${reason ? DisconnectReason[reason] : reason}`);
|
this.updateEventList(
|
||||||
|
RoomEvent.Disconnected,
|
||||||
|
{},
|
||||||
|
`Reason: ${reason ? DisconnectReason[reason] : reason}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,7 +429,9 @@ export class OpenviduInstanceComponent {
|
||||||
this.updateEventList(
|
this.updateEventList(
|
||||||
RoomEvent.TrackSubscriptionFailed,
|
RoomEvent.TrackSubscriptionFailed,
|
||||||
{ trackSid, participant },
|
{ trackSid, participant },
|
||||||
`${participant.identity} (${trackSid}). Reason: ${reason ? SubscriptionError[reason] : reason}`
|
`${participant.identity} (${trackSid}). Reason: ${
|
||||||
|
reason ? SubscriptionError[reason] : reason
|
||||||
|
}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1008,6 +1016,33 @@ export class OpenviduInstanceComponent {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
firstTime ||
|
||||||
|
this.roomEvents.get(RoomEvent.TranscriptionReceived) !==
|
||||||
|
oldValues.get(RoomEvent.TranscriptionReceived)
|
||||||
|
) {
|
||||||
|
this.room?.unregisterTextStreamHandler('lk.transcription');
|
||||||
|
if (this.roomEvents.get(RoomEvent.TranscriptionReceived)) {
|
||||||
|
this.room?.registerTextStreamHandler(
|
||||||
|
'lk.transcription',
|
||||||
|
async (reader: TextStreamReader, participantInfo) => {
|
||||||
|
const message = await reader.readAll();
|
||||||
|
const isFinal =
|
||||||
|
reader.info.attributes!['lk.transcription_final'] === 'true';
|
||||||
|
if (isFinal) {
|
||||||
|
this.updateEventList(
|
||||||
|
RoomEvent.TranscriptionReceived,
|
||||||
|
{ participant: participantInfo.identity, message },
|
||||||
|
`${participantInfo.identity} ${
|
||||||
|
isFinal ? 'said' : 'is saying'
|
||||||
|
}: ${message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEventList(
|
updateEventList(
|
||||||
|
@ -1164,7 +1199,7 @@ export class OpenviduInstanceComponent {
|
||||||
title: 'PCTransports info',
|
title: 'PCTransports info',
|
||||||
updateFunction,
|
updateFunction,
|
||||||
},
|
},
|
||||||
minWidth: '50vh'
|
minWidth: '50vh',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue