Skip to content

Commit

Permalink
Fix speech with Collect and Prompt APIs (#808)
Browse files Browse the repository at this point in the history
* Fix speech with Collect and Prompt APIs

* include changeset

* removed unnecessary log
  • Loading branch information
iAmmar7 authored Jun 14, 2023
1 parent aaa0747 commit 9fd8f9c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/curly-impalas-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@signalwire/realtime-api': patch
'@signalwire/core': patch
---

Fix Collect and Prompt APIs' speech
2 changes: 2 additions & 0 deletions packages/core/src/types/voiceCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions packages/realtime-api/src/voice/CallCollect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions packages/realtime-api/src/voice/CallPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9fd8f9c

Please sign in to comment.