A Python-based Telegram bot that identifies songs based on lyrics. It supports both text input and voice messages, using the Genius API to fetch song details.
- Text Search: Type partial lyrics to find a song.
- Voice Search: Record yourself singing or humming lyrics; the bot converts the audio to text and performs a search.
- Smart Matching: Uses fuzzy logic and keyword cleaning to improve search results.
- Genius Integration: Provides direct links to song lyrics on Genius.com.
- FFmpeg-Free: Uses
librosaandsoundfilefor audio conversion, making deployment easier.
- Python 3.8 or higher
- A Telegram Bot Token
- A Genius API Client Access Token
-
Clone the repository (or download the files):
git clone <your-repo-url> cd <your-repo-folder>
-
Create a virtual environment (recommended):
python -m venv venv # Windows venv\Scripts\activate # Mac/Linux source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
You need to set up your environment variables to keep your API keys secure.
-
Create a file named
.envin the root directory of the project. -
Add the following lines to the file, replacing the placeholders with your actual keys:
BOT_TOKEN=your_telegram_bot_token_here GENIUS_API_KEY=your_genius_access_token_here
- BOT_TOKEN: Chat with @BotFather on Telegram and create a new bot.
- GENIUS_API_KEY: Sign up at Genius API Clients, create a new API Client, and copy the Client Access Token.
- I have added a test file within my codebase to check for the functionality and debugging purposesl, you dont need to mandatorily run this file for the functionality of your code
-
Run the bot:
python your_script_name.py
-
Open Telegram and find your bot.
-
Start the conversation:
/start- Initializes the bot./help- Shows instructions.
-
Search:
- Text: Simply type the lyrics (e.g., "is this the real life is this just fantasy").
- Voice: Hold the microphone button and speak/sing the lyrics clearly.
- Audio Processing: The bot creates temporary
.oggand.wavfiles during voice processing (voice_<chat_id>.wav). These are automatically deleted after processing to save space. - Voice Recognition: The bot uses Google Speech Recognition (
en-US). For best results, speak clearly and minimize background noise.
Pull requests are welcome, you can watch, learn or even laugh at my code but for major changes, please open an issue first to discuss what you would like to change.