Twilio initiate a call from python and speak

I am trying to initiate a simple call from Twilio and when the person on other end accepts the call I want to talk with them using my laptop mic and speaker

import os
from twilio.rest import Client


# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)

call = client.calls.create(
                        url='http://demo.twilio.com/docs/voice.xml',
                        to='+15558675310',
                        from_='+15017122661'
                    )

print(call.sid)

The Python3 code above does initiate the call but I can’t talk with the person on another end. I have tried to find the solution in Twilio documentation and I haven’t found any closest implementation to this scenario. Please let me know what modifications should I do in this code to achieve the desired result?

Answer

Twilio developer evangelist here.

When you create a call using the REST API from a Twilio number to your target’s number you are creating a call leg between Twilio and the callee. You will have seen that the URL you pass when you create the call has control over what happens next in the call by returning TwiML instructions. In your example the URL directs Twilio to say a message and play a song.

If you want to speak to the callee, you also need to create a call leg between Twilio and the device you want to speak to them on.

There are a number of options available to you here. You can either: