---
title: "Comment by Zaid Aman on \"🐍 Answer the phone! with Python\" | Hashnode"
description: "Hello, I just have one question. Were you able to play audio files like mp3 and wav over the phone? I have real problem with that plus it is Europe it supports"
url: "https://hashnode.com/posts/answer-the-phone-with-python/668aa2b843bbe12151289203/comment/676030ea6558eb910fe789c4"
---

[Discussion](https://hashnode.com/posts/answer-the-phone-with-python/668aa2b843bbe12151289203)

Comment [🐍 Answer the phone! with Python](https://hashnode.com/posts/answer-the-phone-with-python/668aa2b843bbe12151289203)

[Zaid Aman](https://hashnode.com/@aman-voip)

[Dec 16, 2024](https://hashnode.com/posts/answer-the-phone-with-python/668aa2b843bbe12151289203/comment/676030ea6558eb910fe789c4)

Hello, I just have one question. Were you able to play audio files like mp3 and wav over the phone? I have real problem with that plus it is Europe it supports puma (alaw).

[Kevin Naidoo](https://hashnode.com/@kwnaidoo)

[Dec 18, 2024](https://hashnode.com/posts/answer-the-phone-with-python/668aa2b843bbe12151289203/comment/676030ea6558eb910fe789c4#reply-6762a2cc14e94c0136a63e4d)

Hi Zaid, thanks for the question. Yes, you can but you need to format the audio into a WAV and ensure that the sample rate is 8000 Hz(mono channel).

Then you can send that WAV file back to the user:

audio = AudioSegment.from\_mp3("your\_file.mp3")

audio = audio.set\_frame\_rate(8000).set\_channels(1)

audio.export("output.wav", format="wav")

f = wave.open('output.wav', 'rb')

frames = f.getnframes()

data = f.readframes(frames)

f.close()

call.write\_audio(data)

I suggest looking into my web socket tutorial over at: [kevincoder.co.za/how-i-used-voice-ai-to-bring-ima…](https://kevincoder.co.za/how-i-used-voice-ai-to-bring-imaginary-characters-to-life)

You don't need to use WebRTC if you need the phone system, you can use Twilio media streams or forward the call from a PBX server like Asterisk.

Hope this helps.

[Zaid Aman](https://hashnode.com/@aman-voip)

[Dec 18, 2024](https://hashnode.com/posts/answer-the-phone-with-python/668aa2b843bbe12151289203/comment/676030ea6558eb910fe789c4#reply-6762e5453e133a240789f1a9)

[Kevin Naidoo](https://hashnode.com/@kwnaidoo) Thank you for the response. Actually I have tried that before and it makes the audio very noise (painful for the ear) and unbearable. I have a bit better audio by processing the raw audio into g711 (alaw) format but the RTP couldn't send the packets or the stream in un choppy manner. I have perfectly working pipeline for voice conversation on laptop but not over the phone.

[Kevin Naidoo](https://hashnode.com/@kwnaidoo)

[Dec 19, 2024](https://hashnode.com/posts/answer-the-phone-with-python/668aa2b843bbe12151289203/comment/676030ea6558eb910fe789c4#reply-6763ad11125e254662b81c5e)

I see. Yeah PyVOIP is more for educational purposes, its not efficient for production. You probably should use pjsua/pjsip or twilio media streams for your use case.
