I have very simple websocket in Python that is listening to live bi-directional stream from Twilio. I get data with the following information.
{'event': 'connected', 'protocol': 'Call', 'version': '1.0.0'}
{'event': 'start', 'sequenceNumber': '1', 'start': {'accountSid': 'accountSid_value', 'streamSid': 'streamSid_value', 'callSid': 'callSid_value', 'tracks': ['inbound'], 'mediaFormat': {'encoding': 'audio/x-mulaw', 'sampleRate': 8000, 'channels': 1}}, 'streamSid': 'streamSid_value'}
{'event': 'media', 'sequenceNumber': '5', 'media': {'track': 'inbound', 'chunk': '4', 'timestamp': '262', 'payload': '/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////w=='}, 'streamSid': 'streamSid_value'}
.........
{'event': 'stop', 'sequenceNumber': '332', 'streamSid': 'streamSid_value', 'stop': {'accountSid': 'accountSid_value', 'callSid': 'callSid_value'}}
The media is located in media.payload. In the example provided media is silence. The media is raw audio encoded in base64. How can I convert the string from media.payload to .wav(or any other) audio file?