POLSKA WERSJA -> https://github.com/Meloon33/MusicFlow/blob/main/README.pl.md
MusicFlow is an innovative tool designed to simplify the management of extensive music libraries while enhancing the playback experience. It offers two primary features:
- Automated MP3 File Renaming: Leverages AI-powered language detection via LM Studio to standardize MP3 filenames into a consistent format with language tags (e.g.,
Artist - Title - [ENG].mp3). - Text-to-Speech (TTS) Announcements: Integrates with foobar2000 to deliver radio-style track introductions and hourly time announcements using Microsoft Edge TTS voices, perfect for immersive playlists and sharing music on Discord.
Ideal for music enthusiasts, DJs, or anyone seeking to organize their music collection and add a professional flair to playback, MusicFlow enhances group listening experiences.
Demo Video: See MusicFlow in action with radio-style track introductions in foobar2000:
Note: The demo showcases LM Studio for AI-generated announcements, but generic TTS is supported if LM Studio is unavailable.
- Overview
- Features
- Requirements
- Installation
- Usage
- File Structure
- Testing
- Troubleshooting
- Discord Audio Sharing Workaround
- License
- Contributing
- Project Background
MusicFlow streamlines music library management and playback automation through two core functionalities:
- Processes MP3 files in a specified directory, using LM Studio's AI model to detect languages and standardize filenames.
- Adds language tags (e.g.,
[ENG],[PL],[ES]) based on AI detection or user-specified preferences.
- Employs a JScript Panel script (
tts.js) in foobar2000 to generate spoken track introductions and hourly time updates via Microsoft Edge TTS voices. - Supports multiple languages with configurable voices (e.g.,
en-US-JennyNeural,pl-PL-ZofiaNeural).
- Seamlessly integrates with foobar2000 32-bit using the JScript Panel for automation tasks like file renaming and TTS playback.
- AI-Driven File Renaming: Cleans and standardizes MP3 filenames using LM Studio’s language model.
- Multilingual TTS: Delivers track and time announcements in various languages with high-quality neural voices.
- Customizable Announcements: Allows voice, delay, and language adjustments in
tts.js. - Discord Compatibility: Provides a workaround to share music and announcements on Discord via a virtual machine.
- Efficient Processing: Tracks processed files to prevent redundant renaming and supports batch API calls for speed.
Ensure the following are installed:
- Python 3.6+ with pip
- LM Studio: For AI language detection (Download)
- foobar2000 32-bit: For playback and automation (Download)
- JScript Panel: foobar2000 plugin for scripting (Download)
- Microsoft Edge: Required for TTS via
edge-playback
requests==2.28.1pydub==0.25.1langdetect==1.0.9
Dependencies are listed in requirements.txt and can be installed automatically.
- Install foobar2000 (32-bit):
- Download from foobar2000.org.
- Install the 32-bit version on Windows.
- Install JScript Panel:
- Download from GitHub.
- Extract to the foobar2000 installation directory and follow the plugin’s installation guide.
- Configure JScript Panel:
- In foobar2000, go to View → Layout → Enable Layouts.
- Add a JScript Panel to the layout.
- Load
tts.jsfor TTS announcements or custom scripts for automation.
- Install LM Studio:
- Download from lmstudio.ai and install on Windows.
- Load the AI Model:
- Open LM Studio and load the Llama-3.2-3B model (or download from the model library).
- Start the API Server:
- Enable the local API server (default:
http://localhost:1234/v1/chat/completions).
- Enable the local API server (default:
- Automated Setup (Windows):
- Run
install_dependencies.batto:- Create a virtual environment (
env). - Install dependencies from
requirements.txt.
- Create a virtual environment (
- Run
- Manual Setup:
- Activate the virtual environment:
.\env\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Activate the virtual environment:
The renaming_script.py script standardizes MP3 filenames using LM Studio’s AI, adding language tags (e.g., song.mp3 → Artist - Title - [ENG].mp3).
- Start LM Studio:
- Ensure the API server is running at
http://localhost:1234/v1/chat/completions.
- Ensure the API server is running at
- Run the Script:
- Execute:
python renaming_script.py
- Select a language tag (e.g.,
ENG,PL) ordetectfor AI-based detection.
- Execute:
- Script Behavior:
- Processes all
.mp3files in the current directory. - Cleans filenames and appends language tags.
- Skips processed files (tracked in
processed_files.json).
- Processes all
- Example:
- Input:
SuperBand - EpicSong [Official Video].mp3 - Output:
SuperBand - EpicSong - [ENG].mp3
- Input:
The tts.js script in foobar2000’s JScript Panel announces track names and hourly times using Microsoft Edge TTS voices.
- Load the Script:
- Add a JScript Panel in foobar2000 and load
tts.js. - Announcements trigger on track changes or player startup.
- Add a JScript Panel in foobar2000 and load
- Functionality:
- Track Announcements: Extracts and announces track names (excluding tags like
[ENG]) in the appropriate language. - Time Announcements: Announces the time (e.g., “It’s now 3:45 PM”) hourly, limited to once per hour.
- Voice Configuration: Supports voices like
en-US-JennyNeuralandpl-PL-ZofiaNeural, customizable intts.js.
- Track Announcements: Extracts and announces track names (excluding tags like
- Customization:
- Edit
tts.jsto adjust voice mappings, delays (minDelaySeconds,maxDelaySeconds), or TTS rate (ttsRate).
- Edit
The JScript Panel enables automation tasks in foobar2000.
- Install JScript Panel (see Installation).
- Load a Script:
- Add a JScript Panel and load
tts.jsor a custom script.
- Add a JScript Panel and load
- Automation Tasks:
- Use
tts.jsfor track and time announcements. - Create custom scripts for playlist or metadata management.
- Use
music-rename-tts/
├── renaming_script.py # Python script for MP3 file renaming
├── tts.js # JScript for TTS announcements
├── install_dependencies.bat # Batch file for dependency installation (Windows)
├── requirements.txt # Python dependency list
├── processed_files.json # Tracks processed files
├── LICENSE # MIT License
└── README.md # Project documentation
- Place a sample MP3 (e.g.,
test_song.mp3) in the project directory. - Ensure LM Studio is running with the Llama-3.2-3B model.
- Run
python renaming_script.pyand selectdetector a language tag. - Verify the file is renamed (e.g.,
test_song - [ENG].mp3) and logged inprocessed_files.json.
- In foobar2000, load
tts.jsin a JScript Panel. - Play a track with a language tag (e.g.,
song - [ENG].mp3). - Confirm the track name is announced in the correct voice.
- At the start of an hour, verify the time announcement.
- Ensure the JScript Panel loads
tts.jsand interacts with renamed files.
- LM Studio API Error:
- Verify the API server is active at
http://localhost:1234/v1/chat/completionsand the Llama-3.2-3B model is loaded.
- Verify the API server is active at
- “pip not found”:
- Confirm Python and pip are in PATH (
python --version,pip --version).
- Confirm Python and pip are in PATH (
- Language Detection Failure:
- Ensure sufficient metadata or specify a language tag.
- TTS Announcements Not Playing:
- Verify Microsoft Edge is installed and
edge-playbackis accessible. - Confirm
tts.jsis loaded correctly.
- Verify Microsoft Edge is installed and
- JScript Panel Not Loading:
- Use foobar2000 32-bit and verify JScript Panel installation.
- Dependency Issues:
- Run
pip install -r requirements.txtmanually in the virtual environment.
- Run
MusicFlow outputs music via foobar2000 and TTS announcements via Windows system audio (edge-playback). Discord’s single-window audio sharing cannot capture both sources.
Run MusicFlow in a VirtualBox VM with Tiny10 (lightweight Windows 10) to consolidate audio into one window for Discord sharing.
- Install VirtualBox:
- Download from virtualbox.org.
- Download Tiny10:
- Obtain the Tiny10 ISO from a trusted source (e.g., Archive.org).
- Note: Verify the source and review licensing.
- Set Up the VM:
- Create a VM (Windows 10, 64-bit, 2GB RAM, 20GB storage).
- Mount the Tiny10 ISO and install Windows.
- Install MusicFlow:
- Follow Installation steps for Python, LM Studio, foobar2000, and project files.
- Load
tts.jsin foobar2000.
- Share on Discord:
- On the host machine, share the VirtualBox VM window in Discord with audio enabled.
- Play music in foobar2000; both music and announcements will be shared.
- Consolidates audio for Discord sharing.
- Tiny10 minimizes VM resource usage.
- Ensure sufficient host resources for VM performance.
- Adjust VirtualBox audio settings if needed.
Licensed under the MIT License. See LICENSE for details.
Contributions are welcome! Open an issue or submit a pull request for enhancements or fixes.
MusicFlow was developed to create an immersive music experience during Discord gaming sessions, managing a playlist of nearly 4,000 diverse tracks—mixes, remixes, original songs, AI covers, and YouTube tracks in multiple languages. Inconsistent filenames (e.g., containing [Official Video]) and unreliable TTS announcements posed challenges, inspiring this project.
- Initial Challenges: Inconsistent filenames disrupted playback and TTS. Early attempts with AIMP failed due to limited scripting support, causing random TTS triggers. Language detection based on Polish characters (e.g., ą, ę) or word lists was unreliable.
- Switch to foobar2000: Transitioned to foobar2000 32-bit for better JScript Panel support after the 64-bit version proved inadequate. The JScript Panel became central to automation.
- File Renaming Solution: Developed
renaming_script.pyusing LM Studio’s Llama-3.2-3B model to standardize filenames (e.g.,ACDC - You Shook Me All Night Long - [ENG]). Tested models like Qwen, Deepseek, Gemma, and Mistral, but Llama-3.2-3B achieved ~90% accuracy. Optimized with batch API calls (5–10 files) and iterative prompt refinement to handle ambiguous names. - TTS Implementation: Wrote
tts.jsfor foobar2000 to announce tracks and times using Microsoft Edge TTS voices. Initial SAPI use was abandoned due to low-quality voices. Temporary.mp3files disrupted playlists, leading toedge-playbackfor superior quality. Adjusted timing to prevent overlapping announcements (e.g., hourly time at 10 PM in Polish). - Model Selection for Announcements: A key challenge was finding a small, low-resource AI model to generate concise track announcements in Polish and English. Popular non-reasoning models, including BERT, DistilBERT, and T5-small, were tested but produced inconsistent or verbose outputs. After extensive testing,
gemma-3-4b-it-qatproved optimal, balancing quality, speed, and resource efficiency for bilingual announcements. - Discord Integration:
edge-playbackcaused audio-sharing issues on Discord. A VirtualBox VM with Tiny10 consolidated audio, enabling seamless sharing. - Additional Refinements: Enhanced regex patterns and error handling in
renaming_script.pyto preserve metadata (e.g., album, year) and handle file locks. Tuned TTS to skip tags (e.g.,[ENG]) and add natural pauses.
- AI Integration: Leveraged LM Studio and
gemma-3-4b-it-qatfor language detection and announcement generation. - Scripting: Combined Python and JScript for robust automation.
- Problem-Solving: Overcame Discord audio limitations with a VM-based workaround.
- Optimization: Improved performance with batch processing and processed file tracking.
- Enhanced TTS: Integrate AI-generated track introductions with trivia, album details, or release years.
- Improved AI Accuracy: Refine the LLM to surpass 90% accuracy for filename standardization.
- Local AI Voice Model: Implement a local AI voice model for higher-quality, customizable TTS announcements.
- Expanded Features: Support additional file formats and advanced playlist automation.
MusicFlow showcases expertise in Python scripting, AI integration, audio automation, and creative problem-solving, delivering a practical, user-focused solution for music enthusiasts and technical users.
