Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc4f43e887 |
@ -57,30 +57,21 @@ async function joinRoom() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
room.registerTextStreamHandler("lk.transcription", async (reader, participantInfo) => {
|
room.registerTextStreamHandler("lk.transcription", async (reader, participantInfo) => {
|
||||||
const message = await reader.readAll();
|
const message = await reader.readAll();
|
||||||
const isFinal = reader.info.attributes["lk.transcription_final"] === "true";
|
const isFinal = reader.info.attributes["lk.transcription_final"] === "true";
|
||||||
const trackId = reader.info.attributes["lk.transcribed_track_id"];
|
const trackId = reader.info.attributes["lk.transcribed_track_id"];
|
||||||
|
|
||||||
if (isFinal) {
|
if (isFinal) {
|
||||||
// Due to a bug in LiveKit Server the participantInfo object may be empty.
|
const speaker = participantInfo.identity == room.localParticipant.identity
|
||||||
// You can still get the participant owning the audio track like below:
|
? "You" : participantInfo.identity;
|
||||||
let participant;
|
const timestamp = new Date().toLocaleTimeString();
|
||||||
if (room.localParticipant.audioTrackPublications.has(trackId)) {
|
const captionsTextarea = document.getElementById("captions");
|
||||||
participant = room.localParticipant;
|
captionsTextarea.value += `[${timestamp}] ${speaker}: ${message}\n`;
|
||||||
} else {
|
captionsTextarea.scrollTop = captionsTextarea.scrollHeight;
|
||||||
participant = room.remoteParticipants.values().find(p => p.audioTrackPublications.has(trackId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const captionsTextarea = document.getElementById("captions");
|
|
||||||
const timestamp = new Date().toLocaleTimeString();
|
|
||||||
const participantIdentity =
|
|
||||||
participant == room.localParticipant ? "You" : participant.identity;
|
|
||||||
captionsTextarea.value += `[${timestamp}] ${participantIdentity}: ${message}\n`;
|
|
||||||
captionsTextarea.scrollTop = captionsTextarea.scrollHeight;
|
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the room name and participant name from the form
|
// Get the room name and participant name from the form
|
||||||
@ -100,7 +91,7 @@ room.registerTextStreamHandler("lk.transcription", async (reader, participantInf
|
|||||||
|
|
||||||
// Publish your camera and microphone
|
// Publish your camera and microphone
|
||||||
await room.localParticipant.enableCameraAndMicrophone();
|
await room.localParticipant.enableCameraAndMicrophone();
|
||||||
const localVideoTrack = room.localParticipant.videoTrackPublications
|
const localVideoTrack = this.room.localParticipant.videoTrackPublications
|
||||||
.values()
|
.values()
|
||||||
.next().value.track;
|
.next().value.track;
|
||||||
addTrack(localVideoTrack, userName, true);
|
addTrack(localVideoTrack, userName, true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user