Skip to main content

Velar - A Library Encode And Decode With Keyword.

Project description

tgcalls
Voice chats, private incoming and outgoing calls in Telegram for Developers
Examples Documentation Channel Chat

Telegram WebRTC (VoIP) Mentioned in Awesome Telegram Calls

This project consists of two main parts: tgcalls, velar. The first is a C++ Python extension. The second uses the extension along with MTProto and provides high level SDK. All together, it allows you to create userbots that can record and broadcast in voice chats, make and receive private calls.

Fipper's snippet

from fipper import Client, filters
from fipper.utils import MAX_CHANNEL_ID

from velar import GroupCallFactory

app = Client('velar')
group_call = GroupCallFactory(app).get_file_group_call('input.raw')


@group_call.on_network_status_changed
async def on_network_changed(context, is_connected):
    chat_id = MAX_CHANNEL_ID - context.full_chat.id
    if is_connected:
        await app.send_message(chat_id, 'Successfully joined!')
    else:
        await app.send_message(chat_id, 'Disconnected from voice chat..')


@app.on_message(filters.outgoing & filters.command('join'))
async def join_handler(_, message):
    await group_call.start(message.chat.id)


app.run()

Telethon's snippet

from telethon import TelegramClient, events

from velar import GroupCallFactory

app = TelegramClient('velar', api_id, api_hash).start()
group_call_factory = GroupCallFactory(app, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON)
group_call = group_call_factory.get_file_group_call('input.raw')


@app.on(events.NewMessage(outgoing=True, pattern=r'^/join$'))
async def join_handler(event):
    chat = await event.get_chat()
    await group_call.start(chat.id)

app.run_until_disconnected()

Features

  • Python solution.
  • Prebuilt wheels for macOS, Linux and Windows.
  • Supporting popular MTProto libraries: Fipper, Telethon.
  • Abstract class to implement own MTProto bridge.
  • Work with voice chats in channels and chats.
  • Multiply voice chats (example).
  • System of custom handlers on events.
  • Join as channels or chats.
  • Join using invite (speaker) links.
  • Speaking status with voice activity detection.
  • Mute/unmute, pause/resume, stop/play, volume control and more...

Available sources of input/output data transfers

Note: All audio data is transmitted in PCM 16 bit, 48k. Example how to convert files using FFmpeg.

Requirements

TODO list

  • Incoming and Outgoing private calls (already there and working, but not in the release version).
  • Group Video Calls and more...

Installing

For Fipper

pip3 install -U velar[pyrogram]

For Telethon

pip3 install -U velar[telethon]

tgcalls
PyPi Sources

tgcalls

The first part of the project is C++ extensions for Python. Pybind11 was used to write it. Binding occurs to the tgcalls library by Telegram, which is used in all official clients. To implement the binding, the code of Telegram Desktop and Telegram Android was studied. Changes have been made to the Telegram library. All modified code is available as a subtree in this repository. The main ideas of the changes is to improve the sound quality and to add ability to work with third party audio device modules. In addition, this binding implemented custom audio modules. These modules are allowing transfer audio data directly from Python via bytes, transfer and control the playback/recording of a file or a virtual system device.

How to build

Short answer for Linux:

git clone git@github.com:MarshalX/tgcalls.git --recursive
cd tgcalls

For x86_64:

docker-compose up tgcalls_x86_64

For AArch64 (ARM64):

docker-compose up tgcalls_aarch64

Python wheels will be available in dist folder in root of tgcalls.

More info:

Also, you can investigate into manylinux GitHub Actions builds.

Documentation

Temporarily, instead of documentation, you can use an example along with MTProto.


velar
Documentation PyPi Sources

velar

This project is implementation of using tgcalls Python binding together with MTProto. By default, this library are supports Fipper and Telethon clients for working with Telegram Mobile Protocol. You can write your own implementation of abstract class to work with other libraries.

Learning by example

Visit this page to discover the official examples.

Documentation

velar's documentation lives at tgcalls.org.

Audio file formats

RAW files are now used. You will have to convert to this format yourself using ffmpeg. The example how to transcode files from a code is available here.

From mp3 to raw (to play in voice chat):

ffmpeg -i input.mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw

From raw to mp3 (files with recordings):

ffmpeg -f s16le -ac 2 -ar 48000 -acodec pcm_s16le -i output.raw clear_output.mp3

For playout live stream you can use this one:

ffmpeg -y -i http://stream2.cnmns.net/hope-mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw

For YouTube videos and live streams you can use youtube-dl:

ffmpeg -i "$(youtube-dl -x -g "https://youtu.be/xhXq9BNndhw")" -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw

And set input.raw as input filename.


Getting help

You can get help in several ways:

Contributing

Contributions of all sizes are welcome.

Special thanks to

License

You may copy, distribute and modify the software provided that modifications are described and licensed for free under LGPL-3. Derivatives works (including modifications or anything statically linked to the library) can only be redistributed under LGPL-3, but applications that use the library don't have to be.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

velar-0.0.2-cp312-cp312-manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.12

velar-0.0.2-cp311-cp311-manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.11

velar-0.0.2-cp310-cp310-manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.10

velar-0.0.2-cp39-cp39-manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.9

velar-0.0.2-cp38-cp38-manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.8

velar-0.0.2-cp37-cp37m-manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.7m

File details

Details for the file velar-0.0.2-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for velar-0.0.2-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c69d6836edb2eee9836154569b692cd388909913005f10c1b417adef376f8c5c
MD5 9337894ce393cd7d2c975f375d6ea271
BLAKE2b-256 21b2b40979075fbb8efd129b6c8ac20e9ea9fdbad3a343f77a1e277cb271a434

See more details on using hashes here.

File details

Details for the file velar-0.0.2-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for velar-0.0.2-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0b7e95deac910412ea4fac5c47377ec2a90373e9d463f74f45c30d51525becf5
MD5 f0b0e59a7a9c580048b4be93936a0b55
BLAKE2b-256 c5d7c48338f715e12bab87548c1a9c2c8bdae4f098b39bd29a26d34b4b54e80e

See more details on using hashes here.

File details

Details for the file velar-0.0.2-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for velar-0.0.2-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 55e79c23fa6ad2f75900695279a82fd7de912353d99bdc85ae7c44537c8d8eaa
MD5 b8c45d44b8d9d825ceb64636ecca6a1a
BLAKE2b-256 35b9daa58c414362fa37d186125faa6f6dbaa65f7c3d997abc288dc9978632e9

See more details on using hashes here.

File details

Details for the file velar-0.0.2-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for velar-0.0.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 793f8aad99117fbe0cb5688cd0f0cca45b180637d3a94964eca6f92dae104ed0
MD5 2f8933f4f9d46c10eda7a2ada26150f8
BLAKE2b-256 32f0d7d7c0ecfbc4d9bc1e19070334c0063fab0d77c83c3fcd9d7824e2cfc1a3

See more details on using hashes here.

File details

Details for the file velar-0.0.2-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for velar-0.0.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fec0c2b923297b3816714a67a5386d7fef2965a8ce1b78a6413d03ff24fd9789
MD5 6e79e0c88e723da1aee8676472ebc96a
BLAKE2b-256 e1ab76966a7b17147aa0d30cfc93c72aceff8d06ab2214999312bd9a71211f92

See more details on using hashes here.

File details

Details for the file velar-0.0.2-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for velar-0.0.2-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e71f03b337b9abb7706ecc7c35ef3c17cce782a022103273d41175333d151d51
MD5 93fc9e0853e724d50ea115fa3544be77
BLAKE2b-256 03209d99e192339ae381751113105f7f750c8ea05a85a2e90e5b4e6d1a6bca3a

See more details on using hashes here.

Supported by

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