Simple Telegram bot that converts voice messages to text using Google Speech. Currently can be found on @voicos_bot
- python-telegram-bot
- pymediainfo (and a system library libmediainfo)
- google-cloud-speech
- google-cloud-storage
- Install the libraries via pip:
pip install -r requirements.txt
- Go to Google Cloud and set up a new project. You will need Google Speech API. For messages longer than 1 minute you will also need Google Storage
- Generate new service account and download a private key as JSON
- Set environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the file path of the JSON key (see here for more instructions) - Go to the Google Storage page and create a new bucket
- Message @BotFather on Telegram to create a new bot
- Set up
VOICOS_TOKEN
,VOICOS_BUCKET
andVOICOS_ADMIN_ID
environment variables - Run the bot
python3 bot.py
You will need to pass your credentials JSON to the container and to pass the environment variables with tokens and such.
Run command will look something like this:
docker run -d --restart unless-stopped --name voicos \
-v /path/to/credentials.json:/app/credentials.json \
-e GOOGLE_APPLICATION_CREDENTIALS=/app/credentials.json \
-e VOICOS_TOKEN -e VOICOS_BUCKET -e VOICOS_ADMIN_ID \
ghcr.io/graynk/voicos:latest
Launch the bot, forward the voice message, easy. Works in group chats as well. For messages longer than 1 minute the bot uses long recognition with uploading to Google Storage