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
here's my code,
(password's and the server ip and phone number has been changed obviously cuz of reasons but try it out, i'm currently using python 3.10.0 and the latest version of pyvoip. lmk how it goes (Call works, like it can call the person, but it wont play audio or listen to dtfm inputs, and just auto hangup in 7-9 seconds)
from pyVoIP.VoIP import VoIPPhone, InvalidStateError, CallState
import time
import wave
import socket
import logging
def get_local_ip():
"""Get the local IP address of the machine"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('10.254.254.254', 1))
local_ip = s.getsockname()[0]
except Exception:
local_ip = '127.0.0.1'
finally:
s.close()
return local_ip
def answer(call):
try:
f = wave.open('raw_audio.wav', 'rb')
frames = f.getnframes()
data = f.readframes(frames)
f.close()
On Mon, Oct 28, 2024 at 2:05 PM coolcunt ***@***.***> wrote:
here's my code,
(password's and the server ip and phone number has been changed obviously
cuz of reasons but try it out, i'm currently using python 3.10.0 and the
latest version of pyvoip. lmk how it goes (Call works, like it can call the
person, but it wont play audio or listen to dtfm inputs, and just auto
hangup in 7-9 seconds)
from pyVoIP.VoIP import VoIPPhone, InvalidStateError, CallState
import time
import wave
import socket
import logging
SIP_SERVER = "123.45.67.89"
SIP_USERNAME = "username"
SIP_PASSWORD = "password"
PHONE_NUMBER = "+123456789"
Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(*name*)
def get_local_ip():
"""Get the local IP address of the machine"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('10.254.254.254', 1))
local_ip = s.getsockname()[0]
except Exception:
local_ip = '127.0.0.1'
finally:
s.close()
return local_ip
def answer(call):
try:
f = wave.open('raw_audio.wav', 'rb')
frames = f.getnframes()
data = f.readframes(frames)
f.close()
call.answer()
call.write_audio(data)
while call.state == CallState.ANSWERED:
dtmf = call.get_dtmf()
if dtmf == "1":
print("pressed one")
# Do something
call.hangup()
elif dtmf == "2":
print("pressed 2")
call.hangup()
time.sleep(0.1)
except InvalidStateError:
pass
except:
call.hangup()
if *name* == '*main*':
local_ip = get_local_ip()
phone = VoIPPhone(
server=SIP_SERVER,
port=5060,
username=SIP_USERNAME,
password=SIP_PASSWORD,
myIP=local_ip,
callCallback=answer
)
phone.start()
logger.info(f"Using local IP: {local_ip}")
logger.info(f"Calling phone number: {PHONE_NUMBER}")
phone.call(PHONE_NUMBER)
input('Press enter to disable the phone')
phone.stop()
—
Reply to this email directly, view it on GitHub
<#283>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFU3N5ZZYOQ6G4YN3HZWWSTZ52RLHAVCNFSM6AAAAABQYJ4S7OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGYYTSNJUHA4TQOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
here's my code,
(password's and the server ip and phone number has been changed obviously cuz of reasons but try it out, i'm currently using python 3.10.0 and the latest version of pyvoip. lmk how it goes (Call works, like it can call the person, but it wont play audio or listen to dtfm inputs, and just auto hangup in 7-9 seconds)
from pyVoIP.VoIP import VoIPPhone, InvalidStateError, CallState
import time
import wave
import socket
import logging
SIP_SERVER = "123.45.67.89"
SIP_USERNAME = "username"
SIP_PASSWORD = "password"
PHONE_NUMBER = "+123456789"
Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(name)
def get_local_ip():
"""Get the local IP address of the machine"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
# doesn't even have to be reachable
s.connect(('10.254.254.254', 1))
local_ip = s.getsockname()[0]
except Exception:
local_ip = '127.0.0.1'
finally:
s.close()
return local_ip
def answer(call):
try:
f = wave.open('raw_audio.wav', 'rb')
frames = f.getnframes()
data = f.readframes(frames)
f.close()
if name == 'main':
local_ip = get_local_ip()
phone = VoIPPhone(
server=SIP_SERVER,
port=5060,
username=SIP_USERNAME,
password=SIP_PASSWORD,
myIP=local_ip,
callCallback=answer
)
phone.start()
logger.info(f"Using local IP: {local_ip}")
logger.info(f"Calling phone number: {PHONE_NUMBER}")
phone.call(PHONE_NUMBER)
input('Press enter to disable the phone')
phone.stop()
The text was updated successfully, but these errors were encountered: