A Python script to download DR LYD audio, generate subtitles using Whisper, convert the subtitles to LRC lyrics format, optionally translate them into any language via Ollama + Gemma 3, and embed these lyrics into the MP3 file.
Now also supports local audio files (MP3 or WAV) for transcription, translation, and lyric embedding – no DR link required.
Disclaimer: This project is intended for educational and research purposes only. The author does not endorse or promote the unauthorized distribution of copyrighted content. Please respect the rights of content creators and only use this tool to download content that is freely available on the internet and use it for study Danish and only for personal use. The code was written by the help of ChatGPT.
-
Download DR LYD audio: Scrapes a DR LYD program page to extract the m3u8 URL and downloads the audio as an MP3 file using ffmpeg.
-
Convert audio for Whisper: Converts the downloaded MP3 file to WAV (mono, 16 kHz) for compatibility with Whisper.
-
(NEW) Transcribe local audio files: You can pass a local MP3 or WAV file to the script. It will convert, transcribe, and optionally translate it just like a DR podcast.
-
Generate subtitles: Uses Whisper CLI to generate an SRT subtitle file from the WAV file.
-
Convert SRT to LRC: Converts the generated SRT file into LRC (lyric) format.
-
Embed lyrics: Embeds the LRC lyrics into the MP3 file using ID3 tags.
-
(Optional) Generate a translated copy: If you pass a second argument (either
translate
or a specific language name), a second MP3 is created containing Danish + translation. -
Cleanup: Removes intermediate files (WAV, SRT, LRC) so that only the final MP3 remains.
-
(Optional) Generate a translated copy: If you pass a second argument (either
translate
or a specific language name), a second MP3 is created containing Danish + translation. -
Cleanup: Removes intermediate files (WAV, SRT, LRC) so that only the final MP3 remains.
- Python 3.11+
- ffmpeg must be installed and in your system PATH.
- whisper-cli must be installed. You can see the installation instructions for each platform in the repository.
./build/bin/whisper-cli
must be in your system PATH.- Environment variable
WHISPER_MODEL_PATH
must be set to the path of your Whisper model file (e.g.,ggml-medium.bin
). - (Optional) Translation: If you plan to use the translate feature, you need Ollama and the Python ollama client installed, as well as an available model (e.g.
gemma3
).
-
Clone the repository:
git clone https://github.com/iskoldt-X/DR-LRC.git cd DR-LRC
-
Install the required Python packages:
pip install -r requirements.txt
-
Set up the Whisper model path in your shell.
For example, if you are using zsh on macOS
A quick guide to install
whisper-cli
and the model:git clone https://github.com/ggml-org/whisper.cpp.git cd whisper.cpp # using large-v3 model for example make -j large-v3
After that, you have your model in
./models/ggml-large-v3.bin
andwhisper-cli
in./build/bin/whisper-cli
.Add the following line to your
~/.zshrc
file:export WHISPER_MODEL_PATH=/path/to/your/whisper.cpp/models/ggml-large-v3.bin export PATH="/path/to/your/whisper.cpp/build/bin:$PATH"
Replace
/path/to/your/
with the actual path to yourwhisper.cpp
directory.Then, run
source ~/.zshrc
to apply the changes.Download and ollama and then pull the gemma3 model in the terminal:
ollama pull gemma3:12b
You can also use other models like
gemma3:4b
orgemma3:1b
if you don't have enough GPU memory. Or you have so much GPU memory that you can usegemma3:27b
. Just remember to change the model name in the script.
Run the script from the command line by providing a DR LYD URL:
python3 dr_lrc.py https://www.dr.dk/lyd/your-podcast-link
The script will:
- Download the audio and convert it to MP3.
- Convert the MP3 to WAV for transcription.
- Run whisper-cli to generate an SRT subtitle file.
- Convert the SRT file to LRC lyrics.
- Embed the LRC lyrics into the MP3.
- Delete intermediate files, leaving only the final MP3 file.
You can also use the script to process a local audio file (MP3 or WAV). Just provide the path to the file as the first argument:
python3 dr_lrc.py your_file.mp3
This will transcribe the audio, generate Danish subtitles and lyrics, and embed them into a new MP3 file. If the input is a WAV file, it will be converted to MP3 automatically.
You can optionally add a second argument to request translation into a specific language. For example, if you run:
python3 dr_lrc.py <DR_LYD_URL> French
It will create a second MP3 containing Danish + French lyrics embedded. The main MP3 remains Danish-only.
If you include the word translate as the second argument, the script will default to English. For instance:
python3 dr_lrc.py <DR_LYD_URL> translate
You will end up with two MP3s:
The original MP3 (with Danish-only lyrics). A second MP3 named something like dr_output_translated.mp3, containing “Danish / English” lines.
This project is licensed under the MIT License - see the LICENSE file for details.