You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from pyVoIP.SIP.message.message import SIPMessage
from pyVoIP.credentials import CredentialsManager
from pyVoIP.VoIP.call import VoIPCall,CallState
from pyVoIP.VoIP.error import InvalidStateError
from pyVoIP.VoIP.phone import VoIPPhone, VoIPPhoneParameter
import time
import wave
import traceback
import librosa
import soundfile
class Call(VoIPCall):
def ringing(self, invite_request):
return custom_answer(self)
def bye(self):
print('Bye')
return self.bye()
def custom_answer(call):
print('start answering')
original_data, sr = librosa.load('x00_autogen_sample_music.wav', sr=44100)
resampled_data = librosa.resample(original_data, orig_sr=sr, target_sr=8000)
soundfile.write('to_play.wav',resampled_data,samplerate=8000,subtype='PCM_U8')
f = wave.open('to_play.wav', 'rb')
frames = f.getnframes()
data = f.readframes(frames)
f.close()
return call.answer()
#call.write_audio(data)
# call.answer()
# call.write_audio(data)
# d=10
# while d>0:
# print(call.state)
# time.sleep(.1)
if __name__ == "__main__":
cm = CredentialsManager()
server_username='---'
server_password='---'
cm.add(server_username, server_password)
server_ip='----'
server_port=5060
server_user='5264'
bind_ip='---'
params = VoIPPhoneParameter(server_ip, server_port, server_user, credentials_manager=cm, bind_ip=bind_ip,call_class=Call)
phone = VoIPPhone(params)
phone.start()
print(phone.get_status())
# call_x=phone.call('89200126698')
# while call_x.state!=CallState.ENDED:
# time.sleep(1)
# if call_x.state==CallState.ANSWERED:
# original_data, sr = librosa.load('x00_autogen_sample_music.wav', sr=44100)
# resampled_data = librosa.resample(original_data, orig_sr=sr, target_sr=8000)
# soundfile.write('to_send.wav',resampled_data,samplerate=8000,subtype='PCM_U8')
# f = wave.open('to_send.wav', 'rb',)
# frames = f.getnframes()
# print(f.getframerate())
# data = f.readframes(frames)
# f.close()
# call_x.write_audio(data)
#print(call_x.state)
input('Press enter to disable the phone\n')
phone.stop()
Output is
PhoneStatus.REGISTERED
Press enter to disable the phone
sys:1: UserWarning: RTP Payload type G729 not found.
sys:1: UserWarning: RTP Payload type G729 not found.
sys:1: UserWarning: RTP Payload type speex not found.
sys:1: UserWarning: RTP Payload type iLBC not found.
sys:1: UserWarning: RTP Payload type iLBC not found.
sys:1: UserWarning: RTP Payload type G729 not found.
sys:1: UserWarning: RTP Payload type AMR not found.
start answering
It seems, that ringing () function works and then is happends nothing
The text was updated successfully, but these errors were encountered:
I'm using dev-branch and code
Output is
It seems, that ringing () function works and then is happends nothing
The text was updated successfully, but these errors were encountered: