Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voice Namespace in Realtime-API #477

Merged
merged 24 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
672f3f8
Voice Inbound (#474)
edolix Mar 29, 2022
a6c87d9
Realtime-API Voice Play Methods (#475)
edolix Mar 30, 2022
05d42d5
Proper typing for call.received and review VoiceClient (#476)
edolix Mar 30, 2022
363336b
Realtime-API Voice Record Methods (#478)
edolix Mar 30, 2022
4961466
Realtime-API Voice Prompt Methods (#479)
edolix Mar 31, 2022
adb71a4
Realtime-API Voice Tap Methods (#482)
edolix Apr 1, 2022
a36f991
add derived prompt methods (#486)
edolix Apr 1, 2022
80dcbcd
Realtime-API Voice Connect/Disconnect Methods (#485) (#488)
edolix Apr 4, 2022
afdd68a
Change params casing for Voice RPC methods (#489)
framini Apr 6, 2022
5569f7a
Split state and Dial events (#493)
framini Apr 11, 2022
2d45f1f
New Workers API + removal of Synthetic events for dial/answer/hangup …
framini Apr 13, 2022
de411e4
Calling sendDigits (#500)
framini Apr 20, 2022
4d33e8d
Voice CreateDialer Interface (#507)
edolix Apr 25, 2022
fffc0f9
Voice CreatePlaylist Interface (#508)
edolix Apr 25, 2022
f6555eb
Realtime-API Voice Detect Methods (#492)
edolix Apr 25, 2022
07d35f4
Migration to `runWorker` (#511)
framini Apr 27, 2022
3b203ae
Add payload to `dial` failed (#514)
framini Apr 28, 2022
efcde69
Update createDialer/createPlaylist Interface (#517)
edolix Apr 29, 2022
492fae2
Add method to wait playback ended events (#515)
edolix Apr 29, 2022
2e245e7
E2E Voice (#519)
framini May 2, 2022
239ab45
add refs to the PR discussion
edolix May 2, 2022
43aedb0
add comment about missing `tag` in some calling events
edolix May 2, 2022
a4c33e0
add warnings for unknow Call device type
edolix May 2, 2022
9fe8d88
add comment on calling.connect.connected event transform
edolix May 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/blue-files-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Expose the `Voice.createPlaylist()` method to simplify playing media on a Voice Call.
6 changes: 6 additions & 0 deletions .changeset/calm-dingos-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@signalwire/core': patch
'@signalwire/realtime-api': patch
---

[internal] add sendDigits method to Voice.Call
7 changes: 7 additions & 0 deletions .changeset/clever-countries-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add ability to record audio in `Voice` Call.
5 changes: 5 additions & 0 deletions .changeset/few-colts-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@signalwire/core': patch
---

[internal] add `runWorker` api to replace setWorker/attachWorker combo
7 changes: 7 additions & 0 deletions .changeset/flat-students-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add ability to prompt for digits or speech using `prompt()` in `Voice` Call.
7 changes: 7 additions & 0 deletions .changeset/forty-moons-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Expose the `Voice.createDialer()` method to simplify dialing devices on a Voice Call.
6 changes: 6 additions & 0 deletions .changeset/friendly-pumpkins-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@signalwire/core': patch
'@signalwire/realtime-api': patch
---

[internal] Migrate Voice namespace to runWorkers API
6 changes: 6 additions & 0 deletions .changeset/hip-wombats-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@signalwire/core': patch
'@signalwire/realtime-api': patch
---

[internal] Add ability to return the payload when the dial fails
7 changes: 7 additions & 0 deletions .changeset/hungry-singers-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add ability to play media in `Voice` Call.
7 changes: 7 additions & 0 deletions .changeset/mean-starfishes-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add ability to connect and disconnect legs in `Voice` namespace.
5 changes: 5 additions & 0 deletions .changeset/modern-terms-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@signalwire/realtime-api': patch
---

[internal] remove usage of synthetic events for dial/answer/hangup
7 changes: 7 additions & 0 deletions .changeset/popular-steaks-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add ability to tap audio in `Voice` Call.
5 changes: 5 additions & 0 deletions .changeset/real-bikes-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@signalwire/core': patch
---

[internal] add option to skip caching the base instance when using the event emitter transform pipeline.
7 changes: 7 additions & 0 deletions .changeset/rich-bikes-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add ability to start detectors for machine/digit/fax in `Voice` Call.
7 changes: 7 additions & 0 deletions .changeset/seven-steaks-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add `waitForEnded()` method to the CallPlayback component to easily wait for playbacks to end.
7 changes: 7 additions & 0 deletions .changeset/sweet-camels-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': minor
'@signalwire/core': minor
'@signalwire/realtime-api': minor
---

Add ability to receive inbound Calls in the `Voice` namespace.
7 changes: 7 additions & 0 deletions .changeset/thick-starfishes-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@sw-internal/playground-realtime-api': patch
'@signalwire/core': patch
'@signalwire/realtime-api': patch
---

Migrate `createDialer` and `createPlaylist` to Dialer and Playlist constructors
13 changes: 13 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ steps:
from_secret: RELAY_FROM_NUMBER
RELAY_TO_NUMBER:
from_secret: RELAY_TO_NUMBER
# Scoped value for Voice tests
VOICE_HOST:
from_secret: VOICE_HOST
VOICE_PROJECT:
from_secret: VOICE_PROJECT
VOICE_TOKEN:
from_secret: VOICE_TOKEN
VOICE_CONTEXT:
from_secret: VOICE_CONTEXT
VOICE_DIAL_FROM_NUMBER:
from_secret: VOICE_DIAL_FROM_NUMBER
VOICE_DIAL_TO_NUMBER:
from_secret: VOICE_DIAL_TO_NUMBER

trigger:
event: push
8 changes: 8 additions & 0 deletions internal/e2e-realtime-api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ RELAY_TOKEN=yyy
RELAY_CONTEXT=default
RELAY_FROM_NUMBER=+10000000000
RELAY_TO_NUMBER=+10000000001

# Voice Namespace
#------------------------------------
VOICE_DIAL_FROM_NUMBER=+10000000000
VOICE_DIAL_TO_NUMBER=+10000000001
VOICE_CONTEXT="office"
VOICE_PROJECT=xxx
VOICE_TOKEN=yyy
69 changes: 69 additions & 0 deletions internal/e2e-realtime-api/src/voice.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Voice } from '@signalwire/realtime-api'
import { createTestRunner } from './utils'

const handler = () => {
return new Promise<number>(async (resolve, reject) => {
const client = new Voice.Client({
host: process.env.VOICE_HOST || 'relay.swire.io',
project: process.env.VOICE_PROJECT as string,
token: process.env.VOICE_TOKEN as string,
contexts: [process.env.VOICE_CONTEXT as string],
// debug: {
// logWsTraffic: true,
// },
})

client.on('call.received', async (call) => {
console.log('Got call', call.id, call.from, call.to, call.direction)

try {
await call.answer()
console.log('Inbound call answered')

const recording = await call.recordAudio()
console.log('Recording STARTED!', recording.id)

const playlist = new Voice.Playlist({ volume: 2 }).add(
Voice.Playlist.TTS({
text: 'Message is getting recorded',
})
)
const playback = await call.play(playlist)
console.log('Playback', playback.id)

console.log('Waiting for Playback to end')
// TODO: waitForEnded should probably accept a timeout
await playback.waitForEnded()
console.log('Playback ended')

console.log('Finishing the call.')
await call.hangup()

resolve(0)
} catch (error) {
console.error('Error', error)
reject(4)
}
})

const call = await client.dialPhone({
to: process.env.VOICE_DIAL_TO_NUMBER as string,
from: process.env.VOICE_DIAL_FROM_NUMBER as string,
timeout: 30,
})

console.log('Call resolved', call.id)
})
}

async function main() {
const runner = createTestRunner({
name: 'Voice E2E',
testHandler: handler,
executionTime: 30_000,
})

await runner.run()
}

main()
6 changes: 6 additions & 0 deletions internal/playground-realtime-api/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HOST=example.domain.com
PROJECT=xxx
TOKEN=yyy
RELAY_CONTEXT=default
FROM_NUMBER=+1xxx
TO_NUMBER=+1yyy
Loading