Skip to main content

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

Metadata

Release files for pytgvoip-pyrogram 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytgvoip-pyrogram 0.0.11
File Size Uploaded
pytgvoip_pyrogram-0.0.11.tar.gz 7.8 kB Details

Release files / pytgvoip_pyrogram-0.0.11.tar.gz

Download URL pytgvoip_pyrogram-0.0.11.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6972e2c408ae8ad1fb5a7b3532f2879f00a9b747aa227fb9f957bb2f31e7cc46
BLAKE2b-256 checksum
How to use checksums
bfc5a772a5f1677aa511fa490f8b8dfd0ae77d2efa53a76cb879b7e1401fa5b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.0.11 This release

1 release file

0.0.10

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6.1

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page