-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
audio doesn't work on call, and dtfm isn't capturing values and not working either. #283
Comments
I've got to say that your email user name is rather offensive.
…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: ***@***.***>
|
and that's all u wanted to say? T~T |
Don't listen to him. He sounds like an ass anyway. As for the issue itself; are you using a PJSIP account or a plain SIP account (assuming you're using something like Asterisk/FreePBX here)? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: