Skip to content

Commit

Permalink
Use Jitsi API to start/stop transcription
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaller committed Jul 10, 2024
1 parent 6a8836c commit fefbfbf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/InCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const InCall = ({
videoConferenceJoinedHandler(transcriptManager.current),
transcriptionChunkReceivedHandler(transcriptManager.current),
transcribingStatusChangedHandler(transcriptManager.current),
buttonHandler,
buttonHandler(transcriptManager.current),
];

transcriptManager.current.roomName = roomName;
Expand Down
27 changes: 18 additions & 9 deletions src/jitsi/event-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,24 @@ export const getParticipants = (
});
};

export const buttonHandler = {
export const buttonHandler = (transcriptManager: TranscriptManager) => ({
name: "toolbarButtonClicked",
fn:
(_jitsi: IJitsiMeetApi, _context: JitsiContext) => async (params: any) => {
switch (params.key) {
case "leo": {
alert("LEO! TODO: en/disable transcription now");
break;
fn: (jitsi: IJitsiMeetApi, _context: JitsiContext) => async (params: any) => {
switch (params.key) {
case "leo": {
if (!transcriptManager.transcriptionEnabledAccordingToJitsiEvents) {
jitsi.executeCommand("startRecording", {
mode: "file",
transcription: true,
});
} else {
jitsi.executeCommand("stopRecording", {
mode: "file",
transcription: true,
});
}
break;
}
},
};
}
},
});
2 changes: 2 additions & 0 deletions src/transcripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class TranscriptManager {
data: { [key: string]: JitsiTranscriptionChunk } = {};
prompt: string = "";
transcriptionUsed: boolean = false;
transcriptionEnabledAccordingToJitsiEvents: boolean = false;

constructor(public onTranscriptChange: (transcript: string) => void) {}

Expand Down Expand Up @@ -158,6 +159,7 @@ export class TranscriptManager {
}

async handleTranscriptionEnabledEvent(jitsi: IJitsiMeetApi, status: boolean) {
this.transcriptionEnabledAccordingToJitsiEvents = status;
if (!this.jwt) {
throw new Error(
"Could not process transcription enabled event due to missing JWT",
Expand Down

0 comments on commit fefbfbf

Please sign in to comment.