Skip to content

Commit

Permalink
cool
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilro committed Jun 14, 2024
1 parent bade6cf commit 7e9df6a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions vapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ async function buildAudioPlayer(track: any, participantId: string) {
await startPlayer(player, track);
return player;
}
function subscribeToTracks(e: DailyEventObjectParticipant, call: DailyCall, isVideoRecordingEnabled?: boolean) {
function subscribeToTracks(
e: DailyEventObjectParticipant,
call: DailyCall,
isVideoRecordingEnabled?: boolean,
) {
if (e.participant.local) return;

call.updateParticipant(e.participant.session_id, {
Expand All @@ -47,7 +51,7 @@ export interface AddMessageMessage {

export interface ControlMessages {
type: 'control';
control: 'mute-assistant' | 'unmute-assistant' | 'resume-call';
control: 'mute-assistant' | 'unmute-assistant' | 'say-first-message';
videoRecordingStartDelay?: number;
}

Expand Down Expand Up @@ -146,9 +150,7 @@ export default class Vapi extends VapiEventEmitter {
if (this.call) {
this.cleanup();
}
const isVideoRecordingEnabled =
webCall?.artifactPlan?.videoRecordingEnabled ??
false;
const isVideoRecordingEnabled = webCall?.artifactPlan?.videoRecordingEnabled ?? false;

this.call = DailyIframe.createCallObject({
audioSource: true,
Expand Down Expand Up @@ -203,7 +205,8 @@ export default class Vapi extends VapiEventEmitter {

if (isVideoRecordingEnabled) {
const recordingRequestedTime = new Date().getTime();
await this.call.startRecording({

this.call.startRecording({
width: 1280,
height: 720,
backgroundColor: '#FF1F2D3D',
Expand All @@ -215,9 +218,9 @@ export default class Vapi extends VapiEventEmitter {
this.call.on('recording-started', () => {
this.send({
type: 'control',
control: 'resume-call',
control: 'say-first-message',
videoRecordingStartDelay: new Date().getTime() - recordingRequestedTime,
})
});
});
}

Expand Down Expand Up @@ -337,18 +340,17 @@ export default class Vapi extends VapiEventEmitter {

public say(message: string, endCallAfterSpoken?: boolean) {
this.send({
type:'say',
type: 'say',
message,
endCallAfterSpoken
})
endCallAfterSpoken,
});
}


public setInputDevicesAsync(options: Parameters<DailyCall['setInputDevicesAsync']>[0]) {
this.call?.setInputDevicesAsync(options)
this.call?.setInputDevicesAsync(options);
}

public setOutputDeviceAsync(options: Parameters<DailyCall['setOutputDeviceAsync']>[0]) {
this.call?.setOutputDeviceAsync(options)
this.call?.setOutputDeviceAsync(options);
}
}

0 comments on commit 7e9df6a

Please sign in to comment.