Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Help: Call initiation and recording user voice #93

Closed
corusm opened this issue Dec 29, 2022 · 1 comment
Closed

Help: Call initiation and recording user voice #93

corusm opened this issue Dec 29, 2022 · 1 comment

Comments

@corusm
Copy link

corusm commented Dec 29, 2022

Hi there, I am new to the VoIP topic and these things are unclear to me:

1. Recording Audio
I try to record voice of a person that calls:

    bytesArray = bytearray(b'')
    time.sleep(3)
    while call.state == CallState.ANSWERED:
        bytesString = call.read_audio(length=20, blocking=True)
        print(bytesString)
        bytesArray.extend(bytearray(bytesString))

When using blocking=False I just get empty bytes and if I use blocking=True nothing gets recorded. I use sipgate as PBX. Do I make an obvious mistake and how can I get my code working? I use python version 3.10. Is it possible that you publish example code?

2. Calling
I try to call a german phone number 0176123123123 but I get

TODO: Add 500 Error on Receiving SIP Response
Traceback (most recent call last):
  File "/Users/user/dev/phone-call/sipbot.py", line 54, in <module>
    phone.call("0176XXXXXXX")
  File "/Users/user/opt/miniconda3/envs/voice/lib/python3.10/site-packages/pyVoIP/VoIP.py", line 679, in call
    request, call_id, sess_id = self.sip.invite(
  File "/Users/user/opt/miniconda3/envs/voice/lib/python3.10/site-packages/pyVoIP/SIP.py", line 1597, in invite
    response = SIPMessage(self.s.recv(8192))
  File "/Users/user/opt/miniconda3/envs/voice/lib/python3.10/site-packages/pyVoIP/SIP.py", line 345, in __init__
    self.parse(data)
  File "/Users/user/opt/miniconda3/envs/voice/lib/python3.10/site-packages/pyVoIP/SIP.py", line 381, in parse
    raise SIPParseError(
pyVoIP.SIP.SIPParseError: Unable to decipher SIP request: 

How must I change my code or are there example code snippets?

@xyc0815
Copy link
Collaborator

xyc0815 commented Jan 1, 2023

@corusm It is possible that you send us logs from the request and response. In the calling case. It's looks like, that you get an not supported SIP format.

        if check in self.SIPCompatibleVersions:
            self.type = SIPMessageType.RESPONSE
            self.parseSIPResponse(data)
        elif check in self.SIPCompatibleMethods:
            self.type = SIPMessageType.MESSAGE
            self.parseSIPMessage(data)
        else:
            raise SIPParseError(
                "Unable to decipher SIP request: " + str(heading, "utf8")
            )

This is the part, where the error starts.

For the recording part, you may have a look her #80

Repository owner locked and limited conversation to collaborators May 9, 2023
@tayler6000 tayler6000 converted this issue into discussion #134 May 9, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants