本文介绍了如何使用 Twilio Java API 获取录制的 wav 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以指出我,使用 Twilio Java API,而不是!REST 请求,如何获取具体调用的录音文件(.wav).

Could somebody point me, using Twilio Java API, NOT! REST requests, how can I get the recorded file (.wav) of a concrete call.

我已经阅读了所有与录音相关的文章(https://support.twilio.com/hc/en-us/sections/205104748-Recording),但没有一个展示如何使用 Java API 做到这一点.

I have read all the related articles to recording (https://support.twilio.com/hc/en-us/sections/205104748-Recording), but none of them shows how to do that with Java API.

我使用这段代码作为起点,假设 CALL_SID 是已知的:

I use this code, as an starting point, assuming the CALL_SID is known:

import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.Recording;
import com.twilio.rest.api.v2010.account.RecordingReader;

public class DeleteRecordings1 {

    private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX";
    private static final String AUTH_TOKEN = "999aa999aaa999aaaa999";

    private static final String CALL_SID = "CA83837718818gdgdg";

    public static void main(String[] args) {
        try {       
            Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

            RecordingReader recordingReader = Recording.reader();
                recordingReader.setCallSid(CALL_SID);

            ResourceSet<Recording> recordings = recordingReader.read();
            String recordingSid;
            for (Recording recording: recordings) { 
                recordingSid = recording.getSid();              

                //HERE! I want to restore the .wav file associated with that RECORD_SID ?¿

            }                       
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

推荐答案

一旦你知道 recordingSid 例如 RE557ce644e5ab84fa21cc21112e22c485

Once you know the recordingSid for example RE557ce644e5ab84fa21cc21112e22c485

您可以在 https://api.twilio.com/2010-04-01/Accounts/ACXXXXX.../Recordings/RE557ce644e5ab84fa21cc21112e22c485.wav

您可以在 https://api.twilio.com/2010-04-01/Accounts/ACXXXXX.../Recordings/RE557ce644e5ab84fa21cc21112e22c485.mp3

其中 ACXXXXX... 是您的 Twilio 帐户 SID (ACCOUNT_SID)

where ACXXXXX... is your Twilio account SID (ACCOUNT_SID)

这篇关于如何使用 Twilio Java API 获取录制的 wav 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 15:25