통화 녹음 빠른 시작
이 문서에서는 음성 및 영상 통화에 대한 통화 녹음을 설명합니다. 통화 녹음 API 사용을 시작하려면 통화가 이루어져야 합니다. 최종 사용자 호출 환경을 빌드하려면 클라이언트 SDK 호출 및 통화 자동화에 대해 잘 알고 있는지 확인합니다.
예제 코드
샘플 앱은 GitHub에서 다운로드할 수 있습니다.
필수 조건
- 활성 구독이 있는 Azure 계정이 필요합니다.
- Communication Services 리소스를 배포합니다. 리소스 연결 문자열을 기록해 둡니다.
- Azure Event Grid를 통해 이벤트를 구독합니다.
- .NET SDK를 다운로드합니다.
시작하기 전에
통화 녹음/녹화 API는 serverCallId
만 사용하여 녹음/녹화를 시작합니다. 시나리오에 따라 serverCallId
를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.
통화 자동화 시나리오
호출 자동화를 사용하는 경우 다음을 가져오는 두 가지 옵션이 있습니다.serverCallId
호출을 설정하면 호출이 설정된 후 이벤트의 속성
CallConnected
으로 반환serverCallId
됩니다. 통화 자동화 SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다.호출에 응답하거나 호출이 생성되면 각각 API
CreateCallResult
응답의AnswerCallResult
속성으로 반환serverCallId
됩니다.
통화 SDK 시나리오
통화 클라이언트 SDK를 사용하는 경우 호출 시 getServerCallId
메서드를 사용하여 serverCallId
를 검색할 수 있습니다.
이 예제를 사용하여 통화 클라이언트 SDK에서 serverCallId를 가져오는 방법을 알아봅니다.
몇 가지 간단한 단계를 시작해 보겠습니다.
1. 통화 자동화 클라이언트 만들기
통화 녹음/녹화 API는 Azure Communication Services 통화 자동화 라이브러리의 일부입니다. 따라서 통화 자동화 클라이언트를 만들어야 합니다.
통화 자동화 클라이언트를 만들려면 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 스토리지
녹음이 완료되면 지정된 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>"))
ExternalStorage = new BlobStorage(new Uri("<Insert Container / Blob Uri>"))
};
Response<RecordingStateResult> response = await callAutomationClient.GetCallRecording()
.StartAsync(recordingOptions);
2.2. 'StartAsync' API를 사용하여 일시 중지 모드를 사용하도록 설정한 상태로 녹화 세션 시작
참고 항목
녹화 파일을 생성하려면 녹음을 다시 시작해야 합니다.
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. Unmixed에만 해당 - 채널 0에서 사용자 지정
비혼합 오디오 녹음 파일을 생성하려면 AudioChannelParticipantOrdering
기능을 사용하여 채널 0에서 녹음할 사용자를 지정할 수 있습니다. 나머지 참가자는 말함과 동시에 채널에 할당됩니다.
RecordingChannel.Unmixed
를 사용하지만 AudioChannelParticipantOrdering
을 사용하지 않는 경우 통화 녹음/녹화는 말하는 첫 번째 참가자에게 채널 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. Unmixed에만 해당 - 채널 선호도 지정
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. API를 사용하여 StopAsync
녹음/녹화 세션 중지
에 recordingId
대한 응답으로 받은 것을 StartAsync
사용합니다.
var stopRecording = await callAutomationClient.GetCallRecording().StopAsync(recordingId);
4. API를 사용하여 PauseAsync
녹음/녹화 세션 일시 중지
에 recordingId
대한 응답으로 받은 것을 StartAsync
사용합니다.
var pauseRecording = await callAutomationClient.GetCallRecording ().PauseAsync(recordingId);
5. API를 사용하여 ResumeAsync
녹음/녹화 세션 다시 시작
에 recordingId
대한 응답으로 받은 것을 StartAsync
사용합니다.
var resumeRecording = await callAutomationClient.GetCallRecording().ResumeAsync(recordingId);
6. API를 사용하여 DownloadToAsync
녹음 파일 다운로드
기록된 미디어를 다운로드할 준비가 되면 Azure Event Grid 웹 후크 또는 기타 트리거된 작업을 사용하여 서비스에 알립니다.
Event Grid 알림 Microsoft.Communication.RecordingFileStatusUpdated
은 일반적으로 녹음/녹화가 완료된 후 몇 분(예: 모임이 종료되거나 녹음이 중지되는 경우)을 검색할 준비가 되면 게시됩니다. 기록 이벤트 알림에는 기록된 미디어와 metadataLocation
기록 메타데이터 파일을 모두 검색하는 데 사용할 수 있는 이벤트 알림이 포함 contentLocation
됩니다.
이벤트 스키마의 예:
{
"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
}
API를 사용하여 DownloadToAsync
녹화된 미디어를 다운로드합니다.
var recordingDownloadUri = new Uri(contentLocation);
var response = await callAutomationClient.GetCallRecording().DownloadToAsync(recordingDownloadUri, fileName);
의 downloadLocation
특성에서 녹음/녹화를 contentLocation
recordingChunk
가져옵니다. 메서드를 DownloadToAsync
사용하여 제공된 파일 이름으로 콘텐츠를 다운로드합니다.
7. API를 사용하여 DeleteAsync
콘텐츠 녹화 삭제
API를 사용하여 DeleteAsync
기록 콘텐츠(예: 녹화된 미디어 및 메타데이터)를 삭제합니다.
var recordingDeleteUri = new Uri(deleteLocation);
var response = await callAutomationClient.GetCallRecording().DeleteAsync(recordingDeleteUri);
예제 코드
샘플 앱은 GitHub에서 다운로드할 수 있습니다.
필수 조건
- 활성 구독이 있는 Azure 계정이 필요합니다.
- Communication Services 리소스를 배포합니다. 리소스 연결 문자열을 기록해 둡니다.
- Azure Event Grid를 통해 이벤트를 구독합니다.
- Java SDK를 다운로드합니다.
시작하기 전에
통화 녹음/녹화 API는 녹음/녹화를 serverCallId
시작하는 데만 사용합니다. 시나리오에 따라 serverCallId
를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.
통화 자동화 시나리오
호출 자동화를 사용하는 경우 다음을 가져오는 두 가지 옵션이 있습니다.serverCallId
호출이 만들어
serverCallId
지면 호출이 설정된 후 이벤트의 속성CallConnected
으로 반환됩니다. 통화 자동화 SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다.통화에 응답하거나 통화가 생성되면 각각
AnswerCallResult
또는CreateCallResult
API 응답의 속성으로serverCallId
가 반환됩니다.
통화 SDK 시나리오
통화 클라이언트 SDK를 사용하는 경우 호출 시 getServerCallId
메서드를 사용하여 serverCallId
를 검색할 수 있습니다.
이 예제를 사용하여 통화 클라이언트 SDK에서 serverCallId를 가져오는 방법을 알아봅니다.
몇 가지 간단한 단계를 시작해 보겠습니다.
1. 통화 자동화 클라이언트 만들기
통화 녹음/녹화 API는 Azure Communication Services 통화 자동화 라이브러리의 일부입니다. 따라서 통화 자동화 클라이언트를 만들어야 합니다.
통화 자동화 클라이언트를 만들려면 Communication Services 연결 문자열 사용하여 개체에 CallAutomationClient
전달합니다.
CallAutomationClient callAutomationClient = new CallAutomationClientBuilder()
.connectionString("<acsConnectionString>")
.buildClient();
2. API를 사용하여 startWithResponse
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 스토리지
녹음이 완료되면 지정된 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>"))
.setExternalStorage(new BlobStorage("<Insert Container / Blob Uri>"));
// //start recording
RecordingStateResult result = callRecording.start(recordingOptions);
2.2. API를 사용하여 일시 중지 모드를 사용하도록 StartAsync
설정된 녹음/녹화 세션 시작
참고 항목
녹음 파일을 생성하려면 녹음/녹화를 다시 시작해야 합니다.
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. Unmixed에만 해당 - 채널 0에서 사용자 지정
비혼합 오디오 녹음 파일을 생성하려면 AudioChannelParticipantOrdering
기능을 사용하여 채널 0에서 녹음할 사용자를 지정할 수 있습니다. 나머지 참가자는 말함과 동시에 채널에 할당됩니다.
RecordingChannel.Unmixed
를 사용하지만 AudioChannelParticipantOrdering
을 사용하지 않는 경우 통화 녹음/녹화는 말하는 첫 번째 참가자에게 채널 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. Unmixed에만 해당 - 채널 선호도 지정
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. API를 사용하여 stopWithResponse
녹음/녹화 세션 중지
에 recordingId
대한 응답으로 받은 것을 startWithResponse
사용합니다.
Response<Void> response = callAutomationClient.getCallRecording()
.stopWithResponse(response.getValue().getRecordingId(), null);
4. API를 사용하여 pauseWithResponse
녹음/녹화 세션 일시 중지
에 recordingId
대한 응답으로 받은 것을 startWithResponse
사용합니다.
Response<Void> response = callAutomationClient.getCallRecording()
.pauseWithResponse(response.getValue().getRecordingId(), null);
5. API를 사용하여 resumeWithResponse
녹음/녹화 세션 다시 시작
에 recordingId
대한 응답으로 받은 것을 startWithResponse
사용합니다.
Response<Void> response = callAutomationClient.getCallRecording()
.resumeWithResponse(response.getValue().getRecordingId(), null);
6. API를 사용하여 downloadToWithResponse
녹음 파일 다운로드
Azure Event Grid 웹후크를 사용하거나 녹음/녹화된 미디어를 다운로드할 준비가 되면 서비스에 알리기 위해 기타 트리거된 작업을 사용해야 합니다.
Event Grid 알림 Microsoft.Communication.RecordingFileStatusUpdated
은 일반적으로 녹음/녹화 프로세스가 완료된 후 몇 분(예: 모임 종료 또는 녹화 중지)을 검색할 준비가 되면 게시됩니다. 기록 이벤트 알림에는 기록된 미디어와 metadataLocation
기록 메타데이터 파일을 모두 검색하는 데 사용할 수 있는 이벤트 알림이 포함 contentLocation
됩니다.
다음 코드는 이벤트 스키마의 예입니다.
{
"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
}
클래스 메서드 CallRecording
를 사용하여 downloadToWithResponse
녹화된 미디어를 다운로드합니다. 다음은 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. API를 사용하여 deleteWithResponse
콘텐츠 녹화 삭제
클래스 메서드 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
를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.
통화 자동화 시나리오
-
통화 자동화를 사용하는 경우
serverCallId
를 가져오는 두 가지 옵션이 있습니다.- 호출이 만들어
serverCallId
지면 호출이 설정된 후 이벤트의 속성CallConnected
으로 반환됩니다. 통화 자동화 SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다. - 호출에 응답하거나 호출이 만들어지면 각각 API
CreateCallResult
응답의AnswerCallResult
속성으로 반환serverCallId
됩니다.
- 호출이 만들어
통화 SDK 시나리오
-
통화 클라이언트 SDK를 사용하는 경우 호출 시
server_call_id
변수를 사용하여serverCallId
를 검색할 수 있습니다. 이 예제를 사용하여 통화 클라이언트 SDK에서 serverCallId를 가져오는 방법을 알아봅니다.
몇 가지 간단한 단계를 시작해 보겠습니다.
1. 통화 자동화 클라이언트 만들기
통화 녹음/녹화 API는 Azure Communication Services 통화 자동화 라이브러리의 일부입니다. 따라서 통화 자동화 클라이언트를 만들어야 합니다.
통화 자동화 클라이언트를 만들려면 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 스토리지
기록이 완료되면 기록 파일을 저장하도록 정의된 자체 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를 사용하여 일시 중지 모드를 사용하도록 설정한 상태로 녹화 세션 시작
참고 항목
녹화 파일을 생성하려면 녹음을 다시 시작해야 합니다.
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. Unmixed에만 해당 - 채널 0에서 사용자 지정
비혼합 오디오 녹음 파일을 생성하려면 AudioChannelParticipantOrdering
기능을 사용하여 채널 0에서 녹음할 사용자를 지정할 수 있습니다. 나머지 참가자는 말함과 동시에 채널에 할당됩니다.
RecordingChannel.Unmixed
를 사용하지만 AudioChannelParticipantOrdering
을 사용하지 않는 경우 통화 녹음/녹화는 말하는 첫 번째 참가자에게 채널 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. Unmixed에만 해당 - 채널 선호도 지정
_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를 사용하여 녹음/녹화 세션 중지
에 recording_id
대한 응답으로 받은 것을 start_recording
사용합니다.
stop_recording = call_automation_client.stop_recording(recording_id = recording_id)
4. 'pause_recording' API를 사용하여 녹음/녹화 세션 일시 중지
에 recording_id
대한 응답으로 받은 것을 start_recording
사용합니다.
pause_recording = call_automation_client.pause_recording(recording_id = recording_id)
5. 'resume_recording' API를 사용하여 녹음/녹화 세션 다시 시작
에 recording_id
대한 응답으로 받은 것을 start_recording
사용합니다.
resume_recording = call_automation_client.resume_recording(recording_id = recording_id)
6. 'download_recording' API를 사용하여 녹음/녹화 파일 다운로드
Azure Event Grid 웹후크를 사용하거나 녹음/녹화된 미디어를 다운로드할 준비가 되면 서비스에 알리기 위해 기타 트리거된 작업을 사용해야 합니다.
Event Grid 알림 Microsoft.Communication.RecordingFileStatusUpdated
은 일반적으로 녹음/녹화 프로세스가 완료된 후 몇 분(예: 모임이 종료되거나 녹음이 중지됨)을 검색할 준비가 되면 게시됩니다. 녹음/녹화 이벤트 알림에는 녹음/녹화된 미디어와 녹음/녹화 메타데이터 파일을 모두 검색하는 데 사용되는 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
}
API를 사용하여 download_recording
녹화된 미디어를 다운로드합니다.
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를 사용하여 녹음/녹화 콘텐츠 삭제
API를 사용하여 delete_recording
녹화된 미디어 및 메타데이터와 같은 기록 콘텐츠를 삭제합니다.
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
를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.
통화 자동화 시나리오
-
통화 자동화를 사용하는 경우
serverCallId
를 가져오는 두 가지 옵션이 있습니다.- 호출이 만들어
serverCallId
지면 호출이 설정된 후 이벤트의 속성CallConnected
으로 반환됩니다. Call Automation SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다. - 호출에 응답하거나 호출이 만들어지면 각각 API
CreateCallResult
응답의AnswerCallResult
속성으로 반환serverCallId
됩니다.
- 호출이 만들어
통화 SDK 시나리오
통화 클라이언트 SDK를 사용하는 경우 호출 시 getServerCallId
메서드를 사용하여 serverCallId
를 검색할 수 있습니다.
이 예제를 사용하여 호출 클라이언트 SDK에서 serverCallId를 가져오는 방법을 알아봅니다.
몇 가지 간단한 단계를 시작해 보겠습니다.
1. 통화 자동화 클라이언트 만들기
통화 녹음/녹화 API는 Azure Communication Services 통화 자동화 라이브러리의 일부입니다. 따라서 통화 자동화 클라이언트를 만들어야 합니다.
통화 자동화 클라이언트를 만들려면 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 스토리지
녹음이 완료되면 지정된 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를 사용하여 일시 중지 모드를 사용하도록 설정한 상태로 녹화 세션 시작
참고 항목
녹화 파일을 생성하려면 녹음을 다시 시작해야 합니다.
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. Unmixed에만 해당 - 채널 0에서 사용자 지정
비혼합 오디오 녹음 파일을 생성하려면 AudioChannelParticipantOrdering
기능을 사용하여 채널 0에서 녹음할 사용자를 지정할 수 있습니다. 나머지 참가자는 말함과 동시에 채널에 할당됩니다.
RecordingChannel.Unmixed
를 사용하지만 AudioChannelParticipantOrdering
을 사용하지 않는 경우 통화 녹음/녹화는 말하는 첫 번째 참가자에게 채널 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. Unmixed에만 해당 - 채널 선호도 지정
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를 사용하여 녹음/녹화 세션 중지
에 recordingId
대한 응답으로 받은 것을 start
사용합니다.
var stopRecording = await callAutomationClient.getCallRecording().stop(recordingId);
4. 'pause' API를 사용하여 녹음/녹화 세션 일시 중지
에 recordingId
대한 응답으로 받은 것을 start
사용합니다.
var pauseRecording = await callAutomationClient.getCallRecording().pause(recordingId);
5. 'ResumeAsync' API를 사용하여 녹음/녹화 세션 다시 시작
에 recordingId
대한 응답으로 받은 것을 start
사용합니다.
var resumeRecording = await callAutomationClient.getCallRecording().resume(recordingId);
6. 'DownloadToAsync' API를 사용하여 녹음/녹화 파일 다운로드
Azure Event Grid 웹후크를 사용하거나 녹음/녹화된 미디어를 다운로드할 준비가 되면 서비스에 알리기 위해 기타 트리거된 작업을 사용해야 합니다.
Event Grid 알림 Microsoft.Communication.RecordingFileStatusUpdated
은 일반적으로 녹음/녹화 프로세스가 완료된 후 몇 분(예: 모임이 종료되거나 녹음이 중지됨)을 검색할 준비가 되면 게시됩니다. 녹음/녹화 이벤트 알림에는 녹음/녹화된 미디어와 녹음/녹화 메타데이터 파일을 모두 검색하는 데 사용되는 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
}
API를 사용하여 downloadToPath
녹화된 미디어를 다운로드합니다.
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 Automation에 대해 자세히 알아봅니다.