From 05040cc9c2a524cb1b8534213bc9fcbc8cee7d06 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Wed, 7 Jun 2023 18:03:41 +0200 Subject: [PATCH 1/3] Fix speech with Collect and Prompt APIs --- packages/core/src/types/voiceCall.ts | 2 ++ packages/realtime-api/src/voice/CallCollect.ts | 8 ++++++++ packages/realtime-api/src/voice/CallPrompt.ts | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/packages/core/src/types/voiceCall.ts b/packages/core/src/types/voiceCall.ts index ac5e78963..1cfc3524c 100644 --- a/packages/core/src/types/voiceCall.ts +++ b/packages/core/src/types/voiceCall.ts @@ -550,6 +550,7 @@ export interface VoiceCallPromptContract { /** Alias for type in case of errors */ readonly reason?: string readonly digits?: string + readonly speech?: string readonly terminator?: string readonly text?: string readonly confidence?: number @@ -589,6 +590,7 @@ export interface VoiceCallCollectContract { /** Alias for type in case of errors */ readonly reason?: string readonly digits?: string + readonly speech?: string readonly terminator?: string readonly text?: string readonly confidence?: number diff --git a/packages/realtime-api/src/voice/CallCollect.ts b/packages/realtime-api/src/voice/CallCollect.ts index cb2af6e23..e6d489363 100644 --- a/packages/realtime-api/src/voice/CallCollect.ts +++ b/packages/realtime-api/src/voice/CallCollect.ts @@ -88,6 +88,13 @@ export class CallCollectAPI return undefined } + get speech() { + if (this.result?.type === 'speech') { + return this.result.params.text + } + return undefined + } + get terminator() { if (this.result?.type === 'digit') { return this.result.params.terminator @@ -111,6 +118,7 @@ export class CallCollectAPI /** @internal */ protected setPayload(payload: CallingCallCollectEventParams) { + console.log('payload', payload) this._payload = payload } diff --git a/packages/realtime-api/src/voice/CallPrompt.ts b/packages/realtime-api/src/voice/CallPrompt.ts index a4d241a2b..d20510071 100644 --- a/packages/realtime-api/src/voice/CallPrompt.ts +++ b/packages/realtime-api/src/voice/CallPrompt.ts @@ -88,6 +88,13 @@ export class CallPromptAPI return undefined } + get speech() { + if (this.result?.type === 'speech') { + return this.result.params.text + } + return undefined + } + get terminator() { if (this.result?.type === 'digit') { return this.result.params.terminator From e0025d74ffe9cb27474ecd59888ebac70657c5d5 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Wed, 7 Jun 2023 18:53:31 +0200 Subject: [PATCH 2/3] include changeset --- .changeset/curly-impalas-fix.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/curly-impalas-fix.md diff --git a/.changeset/curly-impalas-fix.md b/.changeset/curly-impalas-fix.md new file mode 100644 index 000000000..3c3b6e86c --- /dev/null +++ b/.changeset/curly-impalas-fix.md @@ -0,0 +1,6 @@ +--- +'@signalwire/realtime-api': patch +'@signalwire/core': patch +--- + +Fix Collect and Prompt APIs' speech From 38a92e0c9d94be401798894baf80b2a0748901e5 Mon Sep 17 00:00:00 2001 From: Ammar Ansari Date: Mon, 12 Jun 2023 16:29:20 +0200 Subject: [PATCH 3/3] removed unnecessary log --- packages/realtime-api/src/voice/CallCollect.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/realtime-api/src/voice/CallCollect.ts b/packages/realtime-api/src/voice/CallCollect.ts index e6d489363..75630306a 100644 --- a/packages/realtime-api/src/voice/CallCollect.ts +++ b/packages/realtime-api/src/voice/CallCollect.ts @@ -118,7 +118,6 @@ export class CallCollectAPI /** @internal */ protected setPayload(payload: CallingCallCollectEventParams) { - console.log('payload', payload) this._payload = payload }