このサンプルはTwilioの電話音声をリアルタイムに取得できるTwilio Media StreamsとAmiVoice Cloud Platformの連携サンプルです。
Requires Node >= v12.1.0
以下コマンドを実行
npm install
以下コマンドを実行
node ./server.js
-
.env.example
ファイルをコピーして.env
ファイルを作成 -
AMIVOICE_API_KEY
にAmiVoice Cloud Platformのマイページから取得したAPIキーを設定 -
ngrokを起動
ngrok http 8080
-
templates/streams
ファイルの<ngrok url>
部分を上記手順で起動した、ngrokのドメインに修正 -
購入した、電話番号のA CALL COMES INに
<ngrok url>/twiml
を設定 例:'https://xxxx.ngrok.io/twiml'
本サンプルはリアルタイムで認識した文字をコンソールに出力いたします。
2022-02-03T00:59:26.634Z POST TwiML
2022-02-03T00:59:28.141Z Media WS: Connection accepted
2022-02-03T00:59:28.342Z Media WS: Connected event received: { event: 'connected', protocol: 'Call', version: '0.2.0' }
2022-02-03T00:59:28.344Z Media WS: Start event received: {
event: 'start',
sequenceNumber: '1',
start: {
accountSid: '',
streamSid: '',
callSid: '',
tracks: [ 'inbound' ],
mediaFormat: { encoding: 'audio/x-mulaw', sampleRate: 8000, channels: 1 }
},
streamSid: ''
}
Amivoice connected
s mulaw -a-general authorization=
AmiVoice started.
認識中 track:inbound message:1...
認識中 track:inbound message:一番...
認識中 track:inbound message:19...
認識中 track:inbound message:199...
認識中 track:inbound message:1級建築...
認識中 track:inbound message:一番吸収した...
確定 track:inbound message:一番吸収した。
2022-02-03T00:59:34.050Z inbound:一番吸収した。
send close command
AmiVoice closed.