我正在 Twilio 中使用 python 进行录音。只是想知道如何访问我制作的最新/最新录音?干杯!
进行录音:
resp = twilio.twiml.Response()
resp.say("Please record your message after the beep")
resp.record(maxLength="10", action="/handle-recording")
访问录音的示例代码,我将如何对其进行编码以获得最新的?谢谢!
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "AC30bd8bdca7572344721eb96c15a5c0c7"
auth_token = "your_auth_token"
client = TwilioRestClient(account_sid, auth_token)
# A list of recording objects with the properties described above
recordings = client.recordings.list()
recordings[-1]
应该会为您提供录音中的最后一项,这应该是最新的录音,因为录音会附加到列表中。确保 recordings
不为空,否则您将收到 IndexError
。
我是一名优秀的程序员,十分优秀!