Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Python3 pjsip with memory buffers for audio streaming

Notifications You must be signed in to change notification settings

nicolaipre/python3-pjsip-memory-buffer

Repository files navigation

Python 3 PJSIP with memory buffers for audio streaming

WARNING: PROJECT IS DEPRECATED - This project only partially works. Instead use:** pjproject fork by malarinv - Branch: py37


I have simply combined the following two libraries because I needed both in one.

This version works with pjproject-2.9.

Install and compile PJSUA(XT) for Python 3

sudo apt install python3 python3-dev build-essential libasound2-dev
wget https://www.pjsip.org/release/2.9/pjproject-2.9.zip
unzip pjproject-2.9.zip
cd pjproject-2.9
chmod +x configure aconfigure
./configure CXXFLAGS=-fPIC CFLAGS=-fPIC LDFLAGS=-fPIC CPPFLAGS=-fPIC
make dep
make
sudo make install

cd pjsip-apps/src/
git clone https://github.com/nicolaipre/python3-pjsip-memory-buffer.git
cd python3-pjsip-memory-buffer

python3 setup.py build
sudo python3 setup.py install

Test installation

Python 3.6.4 (default, Jul  1 2019, 21:52:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pjsuaxt
>>>

Usage

See file main.py in example-usage for full example.

# Create two audio IO buffers
call_audio    = BufferIO(sample_rate=48000.0)
discord_audio = BufferIO(sample_rate=48000.0)

# Create the audio connections
softphone  = Softphone(sample_rate=48000.0)
disc_vc    = DiscordVoice(sample_rate=48000.0)

# Start listening 
softphone.listen(call_audio)  # Capture phone audio to buffer
disc_vc.listen(discord_audio) # Capture discord audio to buffer

# Start relaying the captured audio
softphone.play(discord_audio) # Play discord audio to phone
disc_vc.play(call_audio)      # Play phone audio to discord voice connector

Credits to:

Alternative implementation (have not checked for errors):

About

Python3 pjsip with memory buffers for audio streaming

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published