この記事では、音声およびビデオ通話の通話レコーディングについて説明します。 通話レコーディング API を使い始めるには、通話を用意する必要があります。 エンド ユーザー通話エクスペリエンスを構築するには、Calling client SDK と Call Automation について理解しておいてください。
サンプル コード
サンプル アプリは GitHub からダウンロードできます
前提条件
- アクティブなサブスクリプションを含む Azure アカウントが必要です。
- Communication Services リソースをデプロイします。 リソースの接続文字列をメモします。
- Azure Event Grid を使ってイベントをサブスクライブします。
- .NET SDK をダウンロードします。
開始する前に
通話レコーディング API で記録を開始するには、serverCallId
のみを使います。 シナリオに応じて、serverCallId
のフェッチに使用できるメソッドがいくつかあります。
Call Automation のシナリオ
Call Automation を使う場合、serverCallId
を取得するには 2 つのオプションがあります。
通話を確立すると、通話が確立された後、
CallConnected
イベントのプロパティとしてserverCallId
が返されます。 Call Automation SDK から CallConnected を取得する方法を参照してください。通話に応答するか、通話が作成されると、
AnswerCallResult
またはCreateCallResult
API 応答それぞれのプロパティとしてserverCallId
が返されます。
Calling SDK のシナリオ
Calling Client SDK を使う場合、通話に対して getServerCallId
メソッドを使うことで serverCallId
を取得できます。
この例を使って Calling Client SDK から serverCallId を取得する方法を学習します。
それでは簡単な手順から始めましょう。
1. Call Automation クライアントを作成する
Call Recording API は、Azure Communication Services の Call Automation ライブラリの一部です。 そのため、Call Automation クライアントを作成する必要があります。
Call Automation クライアントを作成するには、Communication Services の接続文字列を使用し、それを CallAutomationClient
オブジェクトに渡します。
CallAutomationClient callAutomationClient = new CallAutomationClient("<ACSConnectionString>");
2. "StartAsync" API を使用して StartRecordingOptions でレコーディング セッションを開始する
通話の開始時に受け取った serverCallId
を使います。
-
RecordingContent
を使用して、レコーディング コンテンツ タイプを渡します。AUDIO
を使用してください。 -
RecordingChannel
を使用して、レコーディング チャネルの種類を渡します。MIXED
またはUNMIXED
を使用します。 -
RecordingFormat
を使用して、レコーディングのフォーマットを渡します。WAV
を使用してください。
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
{
RecordingContent = RecordingContent.Audio,
RecordingChannel = RecordingChannel.Unmixed,
RecordingFormat = RecordingFormat.Wav,
RecordingStateCallbackUri = new Uri("<CallbackUri>");
};
Response<RecordingStateResult> response = await callAutomationClient.GetCallRecording()
.StartAsync(recordingOptions);
2.1. レコーディングを開始する - Bring Your Own Azure Blob Store
レコーディングが完了したら、指定した Azure Blob Storage を使用して記録を開始し、記録されたファイルを格納します。
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
{
RecordingContent = RecordingContent.Audio,
RecordingChannel = RecordingChannel.Unmixed,
RecordingFormat = RecordingFormat.Wav,
RecordingStateCallbackUri = new Uri("<CallbackUri>"),
RecordingStorage = RecordingStorage.CreateAzureBlobContainerRecordingStorage(new Uri("<YOUR_STORAGE_CONTAINER_URL>"))
};
Response<RecordingStateResult> response = await callAutomationClient.GetCallRecording()
.StartAsync(recordingOptions);
2.2. 'StartAsync' API を使用して一時停止モードを有効にしてセッションのレコーディングを開始する
Note
レコーディング ファイルを生成するには、レコーディングを再開する必要があります。
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
{
RecordingContent = RecordingContent.Audio,
RecordingChannel = RecordingChannel.Unmixed,
RecordingFormat = RecordingFormat.Wav,
PauseOnStart = true,
RecordingStateCallbackUri = new Uri("<CallbackUri>");
};
Response<RecordingStateResult> response = await callAutomationClient.GetCallRecording()
.StartAsync(recordingOptions);
2.3. 非ミックスのみ - チャネル 0 のユーザーを指定する
非ミキシング オーディオ レコーディング ファイルを生成するには、AudioChannelParticipantOrdering
機能を使用して、チャネル 0 に記録するユーザーを指定できます。 参加者の残りの部分は、話すときにチャネルに割り当てられます。
RecordingChannel.Unmixed
を使用し、AudioChannelParticipantOrdering
を使用しない場合、Call Recording によって最初に話している参加者にチャネル 0 が割り当てられます。
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
{
RecordingContent = RecordingContent.Audio,
RecordingChannel = RecordingChannel.Unmixed,
RecordingFormat = RecordingFormat.Wav,
RecordingStateCallbackUri = new Uri("<CallbackUri>"),
AudioChannelParticipantOrdering = { new CommunicationUserIdentifier("<ACS_USER_MRI>") }
};
Response<RecordingStateResult> response = await callAutomationClient.GetCallRecording().StartAsync(recordingOptions);
2.4. 非ミックスのみ - チャネル アフィニティを指定する
var channelAffinity = new ChannelAffinity(new CommunicationUserIdentifier("<ACS_USER_MRI>")) { Channel = 0};
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<ServerCallId>"))
{
RecordingContent = RecordingContent.Audio,
RecordingChannel = RecordingChannel.Unmixed,
RecordingFormat = RecordingFormat.Wav,
RecordingStateCallbackUri = new Uri("<CallbackUri>"),
ChannelAffinity = new List<ChannelAffinity>{ channelAffinity }
};
Response<RecordingStateResult> response = await callAutomationClient.GetCallRecording().StartAsync(recordingOptions);
StartAsync
API 応答には、レコーディング セッションの recordingId
が含まれています。
3.StopAsync
API を使用してレコーディング セッションを停止する
StartAsync
への応答で受信した recordingId
を使用します。
var stopRecording = await callAutomationClient.GetCallRecording().StopAsync(recordingId);
4.PauseAsync
API を使用してレコーディング セッションを一時停止する
StartAsync
への応答で受信した recordingId
を使用します。
var pauseRecording = await callAutomationClient.GetCallRecording ().PauseAsync(recordingId);
5.ResumeAsync
API を使用してセッションのレコーディングを再開する
StartAsync
への応答で受信した recordingId
を使用します。
var resumeRecording = await callAutomationClient.GetCallRecording().ResumeAsync(recordingId);
6.DownloadToAsync
API を使用してレコーディング ファイルをダウンロードする
記録されたメディアをダウンロードする準備ができたときにサービスに通知するために、Azure Event Grid Web hook または他のトリガーされたアクションを使用します。
Event Grid の通知 Microsoft.Communication.RecordingFileStatusUpdated
は、レコーディングを取得する準備ができたときに発行されます。通常は、レコーディングの処理が完了 (会議の終了時、レコーディングの停止など) から 1、2 分後になります。 レコーディングのイベント通知には contentLocation
と metadataLocation
が含まれます。これらは、記録されたメディアとレコーディング メタデータ ファイルの両方を取得するために使用できます。
イベント スキーマの例を次に示します。
{
"id": string, // Unique guid for event
"topic": string, // /subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}
"subject": string, // /recording/call/{call-id}/serverCallId/{serverCallId}
"data": {
"recordingStorageInfo": {
"recordingChunks": [
{
"documentId": string, // Document id for the recording chunk
"contentLocation": string, //Azure Communication Services URL where the content is located
"metadataLocation": string, // Azure Communication Services URL where the metadata for this chunk is located
"deleteLocation": string, // Azure Communication Services URL to use to delete all content, including recording and metadata.
"index": int, // Index providing ordering for this chunk in the entire recording
"endReason": string, // Reason for chunk ending: "SessionEnded", "ChunkMaximumSizeExceeded”, etc.
}
]
},
"recordingStartTime": string, // ISO 8601 date time for the start of the recording
"recordingDurationMs": int, // Duration of recording in milliseconds
"sessionEndReason": string // Reason for call ending: "CallEnded", "InitiatorLeft”, etc.
},
"eventType": string, // "Microsoft.Communication.RecordingFileStatusUpdated"
"dataVersion": string, // "1.0"
"metadataVersion": string, // "1"
"eventTime": string // ISO 8601 date time for when the event was created
}
DownloadToAsync
API を使用して記録されたメディアをダウンロードする。
var recordingDownloadUri = new Uri(contentLocation);
var response = await callAutomationClient.GetCallRecording().DownloadToAsync(recordingDownloadUri, fileName);
recordingChunk
の contentLocation
属性から、レコーディングの downloadLocation
をフェッチします。
DownloadToAsync
メソッドを使用して、指定されたファイル名にコンテンツをダウンロードします。
7.DeleteAsync
API を使用してレコーディング コンテンツを削除する
DeleteAsync
API を使用して、レコーディング コンテンツ (記録されたメディアやメタデータなど) を削除します。
var recordingDeleteUri = new Uri(deleteLocation);
var response = await callAutomationClient.GetCallRecording().DeleteAsync(recordingDeleteUri);
サンプル コード
サンプル アプリは GitHub からダウンロードできます
前提条件
- アクティブなサブスクリプションを含む Azure アカウントが必要です。
- Communication Services リソースをデプロイします。 リソースの接続文字列をメモします。
- Azure Event Grid を使ってイベントをサブスクライブします。
- Java SDK をダウンロードします。
開始する前に
Call Recording API では、レコーディングを開始するために serverCallId
のみが使われます。 シナリオに応じて、serverCallId
のフェッチに使用できるメソッドがいくつかあります。
Call Automation のシナリオ
Call Automation を使う場合、serverCallId
を取得するには 2 つのオプションがあります。
通話が作成されると、通話が確立した後に
CallConnected
イベントのプロパティとしてserverCallId
が返されます。 Call Automation SDK から CallConnected を取得する方法を参照してください。呼び出しに応答するか、通話が作成されると、
AnswerCallResult
またはCreateCallResult
API 応答それぞれのプロパティとしてserverCallId
が返されます。
Calling SDK のシナリオ
Calling Client SDK を使う場合、通話に対して getServerCallId
メソッドを使うことで serverCallId
を取得できます。
この例を使って Calling Client SDK から serverCallId を取得する方法を学習します。
それでは簡単な手順から始めましょう。
1. Call Automation クライアントを作成する
Call Recording API は、Azure Communication Services の Call Automation ライブラリの一部です。 そのため、Call Automation クライアントを作成する必要があります。
Call Automation クライアントを作成するには、Communication Services の接続文字列を使用し、それを CallAutomationClient
オブジェクトに渡します。
CallAutomationClient callAutomationClient = new CallAutomationClientBuilder()
.connectionString("<acsConnectionString>")
.buildClient();
2.startWithResponse
API を使用して StartRecordingOptions でレコーディング セッションを開始する
通話の開始時に受け取った serverCallId
を使います。
-
RecordingContent
を使用して、レコーディング コンテンツ タイプを渡します。AUDIO
を使用してください。 -
RecordingChannel
を使用して、レコーディング チャネルの種類を渡します。MIXED
またはUNMIXED
を使用します。 -
RecordingFormat
を使用して、レコーディングのフォーマットを渡します。WAV
を使用してください。
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<serverCallId>"))
.setRecordingChannel(RecordingChannel.UNMIXED)
.setRecordingFormat(RecordingFormat.WAV)
.setRecordingContent(RecordingContent.AUDIO)
.setRecordingStateCallbackUrl("<recordingStateCallbackUrl>");
Response<RecordingStateResult> response = callAutomationClient.getCallRecording()
.startWithResponse(recordingOptions, null);
2.1. レコーディングを開始する - Bring Your Own Azure Blob Store
レコーディングが完了したら、指定した Azure Blob Storage を使用して記録を開始し、記録されたファイルを格納します。
StartRecordingOptions recordingOptions = new StartRecordingOptions(callLocator)
.setRecordingChannel(RecordingChannel.MIXED)
.setRecordingContent(RecordingContent.AUDIO_VIDEO)
.setRecordingFormat(RecordingFormat.MP4)
.setRecordingStorage(new AzureBlobContainerRecordingStorage("<YOUR_STORAGE_CONTAINER_URL>"));
// //start recording
RecordingStateResult result = callRecording.start(recordingOptions);
2.2.
StartAsync
API を使用して一時停止モードを有効にしてセッションのレコーディングを開始する
Note
レコーディング ファイルを生成するには、レコーディングを再開する必要があります。
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<serverCallId>"))
.setRecordingChannel(RecordingChannel.UNMIXED)
.setRecordingFormat(RecordingFormat.WAV)
.setRecordingContent(RecordingContent.AUDIO)
.setRecordingStateCallbackUrl("<recordingStateCallbackUrl>")
.setPauseOnStart(true)
.setAudioChannelParticipantOrdering(List.of(new CommunicationUserIdentifier("<participantMri>")));
Response<RecordingStateResult> response = callAutomationClient.getCallRecording()
.startWithResponse(recordingOptions, null);
2.3. 非ミックスのみ - チャネル 0 のユーザーを指定する
非ミキシング オーディオ レコーディング ファイルを生成するには、AudioChannelParticipantOrdering
機能を使用して、チャネル 0 に記録するユーザーを指定できます。 参加者の残りの部分は、話すときにチャネルに割り当てられます。
RecordingChannel.Unmixed
を使用し、AudioChannelParticipantOrdering
を使用しない場合、Call Recording によって最初に話している参加者にチャネル 0 が割り当てられます。
StartRecordingOptions recordingOptions = new StartRecordingOptions(new ServerCallLocator("<serverCallId>"))
.setRecordingChannel(RecordingChannel.UNMIXED)
.setRecordingFormat(RecordingFormat.WAV)
.setRecordingContent(RecordingContent.AUDIO)
.setRecordingStateCallbackUrl("<recordingStateCallbackUrl>")
.setAudioChannelParticipantOrdering(List.of(new CommunicationUserIdentifier("<participantMri>")));
Response<RecordingStateResult> response = callAutomationClient.getCallRecording()
.startWithResponse(recordingOptions, null);
2.4. 非ミックスのみ - チャネル アフィニティを指定する
ChannelAffinity channelAffinity = new ChannelAffinity()
.setParticipant(new PhoneNumberIdentifier("RECORDING_ID"))
.setChannel(0);
List<ChannelAffinity> channelAffinities = Arrays.asList(channelAffinity);
StartRecordingOptions startRecordingOptions = new StartRecordingOptions(new ServerCallLocator(SERVER_CALL_ID))
.setRecordingChannel(RecordingChannel.UNMIXED)
.setRecordingFormat(RecordingFormat.WAV)
.setRecordingContent(RecordingContent.AUDIO)
.setRecordingStateCallbackUrl("<recordingStateCallbackUrl>")
.setChannelAffinity(channelAffinities);
Response<RecordingStateResult> response = callAutomationClient.getCallRecording()
.startRecordingWithResponse(recordingOptions, null);
startWithResponse
API 応答には、レコーディング セッションの recordingId
が含まれています。
3.stopWithResponse
API を使用してレコーディング セッションを停止する
startWithResponse
への応答で受信した recordingId
を使用します。
Response<Void> response = callAutomationClient.getCallRecording()
.stopWithResponse(response.getValue().getRecordingId(), null);
4.pauseWithResponse
API を使用してレコーディング セッションを一時停止する
startWithResponse
への応答で受信した recordingId
を使用します。
Response<Void> response = callAutomationClient.getCallRecording()
.pauseWithResponse(response.getValue().getRecordingId(), null);
5.resumeWithResponse
API を使用してセッションのレコーディングを再開する
startWithResponse
への応答で受信した recordingId
を使用します。
Response<Void> response = callAutomationClient.getCallRecording()
.resumeWithResponse(response.getValue().getRecordingId(), null);
6.downloadToWithResponse
API を使用してレコーディング ファイルをダウンロードする
記録されたメディアをダウンロードする準備ができたときにサービスに通知するために、Azure Event Grid Web hook または他のトリガーされたアクションを使用する必要があります。
Event Grid の通知 Microsoft.Communication.RecordingFileStatusUpdated
は、レコーディングを取得する準備ができたときに発行されます。通常は、レコーディング プロセスが完了 (会議が終了、レコーディングの停止など) してから 1、2 分後になります。 レコーディングのイベント通知には contentLocation
と metadataLocation
が含まれます。これらは、記録されたメディアとレコーディング メタデータ ファイルの両方を取得するために使用できます。
イベント スキーマの例を次のコードに示します。
{
"id": string, // Unique guid for event
"topic": string, // /subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}
"subject": string, // /recording/call/{call-id}/serverCallId/{serverCallId}
"data": {
"recordingStorageInfo": {
"recordingChunks": [
{
"documentId": string, // Document id for the recording chunk
"contentLocation": string, //Azure Communication Services URL where the content is located
"metadataLocation": string, // Azure Communication Services URL where the metadata for this chunk is located
"deleteLocation": string, // Azure Communication Services URL to use to delete all content, including recording and metadata.
"index": int, // Index providing ordering for this chunk in the entire recording
"endReason": string, // Reason for chunk ending: "SessionEnded", "ChunkMaximumSizeExceeded”, etc.
}
]
},
"recordingStartTime": string, // ISO 8601 date time for the start of the recording
"recordingDurationMs": int, // Duration of recording in milliseconds
"sessionEndReason": string // Reason for call ending: "CallEnded", "InitiatorLeft”, etc.
},
"eventType": string, // "Microsoft.Communication.RecordingFileStatusUpdated"
"dataVersion": string, // "1.0"
"metadataVersion": string, // "1"
"eventTime": string // ISO 8601 date time for when the event was created
}
downloadToWithResponse
クラスのメソッド CallRecording
を使用して、記録されたメディアをダウンロードします。
downloadToWithResponse
メソッドでサポートされているパラメーターを次に示します。
-
contentLocation
: コンテンツが置かれている Azure Communication Services URL。 -
destinationPath
: ファイルの場所。 -
parallelDownloadOptions
: 並列ダウンロードの動作を変更する省略可能なParallelDownloadOptions
オブジェクト。 -
overwrite
: True にすると、ファイルが存在する場合、それは上書きされます。 -
context
: 要求コンテキストを表すコンテキスト。
Boolean overwrite = true;
ParallelDownloadOptions parallelDownloadOptions = null;
Context context = null;
String filePath = String.format(".\\%s.%s", documentId, fileType);
Path destinationPath = Paths.get(filePath);
Response<Void> downloadResponse = callAutomationClient.getCallRecording().downloadToWithResponse(contentLocation, destinationPath, parallelDownloadOptions, overwrite, context);
レコーディング ファイルのコンテンツの場所とドキュメント ID は、recordingChunk
ごとに、contentLocation
および documentId
フィールドからそれぞれ取得できます。
7.deleteWithResponse
API を使用してレコーディング コンテンツを削除する
CallRecording
クラスの deleteWithResponse
メソッドを使用して、記録されたメディアを削除します。
deleteWithResponse
メソッドでサポートされているパラメーターは、次のとおりです:
-
deleteLocation
: 削除するコンテンツが配置されている Azure Communication Services の URL。 -
context
: 要求コンテキストを表すコンテキスト。
Response<Void> deleteResponse = callAutomationClient.getCallRecording().deleteWithResponse(deleteLocation, context);
レコーディングの削除場所は、Event Grid イベントの deleteLocation
フィールドからフェッチできます。
サンプル コード
サンプル アプリは GitHub からダウンロードできます
前提条件
- アクティブなサブスクリプションを含む Azure アカウントが必要です。
- Communication Services リソースをデプロイします。 リソースの接続文字列をメモします。
- Azure Event Grid を使ってイベントをサブスクライブします。
- Python 3.7 以降。
開始する前に
通話レコーディング API で記録を開始するには、serverCallId
のみを使います。 シナリオに応じて、serverCallId
のフェッチに使用できるメソッドがいくつかあります。
Call Automation のシナリオ
-
Call Automation を使う場合、
serverCallId
を取得するには 2 つのオプションがあります。- 通話が作成されると、通話が確立した後に
CallConnected
イベントのプロパティとしてserverCallId
が返されます。 Call Automation SDK から CallConnected を取得する方法を参照してください。 - 通話に応答するか、通話が作成されると、
AnswerCallResult
またはCreateCallResult
API 応答のそれぞれのプロパティとしてserverCallId
が返されます。
- 通話が作成されると、通話が確立した後に
Calling SDK のシナリオ
-
Calling Client SDK を使う場合、通話に対して
server_call_id
変数を使うことでserverCallId
を取得できます。 この例を使って Calling Client SDK から serverCallId を取得する方法を学習します。
それでは簡単な手順から始めましょう。
1. Call Automation クライアントを作成する
Call Recording API は、Azure Communication Services の Call Automation ライブラリの一部です。 したがって、Call Automation クライアントを作成する必要があります。
Call Automation クライアントを作成するには、Communication Services の接続文字列を使用し、それを CallAutomationClient
オブジェクトに渡します。
call_automation_client = CallAutomationClient.from_connection_string("<ACSConnectionString>")
2. start_recording API でレコーディング セッションを開始する
通話の開始時に受け取った serverCallId
を使います。
-
RecordingContent
を使用して、レコーディング コンテンツ タイプを渡します。AUDIO
を使用してください。 -
RecordingChannel
を使用して、レコーディング チャネルの種類を渡します。MIXED
またはUNMIXED
を使用します。 -
RecordingFormat
を使用して、レコーディングのフォーマットを渡します。WAV
を使用してください。
response = call_automation_client.start_recording(call_locator=ServerCallLocator(server_call_id),
recording_content_type = RecordingContent.Audio,
recording_channel_type = RecordingChannel.Unmixed,
recording_format_type = RecordingFormat.Wav,
recording_state_callback_url = "<CallbackUri>")
2.1. レコーディングを開始する - Bring Your Own Azure Blob Store
レコーディングが完了したら、レコーディング ファイルを保存するように定義された独自の Azure Blob Storage でレコーディングを開始します。
response = call_automation_client.start_recording(call_locator=ServerCallLocator(server_call_id),
recording_content_type = RecordingContent.Audio,
recording_channel_type = RecordingChannel.Unmixed,
recording_format_type = RecordingFormat.Wav,
recording_state_callback_url = "<CallbackUri>",
recording_storage = AzureBlobContainerRecordingStorage(container_url="<YOUR_STORAGE_CONTAINER_URL>"))
2.2. 'StartAsync' API を使用して一時停止モードを有効にしてセッションのレコーディングを開始する
Note
レコーディング ファイルを生成するには、レコーディングを再開する必要があります。
response = call_automation_client.start_recording(call_locator=ServerCallLocator(server_call_id),
recording_content_type = RecordingContent.Audio,
recording_channel_type = RecordingChannel.Unmixed,
recording_format_type = RecordingFormat.Wav,
pause_on_start = true,
recording_state_callback_url = "<CallbackUri>")
2.3. 非ミックスのみ - チャネル 0 のユーザーを指定する
非ミキシング オーディオ レコーディング ファイルを生成するには、AudioChannelParticipantOrdering
機能を使用して、チャネル 0 に記録するユーザーを指定できます。 参加者の残りの部分は、話すときにチャネルに割り当てられます。
RecordingChannel.Unmixed
を使用し、AudioChannelParticipantOrdering
を使用しない場合、Call Recording によって最初に話している参加者にチャネル 0 が割り当てられます。
response = call_automation_client.start_recording(call_locator=ServerCallLocator(server_call_id),
recording_content_type = RecordingContent.Audio,
recording_channel_type = RecordingChannel.Unmixed,
recording_format_type = RecordingFormat.Wav,
recording_state_callback_url = "<CallbackUri>",
audio_channel_participant_ordering=[CommunicationUserIdentifier(id="<ACS_USER_MRI>")])
2.4. 非ミックスのみ - チャネル アフィニティを指定する
_channel_affinity = ChannelAffinity(target_participant=CommunicationUserIdentifier("<ACS_USER_MRI>"), channel=0)
response = call_automation_client.start_recording(call_locator=ServerCallLocator(server_call_id),
recording_content_type = RecordingContent.Audio,
recording_channel_type = RecordingChannel.Unmixed,
recording_format_type = RecordingFormat.Wav,
recording_state_callback_url = "<CallbackUri>",
channel_affinity=[_channel_affinity])
StartAsync
API 応答には、レコーディング セッションの recordingId
が含まれています。
3. 'stop_recording' API を使用してレコーディング セッションを停止する
start_recording
への応答で受信した recording_id
を使用します。
stop_recording = call_automation_client.stop_recording(recording_id = recording_id)
4. 'pause_recording' API を使用してレコーディング セッションを一時停止する
start_recording
への応答で受信した recording_id
を使用します。
pause_recording = call_automation_client.pause_recording(recording_id = recording_id)
5. 'resume_recording' API を使用してレコーディング セッションを再開する
start_recording
への応答で受信した recording_id
を使用します。
resume_recording = call_automation_client.resume_recording(recording_id = recording_id)
6. 'download_recording' API を使用してレコーディング ファイルをダウンロードする
記録されたメディアをダウンロードする準備ができたときにサービスに通知するために、Azure Event Grid Web hook または他のトリガーされたアクションを使用する必要があります。
Event Grid の通知 Microsoft.Communication.RecordingFileStatusUpdated
は、レコーディングを取得する準備ができたときに発行されます。通常は、レコーディング プロセスが完了 (会議が終了、レコーディングの停止など) してから 1、2 分後になります。 録音のイベント通知には contentLocation
と metadataLocation
が含まれます。これらは、録音されたメディアと録音メタデータ ファイルの両方を取得するために使用できます。
イベント スキーマの例を次のコードに示します。
{
"id": string, // Unique guid for event
"topic": string, // /subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}
"subject": string, // /recording/call/{call-id}/serverCallId/{serverCallId}
"data": {
"recordingStorageInfo": {
"recordingChunks": [
{
"documentId": string, // Document id for the recording chunk
"contentLocation": string, //Azure Communication Services URL where the content is located
"metadataLocation": string, // Azure Communication Services URL where the metadata for this chunk is located
"deleteLocation": string, // Azure Communication Services URL to use to delete all content, including recording and metadata.
"index": int, // Index providing ordering for this chunk in the entire recording
"endReason": string, // Reason for chunk ending: "SessionEnded", "ChunkMaximumSizeExceeded”, etc.
}
]
},
"recordingStartTime": string, // ISO 8601 date time for the start of the recording
"recordingDurationMs": int, // Duration of recording in milliseconds
"sessionEndReason": string // Reason for call ending: "CallEnded", "InitiatorLeft”, etc.
},
"eventType": string, // "Microsoft.Communication.RecordingFileStatusUpdated"
"dataVersion": string, // "1.0"
"metadataVersion": string, // "1"
"eventTime": string // ISO 8601 date time for when the event was created
}
download_recording
API を使用して記録されたメディアをダウンロードする。
response = recording_data = call_automation_client.download_recording(content_location)
with open("<file_name>", "wb") as binary_file:
binary_file.write(recording_data.read())
レコーディング用の downloadLocation
は、recordingChunk
の contentLocation
属性からフェッチできます。
download_recording
メソッドを使用して、コンテンツをバイトにダウンロードします。
7. 'delete_recording' API を使用してレコーディング コンテンツを削除する
レコーディング コンテンツ (記録されたメディア、メタデータなど) を削除するには、delete_recording
API を使用します。
response = call_automation_client.delete_recording(delete_location);
サンプル コード
サンプル アプリは GitHub からダウンロードできます
前提条件
- アクティブなサブスクリプションを含む Azure アカウントが必要です。
- Communication Services リソースをデプロイします。 リソースの接続文字列をメモします。
- Azure Event Grid を使ってイベントをサブスクライブします。
- Node.js アクティブ LTS およびメンテナンス LTS バージョン (8.11.1 および 10.14.1 を推奨)
開始する前に
通話レコーディング API で記録を開始するには、serverCallId
のみを使います。 シナリオに応じて、serverCallId
のフェッチに使用できるメソッドがいくつかあります。
Call Automation のシナリオ
-
Call Automation を使う場合、
serverCallId
を取得するには 2 つのオプションがあります。- 通話が作成されると、通話が確立した後に
CallConnected
イベントのプロパティとしてserverCallId
が返されます。 Call Automation SDK から CallConnected イベントを取得する方法を参照してください。 - 通話に応答するか、通話が作成されると、
AnswerCallResult
またはCreateCallResult
API 応答のそれぞれのプロパティとしてserverCallId
が返されます。
- 通話が作成されると、通話が確立した後に
Calling SDK のシナリオ
Calling Client SDK を使う場合、通話に対して getServerCallId
メソッドを使うことで serverCallId
を取得できます。
この例を使って Calling Client SDK から serverCallId を取得する方法を学習します。
それでは簡単な手順から始めましょう。
1. Call Automation クライアントを作成する
Call Recording API は、Azure Communication Services の Call Automation ライブラリの一部です。 したがって、Call Automation クライアントを作成する必要があります。
Call Automation クライアントを作成するには、Communication Services の接続文字列を使用し、それを CallAutomationClient
オブジェクトに渡します。
const callAutomationClient = new CallAutomationClient.CallAutomationClient("<ACSConnectionString>");
2. "StartAsync" API を使用して StartRecordingOptions でレコーディング セッションを開始する
通話の開始時に受け取った serverCallId
を使います。
-
RecordingContent
を使用して、レコーディング コンテンツ タイプを渡します。AUDIO
を使用してください。 -
RecordingChannel
を使用して、レコーディング チャネルの種類を渡します。MIXED
またはUNMIXED
を使用します。 -
RecordingFormat
を使用して、レコーディングのフォーマットを渡します。WAV
を使用してください。
var locator: CallLocator = { id: "<ServerCallId>", kind: "serverCallLocator" };
var options: StartRecordingOptions =
{
callLocator: locator,
recordingContent: "audio",
recordingChannel:"unmixed",
recordingFormat: "wav",
recordingStateCallbackEndpointUrl: "<CallbackUri>"
};
var response = await callAutomationClient.getCallRecording().start(options);
2.1. レコーディングを開始する - Bring Your Own Azure Blob Store
レコーディングが完了したら、指定した Azure Blob Storage を使用して記録を開始し、記録されたファイルを格納します。
const recordingStorageKind: RecordingStorageKind = "azureBlobStorage"
const recordingStorage: RecordingStorage = {
recordingStorageKind: recordingStorageKind,
recordingDestinationContainerUrl: "<YOUR_STORAGE_CONTAINER_URL>"
}
var options: StartRecordingOptions = {
callLocator: callLocator,
recordingContent: "audio",
recordingChannel:"unmixed",
recordingFormat: "wav",
recordingStateCallbackEndpointUrl: "<CallbackUri>",
recordingStorage: recordingStorage
};
var response = await callAutomationClient.getCallRecording().start(options);
2.2. 'StartAsync' API を使用して一時停止モードを有効にしてセッションのレコーディングを開始する
Note
レコーディング ファイルを生成するには、レコーディングを再開する必要があります。
var locator: CallLocator = { id: "<ServerCallId>", kind: "serverCallLocator" };
var options: StartRecordingOptions =
{
callLocator: locator,
recordingContent: "audio",
recordingChannel:"unmixed",
recordingFormat: "wav",
pauseOnStart: true
recordingStateCallbackEndpointUrl: "<CallbackUri>",
audioChannelParticipantOrdering:[{communicationUserId: "<ACS_USER_MRI>"}]
};
var response = await callAutomationClient.getCallRecording().start(options);
2.3. 非ミックスのみ - チャネル 0 のユーザーを指定する
非ミキシング オーディオ レコーディング ファイルを生成するには、AudioChannelParticipantOrdering
機能を使用して、チャネル 0 に記録するユーザーを指定できます。 参加者の残りの部分は、話すときにチャネルに割り当てられます。
RecordingChannel.Unmixed
を使用し、AudioChannelParticipantOrdering
を使用しない場合、Call Recording によって最初に話している参加者にチャネル 0 が割り当てられます。
var locator: CallLocator = { id: "<ServerCallId>", kind: "serverCallLocator" };
var options: StartRecordingOptions =
{
callLocator: locator,
recordingContent: "audio",
recordingChannel:"unmixed",
recordingFormat: "wav",
recordingStateCallbackEndpointUrl: "<CallbackUri>",
audioChannelParticipantOrdering:[{communicationUserId: "<ACS_USER_MRI>"}]
};
var response = await callAutomationClient.getCallRecording().start(options);
2.4. 非ミックスのみ - チャネル アフィニティを指定する
var options: StartRecordingOptions =
{
callLocator: locator,
recordingContent: "audio",
recordingChannel:"unmixed",
recordingFormat: "wav",
recordingStateCallbackEndpointUrl: "<CallbackUri>",
ChannelAffinity:
[
{
channel:0,
targetParticipant:{communicationUserId: "<ACS_USER_MRI>"}
}
]
};
var response = await callAutomationClient.getCallRecording().start(options);
StartAsync
API 応答には、レコーディング セッションの recordingId
が含まれています。
3. 'stop' API を使用してレコーディング セッションを停止する
start
への応答で受信した recordingId
を使用します。
var stopRecording = await callAutomationClient.getCallRecording().stop(recordingId);
4. 'pause' API を使用してレコーディング セッションを一時停止する
start
への応答で受信した recordingId
を使用します。
var pauseRecording = await callAutomationClient.getCallRecording().pause(recordingId);
5. "ResumeAsync" API を使用してレコーディング セッションを再開する
start
への応答で受信した recordingId
を使用します。
var resumeRecording = await callAutomationClient.getCallRecording().resume(recordingId);
6. 'DownloadToAsync' API を使ってレコーディング ファイルをダウンロードする
記録されたメディアをダウンロードする準備ができたときにサービスに通知するために、Azure Event Grid Web hook または他のトリガーされたアクションを使用する必要があります。
Event Grid の通知 Microsoft.Communication.RecordingFileStatusUpdated
は、レコーディングを取得する準備ができたときに発行されます。通常は、レコーディング プロセスが完了 (会議が終了、レコーディングの停止など) してから 1、2 分後になります。 録音のイベント通知には contentLocation
と metadataLocation
が含まれます。これらは、録音されたメディアと録音メタデータ ファイルの両方を取得するために使用できます。
イベント スキーマの例を次のコードに示します。
{
"id": string, // Unique guid for event
"topic": string, // /subscriptions/{subscription-id}/resourceGroups/{group-name}/providers/Microsoft.Communication/communicationServices/{communication-services-resource-name}
"subject": string, // /recording/call/{call-id}/serverCallId/{serverCallId}
"data": {
"recordingStorageInfo": {
"recordingChunks": [
{
"documentId": string, // Document id for the recording chunk
"contentLocation": string, //Azure Communication Services URL where the content is located
"metadataLocation": string, // Azure Communication Services URL where the metadata for this chunk is located
"deleteLocation": string, // Azure Communication Services URL to use to delete all content, including recording and metadata.
"index": int, // Index providing ordering for this chunk in the entire recording
"endReason": string, // Reason for chunk ending: "SessionEnded", "ChunkMaximumSizeExceeded”, etc.
}
]
},
"recordingStartTime": string, // ISO 8601 date time for the start of the recording
"recordingDurationMs": int, // Duration of recording in milliseconds
"sessionEndReason": string // Reason for call ending: "CallEnded", "InitiatorLeft”, etc.
},
"eventType": string, // "Microsoft.Communication.RecordingFileStatusUpdated"
"dataVersion": string, // "1.0"
"metadataVersion": string, // "1"
"eventTime": string // ISO 8601 date time for when the event was created
}
downloadToPath
API を使用して記録されたメディアをダウンロードする。
var response = await callAutomationClient.getCallRecording().downloadToPath(contentLocation, fileName);
レコーディング用の downloadLocation
は、recordingChunk
の contentLocation
属性からフェッチできます。
DownloadToAsync
メソッドを使用して、指定されたファイル名にコンテンツをダウンロードします。
7. "DeleteAsync" API を使用してレコーディング コンテンツを削除する
レコーディング コンテンツ (記録されたメディア、メタデータなど) を削除するには、delete
API を使用します。
var response = await callAutomationClient.getCallRecording().delete(deleteLocation);
リソースをクリーンアップする
Communication Services サブスクリプションをクリーンアップして解除する場合は、リソースまたはリソース グループを削除できます。 リソース グループを削除すると、それに関連付けられている他のリソースも削除されます。 詳細については、リソースのクリーンアップに関する記事を参照してください。
次の手順
詳細については、次の記事を参照してください。
- Java、Python、JavaScript の通話レコーディング サンプル アプリをダウンロードする。
- Call Recording についてさらに学習する。
- Call Automation の詳細を確認します。