통화 녹음/녹화 빠른 시작

이 빠른 시작을 통해 음성 및 영상 통화의 통화 녹음/녹화를 시작할 수 있습니다. 통화 녹음 API 사용을 시작하려면 통화가 이루어져야 합니다. 최종 사용자 호출 환경을 빌드하려면 통화 클라이언트 SDK 및/또는 통화 자동화에 대해 잘 알고 있어야 합니다.

예제 코드

샘플 앱은 GitHub에서 다운로드할 수 있습니다.

필수 조건

  • 활성 구독이 있는 Azure 계정이 필요합니다.
  • Communication Services 리소스를 배포합니다. 리소스 연결 문자열을 기록해 둡니다.
  • Azure Event Grid를 통해 이벤트를 구독합니다.
  • .NET SDK를 다운로드합니다.

시작하기 전에

통화 녹음/녹화 API는 serverCallId만 사용하여 녹음/녹화를 시작합니다. 시나리오에 따라 serverCallId를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.

통화 자동화 시나리오

  • 통화 자동화를 사용하는 경우 serverCallId를 가져오는 두 가지 옵션이 있습니다.
    1. 통화가 생성되었으면 통화가 설정된 후 CallConnected 이벤트의 속성으로 serverCallId가 반환됩니다. 통화 자동화 SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다.
    2. 통화에 응답하거나 통화가 생성되면 각각 AnswerCallResult 또는 CreateCallResult API 응답의 속성으로 serverCallId가 반환됩니다.

통화 SDK 시나리오

몇 가지 간단한 단계를 시작해 보겠습니다.

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. 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.2. 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. '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 웹후크를 사용하거나 녹음/녹화된 미디어를 다운로드할 준비가 되면 서비스에 알리기 위해 기타 트리거된 작업을 사용해야 합니다.

Event Grid 알림(Microsoft.Communication.RecordingFileStatusUpdated)은 녹음/녹화를 검색할 준비가 되면 일반적으로 녹화 프로세스가 완료(예: 모임 종료, 녹음/녹화 중지)되고 나서 몇 분 후에 게시됩니다. 녹음/녹화 이벤트 알림에는 녹음/녹화된 미디어와 녹음/녹화 메타데이터 파일을 모두 검색하는 데 사용되는 contentLocationmetadataLocation이 포함됩니다.

이벤트 스키마의 예:

{
    "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);

녹음의 downloadLocationrecordingChunkcontentLocation 특성에서 가져올 수 있습니다. 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를 다운로드합니다.

시작하기 전에

통화 녹음/녹화 API는 serverCallId만 사용하여 녹음/녹화를 시작합니다. 시나리오에 따라 serverCallId를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.

통화 자동화 시나리오

  • 통화 자동화를 사용하는 경우 serverCallId를 가져오는 두 가지 옵션이 있습니다.
    1. 통화가 생성되었으면 통화가 설정된 후 CallConnected 이벤트의 속성으로 serverCallId가 반환됩니다. 통화 자동화 SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다.
    2. 통화에 응답하거나 통화가 생성되면 각각 AnswerCallResult 또는 CreateCallResult API 응답의 속성으로 serverCallId가 반환됩니다.

통화 SDK 시나리오

몇 가지 간단한 단계를 시작해 보겠습니다.

1. 통화 자동화 클라이언트 만들기

통화 녹음/녹화 API는 Azure Communication Services 통화 자동화 라이브러리의 일부입니다. 따라서 통화 자동화 클라이언트를 만들어야 합니다. 통화 자동화 클라이언트를 만들려면 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. 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.2. 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. '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 웹후크를 사용하거나 녹음/녹화된 미디어를 다운로드할 준비가 되면 서비스에 알리기 위해 기타 트리거된 작업을 사용해야 합니다.

Event Grid 알림(Microsoft.Communication.RecordingFileStatusUpdated)은 녹음/녹화를 검색할 준비가 되면 일반적으로 녹화 프로세스가 완료(예: 모임 종료, 녹음/녹화 중지)되고 나서 몇 분 후에 게시됩니다. 녹음/녹화 이벤트 알림에는 녹음/녹화된 미디어와 녹음/녹화 메타데이터 파일을 모두 검색하는 데 사용되는 contentLocationmetadataLocation이 포함됩니다.

다음은 이벤트 스키마의 예입니다.

{
    "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에 대해 contentLocationdocumentId 필드에서 각각 가져올 수 있습니다.

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를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.

통화 자동화 시나리오

  • 통화 자동화를 사용하는 경우 serverCallId를 가져오는 두 가지 옵션이 있습니다.
    1. 통화가 생성되었으면 통화가 설정된 후 CallConnected 이벤트의 속성으로 serverCallId가 반환됩니다. 통화 자동화 SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다.
    2. 통화에 응답하거나 통화가 생성되면 각각 AnswerCallResult 또는 CreateCallResult API 응답의 속성으로 serverCallId가 반환됩니다.

통화 SDK 시나리오

몇 가지 간단한 단계를 시작해 보겠습니다.

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. 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.2. 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를 사용하여 녹음/녹화 세션 중지

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 웹후크를 사용하거나 녹음/녹화된 미디어를 다운로드할 준비가 되면 서비스에 알리기 위해 기타 트리거된 작업을 사용해야 합니다.

Event Grid 알림(Microsoft.Communication.RecordingFileStatusUpdated)은 녹음/녹화를 검색할 준비가 되면 일반적으로 녹화 프로세스가 완료(예: 모임 종료, 녹음/녹화 중지)되고 나서 몇 분 후에 게시됩니다. 녹음/녹화 이벤트 알림에는 녹음/녹화된 미디어와 녹음/녹화 메타데이터 파일을 모두 검색하는 데 사용되는 contentLocationmetadataLocation이 포함됩니다.

다음은 이벤트 스키마의 예입니다.

{
    "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())

녹음의 downloadLocationrecordingChunkcontentLocation 특성에서 가져올 수 있습니다. 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를 가져오는 데 사용할 수 있는 몇 가지 방법이 있습니다.

통화 자동화 시나리오

  • 통화 자동화를 사용하는 경우 serverCallId를 가져오는 두 가지 옵션이 있습니다.
    1. 통화가 생성되었으면 통화가 설정된 후 CallConnected 이벤트의 속성으로 serverCallId가 반환됩니다. 통화 자동화 SDK에서 CallConnected 이벤트를 가져오는 방법을 알아봅니다.
    2. 통화에 응답하거나 통화가 생성되면 각각 AnswerCallResult 또는 CreateCallResult API 응답의 속성으로 serverCallId가 반환됩니다.

통화 SDK 시나리오

몇 가지 간단한 단계를 시작해 보겠습니다.

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. 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.2. 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를 사용하여 녹음/녹화 세션 중지

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 웹후크를 사용하거나 녹음/녹화된 미디어를 다운로드할 준비가 되면 서비스에 알리기 위해 기타 트리거된 작업을 사용해야 합니다.

Event Grid 알림(Microsoft.Communication.RecordingFileStatusUpdated)은 녹음/녹화를 검색할 준비가 되면 일반적으로 녹화 프로세스가 완료(예: 모임 종료, 녹음/녹화 중지)되고 나서 몇 분 후에 게시됩니다. 녹음/녹화 이벤트 알림에는 녹음/녹화된 미디어와 녹음/녹화 메타데이터 파일을 모두 검색하는 데 사용되는 contentLocationmetadataLocation이 포함됩니다.

다음은 이벤트 스키마의 예입니다.

{
    "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);

녹음의 downloadLocationrecordingChunkcontentLocation 특성에서 가져올 수 있습니다. DownloadToAsync 메서드는 제공된 파일 이름으로 콘텐츠를 다운로드합니다.

7. 'DeleteAsync' API를 사용하여 녹음/녹화 콘텐츠 삭제

녹음 콘텐츠를 삭제하는 데 delete API 사용(예: 녹음된 미디어, 메타데이터)

var response = await callAutomationClient.getCallRecording().delete(deleteLocation);

리소스 정리

Communication Services 구독을 정리하고 제거하려면 리소스 또는 리소스 그룹을 삭제하면 됩니다. 리소스 그룹을 삭제하면 해당 리소스 그룹에 연결된 다른 모든 리소스가 함께 삭제됩니다. 리소스 정리에 대해 자세히 알아보세요.

다음 단계

자세한 내용은 다음 문서를 참조하세요.