PyVoIP is a pure python VoIP/SIP/RTP library. Currently, it supports PCMA, PCMU, and telephone-event.
Please note this is still in development.
This library does not depend on a sound library, i.e. you can use any sound library that can handle linear sound data i.e. pyaudio or even wave. Keep in mind PCMU/PCMA only supports 8000Hz, 1 channel, 8 bit, audio.
Simply put pyVoIP into your site-packages folder.
This basic code will simple make a phone that will automatically answer then hang up.
frompyVoIP.VoIPimportVoIPPhone, InvalidStateErrordefanswer(call): #This will be your callback function for when you receive a phone call.try:
call.answer()
call.hangup()
exceptInvalidStateError:
passif__name__=='__main__':
phone=VoIPPhone(<SIPServerIP>, <SIPServerPort>, <SIPServerUsername>, <SIPServerPassword>, callCallback=answer, myIP=<Yourcomputer'slocalIP>, sipPort=<PorttouseforSIP (int, default5060)>, rtpPortLow=<lowendoftheRTPPortRange>, rtpPortHigh=<highendoftheRTPPortRange>)
phone.start()
input('Press enter to disable the phone')
phone.stop()