Skip to main content

Pyrogram support module for Telegram VoIP Library for Python

Project description

pytgvoip_pyrogram

PyPI

Sample usage of PytgVoIP library with Pyrogram

Hopefully pytgvoip support will be integrated in Pyrogram itself, but this repository would still be available as reference even after merge.

Detailed pytgvoip usage guide is also available here

Community

# making outgoing calls
from pyrogram import Client
from tgvoip_pyrogram import VoIPFileStreamService

app = Client('account')
app.start()

service = VoIPFileStreamService(app, receive_calls=False)
call = service.start_call('@bakatrouble')
call.play('input.raw')
call.play_on_hold(['input.raw'])
call.set_output_file('output.raw')

@call.on_call_ended
def call_ended(call):
    app.stop()
# accepting incoming calls
from pyrogram import Client
from tgvoip_pyrogram import VoIPFileStreamService, VoIPIncomingFileStreamCall

app = Client('account')
app.start()

service = VoIPFileStreamService(app)

@service.on_incoming_call
def handle_call(call: VoIPIncomingFileStreamCall):
    call.accept()
    call.play('input.raw')
    call.play_on_hold(['input.raw'])
    call.set_output_file('output.raw')
    
    # you can use `call.on_call_ended(lambda _: app.stop())` here instead
    @call.on_call_ended
    def call_ended(call):
        app.stop()

More examples

Requirements

  • Python 3.5 or higher
  • PytgVoIP (listed as dependency)
  • Pyrogram (listed as dependency)

Installing

pip3 install pytgvoip-pyrogram

Encoding audio streams

Streams consumed by libtgvoip should be encoded in 16-bit signed PCM audio.

$ ffmpeg -i input.mp3 -f s16le -ac 1 -ar 48000 -acodec pcm_s16le input.raw  # encode
$ ffmpeg -f s16le -ac 1 -ar 48000 -acodec pcm_s16le -i output.raw output.mp3  # decode

Copyright & License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stefano_pytgvoip_pyrogram-0.0.12.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stefano_pytgvoip_pyrogram-0.0.12-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file stefano_pytgvoip_pyrogram-0.0.12.tar.gz.

File metadata

File hashes

Hashes for stefano_pytgvoip_pyrogram-0.0.12.tar.gz
Algorithm Hash digest
SHA256 493b1b18ec8645f8fb74fef43a7c2cb25ce7e3c2c565f16aee76999266d33282
MD5 bf7cc2560086f2088e3fa0bf2fd15544
BLAKE2b-256 6b5ddc76aefe6e49dc2b1c7c9459f4adf8fe0e2c16eea070514c072a765df421

See more details on using hashes here.

File details

Details for the file stefano_pytgvoip_pyrogram-0.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for stefano_pytgvoip_pyrogram-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 51cea105e5057c6f89ac3a620947190d4a7eee6edc7889a12d70c26008e2c25f
MD5 3646dffe3bfc5705f2d52727402c2fd6
BLAKE2b-256 a06f8b0ae1dcbee4579348f816b92930f64db075b884f69cd24e3d0e8f42e2f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page