Telegram VoIP Library for Python
Branch: master
Clone or download
Latest commit 96926dc Feb 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
3rdparty add license Feb 14, 2019
docs prepare for release Feb 14, 2019
example prepare for release Feb 14, 2019
src prepare for release Feb 14, 2019
.gitignore add appveyor builds Feb 14, 2019
CMakeLists.txt prepare for release Feb 14, 2019
COPYING add license Feb 14, 2019
COPYING.lesser add license Feb 14, 2019
MANIFEST.in fix source builds Feb 14, 2019
NOTICE add license Feb 14, 2019
README.md add badges Feb 14, 2019
appveyor.yml fix appveyor deploy Feb 14, 2019
setup.py fix source builds Feb 14, 2019

README.md

pytgvoip

Telegram VoIP Library for Python

Community

Supported MTProto frameworks: Pyrogram

from pyrogram import Client
from tgvoip 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()

app.idle()

PytgVoIP is a Telegram VoIP library written in Python and C++.

It uses libtgvoip (a library used in official clients) for voice encoding and transmission, and pybind11 for simple generation of Python extension written in C++.

Features

  • Making and receiving Telegram calls
  • Python callbacks for sending and receiving audio stream frames allow flexible control (see alsa.py example which uses system audio devices)
  • Included classes that use files for audio playback/record
  • Pre-built Windows wheels in PyPI

Requirements

Linux, MacOS: (use binary wheels from PyPI for Windows)

  • libtgvoip
  • CMake, C++11-compatible compiler, Python headers

Installing

pip3 install pytgvoip

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