Pyrogram bot to automate streaming music in voice chats

Related tags

Audiovcpb
Overview

Pyrogram bot to automate streaming music in voice chats

Help

If you face an error, want to discuss this project or get support for it, join it's group on Telegram.

Requirements

  • A computer (a Debian-based Linux recommmended).
  • An alt Telegram account.
  • Bot token from @BotFather.
  • API ID & hash from my.telegram.org.
  • Python 3.6 or newer & latest version of pip.
  • MPV (and libmpv).
  • A software to forward audio to tdesktop (Linux: pulseaudio, Windows: voicemeeter).

Deploying

The code

Cloning

    git clone https://github.com/rojserbest/vcpb.git vcpb && cd vcpb

Configuring

CLI args (when running bot.py)

Example:

python3 bot.py \
--api-id 1 \
--api-hash abcdef1234 \
--token 1234567890:ABCDEF \
--sudo-users 111111_22222_33333 \
--mongo-db-uri mongodb+srv://user:[email protected]/vcpb \
--group -1001876543112 \
--dur-limit 10 \
--lang en
Config file

Copy config/sample_config.py to config/config.py and make it use your credentials (you can also give those as an arg when running bot.py):

API_ID int: your api id from my.telegram.org

API_HASH str: your api hash from my.telegram.org TOKEN str: your bot token from @BotFather

SUDO_USERS list(int): a list of user ids which can pause, skip and change volume

MONGO_DB_URI str: your MongoDB URI (you can get one for free in their official website, sign up, create a cluster and a database named "vcpb")

GROUP int: the id of the group where your bot plays (not required if both USERS_MUST_JOIN and LOG are false)

USERS_MUST_JOIN bool: if true, only users which are in the group can use the bot

LOG bool: if true, now playing messages will be sent to the group

LANG str: your bot language, choose an available language code in strings/

DUR_LIMIT int: max video duration in minutes for downloads

PIP requirements

pip(3) install -U -r requirements.txt

Running

⚠️ Warning for Linux users: don't run any command as root (except those which require it), else you might face bulky problems. You can create a user with adduser music and add it to sudoers using sudo usermod -aG sudo music.

ℹ️ The volume command isn't working on Windows.

On Linux VPS

These are apt package manager instructions but you can install the required packages with other package managers too.

  1. Update and upgrade apt: sudo apt update && sudo apt upgrade -y

  2. Install requirements: sudo apt install python3-pip xrdp pulseaudio mpv libmpv-dev screen -y

  3. Download tdesktop: cd ~ && wget https://telegram.org/dl/desktop/linux -O tdesktop.tar.xz && tar -xf tdesktop.tar.xz && rm tdesktop.tar.xz

  4. Configure XRDP session to only start Telegram: echo "~/Telegram/Telegram" >~/.xsession

  5. Enable pulseaudio service (you can skip this step if you don't have systemctl): systemctl --user enable pulseaudio

  6. Restart the machine: sudo reboot

  7. Start pulseaudio (you can skip this step if you did step 5): pulseaudio --start

  8. Go back to directory of the clone and load a pulseaudio null sink, by running: bash pa.sh

  9. Make a screen for the bot and attach to it: screen -S vcbot

  10. Run the bot: python(3) bot.py

  11. Detattach from the screen by pressing CTRL+A then CTRL+D.

  12. Open a remote desktop client and login to your user.

  13. You should see the Telegram GUI, just login, join a voice chat and set VoiceChatPyroBot as your microphone.

  14. Done, you can now start sending commands to your bot and it'll stream in the voice chat.

On Linux desktop

These are apt package manager instructions but you can install the required packages with other package managers too.

  1. Update and upgrade apt: sudo apt update && sudo apt upgrade -y

  2. Install requirements: sudo apt install pulseaudio mpv libmpv-dev pavucontrol screen -y

  3. If you have Telegram skip this step, otherwise download it here.

  4. Go to directory of the clone and load a pulseaudio null sink, by running: bash pa.sh

  5. Make a screen for the bot and attach to it: screen -S vcbot

  6. Run the bot: python(3) bot.py

  7. Detattach from the screen by pressing CTRL+A then CTRL+D.

  8. Open Telegram, join a voice chat and set VoiceChatPyroBot as your microphone.

  9. Done, you can now start sending commands to your bot and it'll stream in the voice chat.

On Windows 10 PC

  1. Download Voicemeeter here and install it.

  2. Download virtual audio cable here and install it.

  3. Reboot.

  4. Right click the speaker account in your taskbar, then click playback.

  5. Set Voicemeeter input and Voicemeeter output as default and click OK.

  6. Download MPV.

  7. Start Voicemeeter engine.

  8. Run the bot: python bot.py

  9. Open Telegram, join a voice chat and set Voicemeeter input as your microphone.

  10. Done, you can now start sending commands to your bot and it'll stream in the voice chat.

Usage

Streaming YouTube videos

  1. Open YouTube in your browser, and search for a song.
  2. Copy the complete video URL to clipboard and send it to your bot in private.

Method 2

  1. Enable inline for you bot in @BotFather.
  2. In your bot's private, type @usernameOfYourBot followed by your YouTube search query, and click a result.

Authors & Acknowledgment

Inspiration

Development & contribution

ianZiPu is a way to write notation for Guqin (古琴) music.

PyBetween Wrapper for Between - 비트윈을 위한 파이썬 라이브러리 Legal Disclaimer 오직 교육적 목적으로만 사용할수 있으며, 비트윈은 VCNC의 자산입니다. 악의적 공격에 이용할시 처벌 받을수 있습니다. 사용에 따른 책임은 사용자가

Nancy Yi Liang 8 Nov 25, 2022
:sound: Play and Record Sound with Python :snake:

Play and Record Sound with Python This Python module provides bindings for the PortAudio library and a few convenience functions to play and record Nu

spatialaudio.net 750 Dec 31, 2022
A tool for retrieving audio in the past

Rewinder A tool for retrieving audio in the past. Ever felt like, I need to remember that discussion which happened 10 min back. Now you can! Rewind a

Bharat 1 Jan 24, 2022
Audio book player for senior visually impaired.

PI Zero W Audio Book Motivation and requirements My dad is practically blind and at 80 years has trouble hearing and operating tiny or more complicate

Andrej Hosna 29 Dec 25, 2022
Stevan KZ 1 Oct 27, 2021
Improved Python UI to convert Youtube URL to .mp3 file.

YT-MP3 Improved Python UI to convert Youtube URL to .mp3 file. How to use? Just run python3 main.py Enter the URL of the video Enter the PATH of where

8 Jun 19, 2022
A voice based calculator by using termux api in Android

termux_voice_calculator This is. A voice based calculator by using termux api in Android Instagram account 👉 👈 Requirements and installation Downloa

ʕ´•ᴥ•`ʔ╠ŞĦỮβĦa̷m̷╣ʕ´•ᴥ•`ʔ 2 Apr 29, 2022
A Youtube audio player for your terminal

AudioLine A lightweight Youtube audio player for your terminal Explore the docs » View Demo · Report Bug · Request Feature · Send a Pull Request About

Haseeb Khalid 26 Jan 04, 2023
Open-Source bot to play songs in your Telegram's Group Voice Chat. Powered by @Akki_ThePro

VcPlayer Telegram Voice-Chat Bot [PyTGCalls] ⇝ Requirements ⇜ Account requirements A Telegram account to use as the music bot, You cannot use regular

Akki ThePro 2 Dec 25, 2021
A simple voice detection system which can be applied practically for designing a device with capability to detect a baby’s cry and automatically turning on music

Auto-Baby-Cry-Detection-with-Music-Player A simple voice detection system which can be applied practically for designing a device with capability to d

2 Dec 15, 2021
Code for csig audio deepfake detection

FMFCC Audio Deepfake Detection Solution This repo provides an solution for the 多媒体伪造取证大赛. Our solution achieve the 1st in the Audio Deepfake Detection

BokingChen 9 Jun 04, 2022
:speech_balloon: SpeechPy - A Library for Speech Processing and Recognition: http://speechpy.readthedocs.io/en/latest/

SpeechPy Official Project Documentation Table of Contents Documentation Which Python versions are supported Citation How to Install? Local Installatio

Amirsina Torfi 870 Dec 27, 2022
Accompanying code for our paper "Point Cloud Audio Processing"

Point Cloud Audio Processing Krishna Subramani1, Paris Smaragdis1 1UIUC Paper For the necessary libraries/prerequisites, please use conda/anaconda to

Krishna Subramani 17 Nov 17, 2022
All-In-One Digital Audio Workstation and Plugin Suite

How to install Windows Mac OS X Fedora Ubuntu How to Build Debian and Ubuntu Fedora All Other Linux Distros Mac OS X Windows What is MusiKernel? MusiK

j3ffhubb 111 Sep 21, 2021
Analyze, visualize and process sound field data recorded by spherical microphone arrays.

Sound Field Analysis toolbox for Python The sound_field_analysis toolbox (short: sfa) is a Python port of the Sound Field Analysis Toolbox (SOFiA) too

Division of Applied Acoustics at Chalmers University of Technology 69 Nov 23, 2022
The official repository for Audio ALBERT

AALBERT Here is also the official repository of AALBERT, which is Pytorch lightning reimplementation of the paper, Audio ALBERT: A Lite Bert for Self-

pohan 55 Dec 11, 2022
Users can transcribe their favorite piano recordings to MIDI files after installation

Users can transcribe their favorite piano recordings to MIDI files after installation

190 Dec 17, 2022
Anaphones are like anagrams, but for sounds.

Anaphones Anaphones are like anagrams but for sounds (phonemes). Examples include: salami-awesomely, atari-tiara, and beefy-phoebe. Anaphones can be a

James Murphy 18 Nov 02, 2022
This is a python package that turns any images into MIDI files that views the same as them

image_to_midi This is a python package that turns any images into MIDI files that views the same as them. This package firstly convert the image to AS

Rainbow Dreamer 4 Mar 10, 2022
kapre: Keras Audio Preprocessors

Kapre Keras Audio Preprocessors - compute STFT, ISTFT, Melspectrogram, and others on GPU real-time. Tested on Python 3.6 and 3.7 Why Kapre? vs. Pre-co

Keunwoo Choi 867 Dec 29, 2022