録音をダウンロードする

このコード・スニペットでは、録画をダウンロードする方法を説明します。

サンプルコードの以下の変数を置き換える:

キー説明
VOICE_RECORDING_URL

The URL of the recording to download. You typically get this from the JSON response received on the /webhooks/recordings endpoint when the record action is used.

Prerequisites

Execute the following command at your terminal prompt to create the JWT for authentication:

export JWT=$(nexmo jwt:generate $PATH_TO_PRIVATE_KEY application_id=$NEXMO_APPLICATION_ID)

Write the code

Add the following to download-a-recording.sh:

curl $VOICE_RECORDING_URL \
  -H "Authorization: Bearer $JWT" \
  --output recording.mp3

View full source

Run your code

Save this file to your machine and run it:

bash download-a-recording.sh

試してみる

録画ファイルをダウンロードするには、録画URLが必要です。通常、これは /webhooks/recordings エンドポイント record アクションは 通話録音別の呼び出しに接続する、といった具合だ。典型的なJSONレスポンスは以下のようなものである:

{'conversation_uuid': 'CON-ddddaaaa-bbbb-cccc-dddd-0123456789de',
 'end_time': '2018-08-10T11:19:31Z',
 'recording_url': 'https://api.nexmo.com/v1/files/aaaaaaaa-bbbb-cccc-dddd-0123456789ab',
 'recording_uuid': 'ccccaaaa-dddd-cccc-dddd-0123456789ab',
 'size': 162558,
 'start_time': '2018-08-10T11:18:51Z',
 'timestamp': '2018-08-10T11:19:31.744Z'}
1.2.3.4 - - [10/Aug/2018 11:19:31] "POST /webhooks/recordings HTTP/1.1" 200 -

スクリプトを実行すると、録画URLにある録画がダウンロードされます。 にある録音がダウンロードされます。その後、録音を聴くことができます。

さらに読む

  • トランスクリプション - このガイドでは、Amazon Transcribe APIを使って、Vonage Voice APIで録音した電話での会話を書き起こす方法を紹介します。