This is a serverless Telegram bot that transcribes voice, audio, and video notes sent to it using the Groq Whisper API. It also stores and retrieves transcriptions using AWS DynamoDB.
- The bot receives a voice, audio, or video note message from a user.
- It downloads the file from Telegram and checks its duration. If the duration is above a specified limit, it sends a warning message to the user and exits.
- The bot checks if the transcription already exists in AWS DynamoDB. If it does, the saved transcription is sent back to the user.
- If no transcription is found, the bot transcribes the audio using the Groq Whisper API.
- The transcription is sent back to the user as a text message and stored in DynamoDB for future reference.
/start
: Initializes the bot and provides a welcome message./help
: Provides information on how to use the bot and its features.- more coming soon!
/transcribe
: Transcribes the voice, audio, or video note in the reply message./translate
: Translates (into English) the voice, audio, or video note in the reply message.
- The bot is built using the
teloxide
crate for interacting with the Telegram API. - The transcription is done using the
reqwest
crate to send a request to the Groq Whisper API. - The bot uses AWS DynamoDB to store and retrieve transcriptions, ensuring that repeated requests for the same audio do not require retranscription.
- The bot is deployed as a serverless function using AWS Lambda.
TELEGRAM_BOT_TOKEN
: the token for the Telegram bot.GROQ_API_KEY
: the API key for the Groq Whisper API.DYNAMODB_TABLE
: the name of the DynamoDB table where transcriptions are stored.
Before deploying this bot, ensure you have the following prerequisites installed:
- AWS CLI: Follow the instructions here to install the AWS Command Line Interface.
- cargo-lambda: Install
cargo-lambda
(not with cargo, it doesn't support cross compilation) by following the instructions here.
To build:
cargo lambda build --release --arm64
To deploy:
cargo lambda deploy
Ensure that your AWS Lambda function has the necessary permissions to access DynamoDB. You will need to attach a policy that grants the Lambda function read and write permissions to the DynamoDB table. This can be done by attaching the AWSLambdaDynamoDBExecutionRole
managed policy or by creating a custom policy with the necessary permissions.
Do literally whatever you want with this code. I don't care.
Contributions are welcome! If you'd like to help improve this bot, please open a pull request with your changes.