Permalink
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (66 sloc) 2.85 KB

Recordings

A :class:`Recording` resource represents an individually recorded call. Recordings are generated when you use the Record TwiML verb. For more information, see the Recordings REST Resource documentation.

Audio Formats

Each :class:`Recording` has a :attr:`formats` dictionary which lists the audio formats available for each recording. Below is an example :attr:`formats` dictionary.

{
    "mp3": "https://api.twilio.com/cowbell.mp3",
    "wav": "http://www.dailywav.com/0112/noFateButWhatWeMake.wav",
}

Listing Your Recordings

The following code will print out the :attr:`duration` for each :class:`Recording`.

from twilio.rest import TwilioRestClient

# To find these visit https://www.twilio.com/user/account
ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
for recording in client.recordings.list():
    print recording.duration

You can filter recordings by CallSid by passing the Sid as :attr:`call`. Filter recordings using :attr:`before` and :attr:`after` dates.

The following will only show recordings made before January 1, 2011.

from datetime import date
from twilio.rest import TwilioRestClient

# To find these visit https://www.twilio.com/user/account
ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
for recording in client.recordings.list(before=date(2011,1,1)):
    print recording.duration

Deleting Recordings

The :class:`Recordings` resource allows you to delete unnecessary recordings.

from twilio.rest import TwilioRestClient

# To find these visit https://www.twilio.com/user/account
ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
client.recordings.delete("RC123")

Accessing Related Transcriptions

The :class:`Recordings` allows you to retrieve associated transcriptions. The following prints out the text for each of the transcriptions associated with this recording.

from twilio.rest import TwilioRestClient

# To find these visit https://www.twilio.com/user/account
ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
recording = client.recordings.get("RC123")

for transcription in recording.transcriptions.list():
    print transcription.transcription_text