<p align="center">
<a href="https://github.com/MarshalX/tgcalls">
<img src="https://github.com/MarshalX/tgcalls/raw/main/.github/images/logo.png" alt="tgcalls">
</a>
<br>
<b>Voice chats, private incoming and outgoing calls in Telegram for Developers</b>
<br>
<a href="https://github.com/MarshalX/tgcalls/tree/main/examples">
Examples
</a>
•
<a href="https://tgcalls.org">
Documentation
</a>
•
<a href="https://t.me/tgcallslib">
Channel
</a>
•
<a href="https://t.me/tgcallschat">
Chat
</a>
</p>
## Telegram WebRTC (VoIP) [![Mentioned in Awesome Telegram Calls](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/tgcalls/awesome-tgcalls)
This project consists of two main parts: [tgcalls](#tgcalls), [velar](#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
```python
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
```python
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](https://github.com/MarshalX/tgcalls/blob/main/examples/radio_as_smart_plugin.py)).
- 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
- Raw (`GroupCallRaw`, [example with pyav](https://github.com/MarshalX/tgcalls/blob/main/examples/pyav.py),
[example of restreaming](https://github.com/MarshalX/tgcalls/blob/main/examples/restream_using_raw_data.py))
— to send and receive data in `bytes` directly from Python.
- File (`GroupCallFile`, [playout example](https://github.com/MarshalX/tgcalls/blob/main/examples/file_playout.py),
[recording example](https://github.com/MarshalX/tgcalls/blob/main/examples/recorder_as_smart_plugin.py))
— to use audio files including named pipe (FIFO).
- Device (`GroupCallDevice`, [example](https://github.com/MarshalX/tgcalls/blob/main/examples/device_playout.py)) —
to use system virtual devices. Please don't use it with real microphone, headphones, etc.
Note: All audio data is transmitted in PCM 16 bit, 48k.
[Example how to convert files using FFmpeg](#audio-file-formats).
### Requirements
- Python 3.7 or higher.
- A [Telegram API key](https://docs.pyrogram.org/intro/setup#api-keys).
### TODO list
- Incoming and Outgoing private calls
(already there and working, but not in the release version).
- Group Video Calls
[and more...](https://github.com/MarshalX/tgcalls/issues)
### Installing
#### For Fipper
``` bash
pip3 install -U velar[pyrogram]
```
#### For Telethon
``` bash
pip3 install -U velar[telethon]
```
<hr>
<p align="center">
<a href="https://github.com/MarshalX/tgcalls">
<img src="https://github.com/MarshalX/tgcalls/raw/main/.github/images/tgcalls.png" alt="tgcalls">
</a>
<br>
<a href="https://pypi.org/project/tgcalls/">
PyPi
</a>
•
<a href="https://github.com/MarshalX/tgcalls/tree/main/tgcalls">
Sources
</a>
</p>
## tgcalls
The first part of the project is C++ extensions for Python. [Pybind11](https://github.com/pybind/pybind11)
was used to write it. Binding occurs to the [tgcalls](https://github.com/TelegramMessenger/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](https://github.com/MarshalX/tgcalls/tree/main/tgcalls/third_party/lib_tgcalls)
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:
```bash
git clone git@github.com:MarshalX/tgcalls.git --recursive
cd tgcalls
```
For x86_64:
```bash
docker-compose up tgcalls_x86_64
```
For AArch64 (ARM64):
```bash
docker-compose up tgcalls_aarch64
```
Python wheels will be available in `dist` folder in root of `tgcalls`.
More info:
- [Manylinux](build/manylinux/dev).
- [Ubuntu](build/ubuntu).
- [macOS](build/macos).
- [Windows](build/windows).
Also, you can investigate into [manylinux GitHub Actions builds](build/manylinux).
### Documentation
Temporarily, instead of documentation, you can use [an example](velar/velar)
along with MTProto.
<hr>
<p align="center">
<a href="https://github.com/MarshalX/tgcalls">
<img src="https://github.com/MarshalX/tgcalls/raw/main/.github/images/velar.png" alt="velar">
</a>
<br>
<a href="https://tgcalls.org">
Documentation
</a>
•
<a href="https://pypi.org/project/velar/">
PyPi
</a>
•
<a href="https://github.com/MarshalX/tgcalls/tree/main/velar">
Sources
</a>
</p>
## velar
This project is implementation of using [tgcalls](#tgcalls)
Python binding together with [MTProto](https://core.telegram.org/mtproto).
By default, this library are supports [Fipper](https://github.com/pyrogram/pyrogram)
and [Telethon](https://github.com/LonamiWebs/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](https://github.com/MarshalX/tgcalls/tree/main/examples) to discover the official examples.
### Documentation
`velar`'s documentation lives at [tgcalls.org](https://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](https://github.com/MarshalX/tgcalls/blob/e0b2d667728cc92cc0da437b9c85bcc909e4ac9c/examples/player_as_smart_plugin.py#L41).
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.
<hr>
### Getting help
You can get help in several ways:
- We have a community of developers helping each other in our
[Telegram group](https://t.me/tgcallschat).
- Report bugs, request new features or ask questions by creating
[an issue](https://github.com/MarshalX/tgcalls/issues/new) or
[a discussion](https://github.com/MarshalX/tgcalls/discussions/new).
### Contributing
Contributions of all sizes are welcome.
### Special thanks to
- [@FrayxRulez](https://github.com/FrayxRulez) for amazing code of [Unigram](https://github.com/UnigramDev/Unigram).
- [@john-preston](https://github.com/john-preston) for [Telegram Desktop](https://github.com/telegramdesktop/tdesktop) and [tgcalls](https://github.com/TelegramMessenger/tgcalls).
- [@bakatrouble](https://github.com/bakatrouble/) for help and inspiration by [pytgvoip](https://github.com/bakatrouble/pytgvoip).
- [@delivrance](https://github.com/delivrance) for [Fipper](https://github.com/pyrogram/pyrogram).
- [@Lonami](https://github.com/Lonami) for [Telethon](https://github.com/LonamiWebs/Telethon).
### License
You may copy, distribute and modify the software provided that modifications
are described and licensed for free under [LGPL-3](https://www.gnu.org/licenses/lgpl-3.0.html).
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/MarshalX/tgcalls",
"name": "yins-music",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.7",
"maintainer_email": "",
"keywords": "python,library,telegram,async,asynchronous,webrtc,lib,voice-chat,voip,group-chat,video-call,calls,fipper,telethon,velar,tgcalls",
"author": "AyiinXd",
"author_email": "ayiinxd0307@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/61/5f/a582837d7fc25772a669d39542ef7bfdc8bdfe83556008493138332fc789/yins-music-0.1.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://github.com/MarshalX/tgcalls\">\n <img src=\"https://github.com/MarshalX/tgcalls/raw/main/.github/images/logo.png\" alt=\"tgcalls\">\n </a>\n <br>\n <b>Voice chats, private incoming and outgoing calls in Telegram for Developers</b>\n <br>\n <a href=\"https://github.com/MarshalX/tgcalls/tree/main/examples\">\n Examples\n </a>\n \u2022\n <a href=\"https://tgcalls.org\">\n Documentation\n </a>\n \u2022\n <a href=\"https://t.me/tgcallslib\">\n Channel\n </a>\n \u2022\n <a href=\"https://t.me/tgcallschat\">\n Chat\n </a>\n</p>\n\n## Telegram WebRTC (VoIP) [![Mentioned in Awesome Telegram Calls](https://awesome.re/mentioned-badge-flat.svg)](https://github.com/tgcalls/awesome-tgcalls)\n\nThis project consists of two main parts: [tgcalls](#tgcalls), [velar](#velar).\nThe first is a C++ Python extension.\nThe second uses the extension along with MTProto and provides high level SDK.\nAll together, it allows you to create userbots that can record and\nbroadcast in voice chats, make and receive private calls.\n\n#### Fipper's snippet\n```python\nfrom fipper import Client, filters\nfrom fipper.utils import MAX_CHANNEL_ID\n\nfrom velar import GroupCallFactory\n\napp = Client('velar')\ngroup_call = GroupCallFactory(app).get_file_group_call('input.raw')\n\n\n@group_call.on_network_status_changed\nasync def on_network_changed(context, is_connected):\n chat_id = MAX_CHANNEL_ID - context.full_chat.id\n if is_connected:\n await app.send_message(chat_id, 'Successfully joined!')\n else:\n await app.send_message(chat_id, 'Disconnected from voice chat..')\n\n\n@app.on_message(filters.outgoing & filters.command('join'))\nasync def join_handler(_, message):\n await group_call.start(message.chat.id)\n\n\napp.run()\n```\n\n#### Telethon's snippet\n```python\nfrom telethon import TelegramClient, events\n\nfrom velar import GroupCallFactory\n\napp = TelegramClient('velar', api_id, api_hash).start()\ngroup_call_factory = GroupCallFactory(app, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON)\ngroup_call = group_call_factory.get_file_group_call('input.raw')\n\n\n@app.on(events.NewMessage(outgoing=True, pattern=r'^/join$'))\nasync def join_handler(event):\n chat = await event.get_chat()\n await group_call.start(chat.id)\n\napp.run_until_disconnected()\n```\n\n### Features\n\n- Python solution.\n- Prebuilt wheels for macOS, Linux and Windows.\n- Supporting popular MTProto libraries: Fipper, Telethon.\n- Abstract class to implement own MTProto bridge.\n- Work with voice chats in channels and chats.\n- Multiply voice chats ([example](https://github.com/MarshalX/tgcalls/blob/main/examples/radio_as_smart_plugin.py)).\n- System of custom handlers on events.\n- Join as channels or chats.\n- Join using invite (speaker) links.\n- Speaking status with voice activity detection.\n- Mute/unmute, pause/resume, stop/play, volume control and more...\n\n### Available sources of input/output data transfers\n\n- Raw (`GroupCallRaw`, [example with pyav](https://github.com/MarshalX/tgcalls/blob/main/examples/pyav.py),\n[example of restreaming](https://github.com/MarshalX/tgcalls/blob/main/examples/restream_using_raw_data.py))\n \u2014 to send and receive data in `bytes` directly from Python.\n- File (`GroupCallFile`, [playout example](https://github.com/MarshalX/tgcalls/blob/main/examples/file_playout.py),\n [recording example](https://github.com/MarshalX/tgcalls/blob/main/examples/recorder_as_smart_plugin.py))\n \u2014 to use audio files including named pipe (FIFO).\n- Device (`GroupCallDevice`, [example](https://github.com/MarshalX/tgcalls/blob/main/examples/device_playout.py)) \u2014 \nto use system virtual devices. Please don't use it with real microphone, headphones, etc.\n\nNote: All audio data is transmitted in PCM 16 bit, 48k. \n[Example how to convert files using FFmpeg](#audio-file-formats).\n\n### Requirements\n\n- Python 3.7 or higher.\n- A [Telegram API key](https://docs.pyrogram.org/intro/setup#api-keys).\n\n### TODO list\n- Incoming and Outgoing private calls \n(already there and working, but not in the release version).\n- Group Video Calls\n[and more...](https://github.com/MarshalX/tgcalls/issues)\n\n### Installing\n\n#### For Fipper\n``` bash\npip3 install -U velar[pyrogram]\n```\n\n#### For Telethon\n``` bash\npip3 install -U velar[telethon]\n```\n\n<hr>\n<p align=\"center\">\n <a href=\"https://github.com/MarshalX/tgcalls\">\n <img src=\"https://github.com/MarshalX/tgcalls/raw/main/.github/images/tgcalls.png\" alt=\"tgcalls\">\n </a>\n <br>\n <a href=\"https://pypi.org/project/tgcalls/\">\n PyPi\n </a>\n \u2022\n <a href=\"https://github.com/MarshalX/tgcalls/tree/main/tgcalls\">\n Sources\n </a>\n</p>\n\n## tgcalls \n\nThe first part of the project is C++ extensions for Python. [Pybind11](https://github.com/pybind/pybind11)\nwas used to write it. Binding occurs to the [tgcalls](https://github.com/TelegramMessenger/tgcalls)\nlibrary by Telegram, which is used in all official clients. \nTo implement the binding, the code of Telegram Desktop and Telegram Android was studied.\nChanges have been made to the Telegram library. \nAll modified code is [available as a subtree](https://github.com/MarshalX/tgcalls/tree/main/tgcalls/third_party/lib_tgcalls)\nin this repository. The main ideas of the changes is to improve \nthe sound quality and to add ability to work with third party audio device modules.\nIn addition, this binding implemented custom audio modules. These modules are allowing\ntransfer audio data directly from Python via bytes, transfer and control \nthe playback/recording of a file or a virtual system device.\n\n### How to build\n\nShort answer for Linux:\n```bash\ngit clone git@github.com:MarshalX/tgcalls.git --recursive\ncd tgcalls\n```\nFor x86_64:\n```bash\ndocker-compose up tgcalls_x86_64\n```\nFor AArch64 (ARM64):\n```bash\ndocker-compose up tgcalls_aarch64\n```\n\nPython wheels will be available in `dist` folder in root of `tgcalls`.\n\nMore info:\n- [Manylinux](build/manylinux/dev).\n- [Ubuntu](build/ubuntu).\n- [macOS](build/macos).\n- [Windows](build/windows).\n\nAlso, you can investigate into [manylinux GitHub Actions builds](build/manylinux).\n\n### Documentation\n\nTemporarily, instead of documentation, you can use [an example](velar/velar)\nalong with MTProto.\n\n<hr>\n<p align=\"center\">\n <a href=\"https://github.com/MarshalX/tgcalls\">\n <img src=\"https://github.com/MarshalX/tgcalls/raw/main/.github/images/velar.png\" alt=\"velar\">\n </a>\n <br>\n <a href=\"https://tgcalls.org\">\n Documentation\n </a>\n \u2022\n <a href=\"https://pypi.org/project/velar/\">\n PyPi\n </a>\n \u2022\n <a href=\"https://github.com/MarshalX/tgcalls/tree/main/velar\">\n Sources\n </a>\n</p>\n\n## velar \n\nThis project is implementation of using [tgcalls](#tgcalls) \nPython binding together with [MTProto](https://core.telegram.org/mtproto).\nBy default, this library are supports [Fipper](https://github.com/pyrogram/pyrogram)\nand [Telethon](https://github.com/LonamiWebs/Telethon) clients for working \nwith Telegram Mobile Protocol. \nYou can write your own implementation of abstract class to work with other libraries.\n\n### Learning by example\n\nVisit [this page](https://github.com/MarshalX/tgcalls/tree/main/examples) to discover the official examples.\n\n### Documentation\n\n`velar`'s documentation lives at [tgcalls.org](https://tgcalls.org).\n\n### Audio file formats\n\nRAW files are now used. You will have to convert to this format yourself\nusing ffmpeg. The example how to transcode files from a code is available [here](https://github.com/MarshalX/tgcalls/blob/e0b2d667728cc92cc0da437b9c85bcc909e4ac9c/examples/player_as_smart_plugin.py#L41).\n\nFrom mp3 to raw (to play in voice chat):\n```\nffmpeg -i input.mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw\n```\n\nFrom raw to mp3 (files with recordings):\n```\nffmpeg -f s16le -ac 2 -ar 48000 -acodec pcm_s16le -i output.raw clear_output.mp3\n```\n\nFor playout live stream you can use this one:\n```\nffmpeg -y -i http://stream2.cnmns.net/hope-mp3 -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw\n```\n\nFor YouTube videos and live streams you can use youtube-dl:\n```\nffmpeg -i \"$(youtube-dl -x -g \"https://youtu.be/xhXq9BNndhw\")\" -f s16le -ac 2 -ar 48000 -acodec pcm_s16le input.raw\n```\n\nAnd set input.raw as input filename.\n\n<hr>\n\n### Getting help\n\nYou can get help in several ways:\n- We have a community of developers helping each other in our \n[Telegram group](https://t.me/tgcallschat).\n- Report bugs, request new features or ask questions by creating \n[an issue](https://github.com/MarshalX/tgcalls/issues/new) or \n[a discussion](https://github.com/MarshalX/tgcalls/discussions/new).\n\n### Contributing\n\nContributions of all sizes are welcome.\n\n### Special thanks to\n\n- [@FrayxRulez](https://github.com/FrayxRulez) for amazing code of [Unigram](https://github.com/UnigramDev/Unigram).\n- [@john-preston](https://github.com/john-preston) for [Telegram Desktop](https://github.com/telegramdesktop/tdesktop) and [tgcalls](https://github.com/TelegramMessenger/tgcalls).\n- [@bakatrouble](https://github.com/bakatrouble/) for help and inspiration by [pytgvoip](https://github.com/bakatrouble/pytgvoip).\n- [@delivrance](https://github.com/delivrance) for [Fipper](https://github.com/pyrogram/pyrogram).\n- [@Lonami](https://github.com/Lonami) for [Telethon](https://github.com/LonamiWebs/Telethon).\n\n### License\n\nYou may copy, distribute and modify the software provided that modifications\nare described and licensed for free under [LGPL-3](https://www.gnu.org/licenses/lgpl-3.0.html).\nDerivatives works (including modifications or anything statically\nlinked to the library) can only be redistributed under LGPL-3, but\napplications that use the library don't have to be.\n",
"bugtrack_url": null,
"license": "LGPLv3",
"summary": "a library connecting the tgcalls Python binding with MTProto",
"version": "0.1.0",
"project_urls": {
"Author": "https://github.com/AyiinXd",
"Documentation": "https://tgcalls.org/",
"Homepage": "https://github.com/MarshalX/tgcalls",
"Telegram Channel": "https://t.me/tgcallslib",
"Telegram Chat": "https://t.me/tgcallschat"
},
"split_keywords": [
"python",
"library",
"telegram",
"async",
"asynchronous",
"webrtc",
"lib",
"voice-chat",
"voip",
"group-chat",
"video-call",
"calls",
"fipper",
"telethon",
"velar",
"tgcalls"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d44d4645c8ae57ce88430c5bb87a808b64af705de8a97e3cb6a1cc774dd85ebf",
"md5": "60e3cdd9cf079a39ff1dcd993609b5b9",
"sha256": "0c7c0cb043779a42dace7e29ed35c1f2423a37735b3d8703917fb8bf3edc402a"
},
"downloads": -1,
"filename": "yins_music-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "60e3cdd9cf079a39ff1dcd993609b5b9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.7",
"size": 50278,
"upload_time": "2023-09-10T09:09:27",
"upload_time_iso_8601": "2023-09-10T09:09:27.883375Z",
"url": "https://files.pythonhosted.org/packages/d4/4d/4645c8ae57ce88430c5bb87a808b64af705de8a97e3cb6a1cc774dd85ebf/yins_music-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "615fa582837d7fc25772a669d39542ef7bfdc8bdfe83556008493138332fc789",
"md5": "77dee0bd012974f9212ab970d353cd5b",
"sha256": "3faaec03e2b8d9f493028afa3ebfbcb1ac48b0769538581387fa0c0df6510001"
},
"downloads": -1,
"filename": "yins-music-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "77dee0bd012974f9212ab970d353cd5b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.7",
"size": 31126,
"upload_time": "2023-09-10T09:09:29",
"upload_time_iso_8601": "2023-09-10T09:09:29.923074Z",
"url": "https://files.pythonhosted.org/packages/61/5f/a582837d7fc25772a669d39542ef7bfdc8bdfe83556008493138332fc789/yins-music-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-10 09:09:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MarshalX",
"github_project": "tgcalls",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "yins-music"
}