Skip to content

Commit

Permalink
fix transcription using wrong attribute (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbsp authored Sep 18, 2024
1 parent 27c8d98 commit 8ef9073
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions plugins/openai/src/voice_assistant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,16 @@ export class VoiceAssistant {

private handleInputTranscribed(event: proto.ServerEvent): void {
if (event.event !== proto.ServerEventType.INPUT_TRANSCRIBED) return;
const itemId = event.item_id;
const messageId = event.message_id;
const transcription = event.transcript;
if (!itemId || transcription === undefined) {
this.logger.error('Item ID or transcription not set');
if (!messageId || transcription === undefined) {
this.logger.error('Message ID or transcription not set');
return;
}
const participantIdentity = this.linkedParticipant?.identity;
const trackSid = this.subscribedTrack?.sid;
if (participantIdentity && trackSid) {
this.publishTranscription(participantIdentity, trackSid, transcription, true, itemId);
this.publishTranscription(participantIdentity, trackSid, transcription, true, messageId);
} else {
this.logger.error('Participant or track not set');
}
Expand Down Expand Up @@ -389,11 +389,11 @@ export class VoiceAssistant {

private handleVadSpeechStarted(event: proto.ServerEvent): void {
if (event.event !== proto.ServerEventType.VAD_SPEECH_STARTED) return;
const itemId = event.item_id;
const messageId = event.message_id;
const participantIdentity = this.linkedParticipant?.identity;
const trackSid = this.subscribedTrack?.sid;
if (participantIdentity && trackSid && itemId) {
this.publishTranscription(participantIdentity, trackSid, '', false, itemId);
if (participantIdentity && trackSid && messageId) {
this.publishTranscription(participantIdentity, trackSid, '', false, messageId);
} else {
this.logger.error('Participant or track or itemId not set');
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/openai/src/voice_assistant/proto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ export type ServerEvent =
| ServerEventType.VAD_SPEECH_STOPPED
| ServerEventType.GENERATION_CANCELED;
sample_index: number;
item_id: string;
message_id: string;
}
| {
event: ServerEventType.INPUT_TRANSCRIBED;
item_id: string;
message_id: string;
transcript: string;
};

Expand Down

0 comments on commit 8ef9073

Please sign in to comment.