跳到正文
DEV Community· Bhavik Pahwa·· 1 天前AI 評分33

The Lazy Jukebox:離線生成趣味口述歌曲的 CLI 應用

Funny Songs 101

AI 導讀

The Lazy Jukebox 是一款完全離線的 CLI 應用,利用本地 AI 持續生成並播放趣味口述歌曲和 rap。它以 Ollama 運行 Llama 3.2 (1B) 撰寫歌詞,並用 Piper TTS 合成聲音、pydub 混音及 pygame 播放歌曲。應用以可在 8GB RAM、整合式顯示卡上運行為目標,無須雲端 API,作者稱營運成本為 $0。

正文

Bhavik Pahwa

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady

What I Built

I built The Lazy Jukebox (aka Endless Sloth FM). I often get bored of my own playlists, but finding new, entertaining music takes too much effort.

The Lazy Jukebox is a completely offline CLI application that endlesssly generates and plays funny, spoken-word "songs" and raps. You run the script once, sit back, and the machine handles all the creative thinking, lyric writing, vocal synthesis, and DJ mixing indefinitely. It saves you from the dreadful task of curating playlists while rewarding maximum laziness with infinite laughs.

Demo

Code

The Lazy Jukebox / Endless Sloth FM

Run once, sit back, and let a local AI DJ invent ridiculous spoken-word songs Wonderwords collides a noun, adjective, and everyday predicament; Ollama writes the lyrics; Piper speaks them; pydub mixes a beat; pygame plays the result while the next track is being made. No cloud API keys, subscriptions, or runtime downloads.

Setup

Use 64-bit Python 3.10–3.13. Python 3.13 is tested; Python 3.14 is not yet a supported target because audio dependencies may lack compatible wheels. Install Ollama and FFmpeg (both ffmpeg and ffprobe must be on PATH).

From this directory, on Windows PowerShell:

py -3.13 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
ollama pull llama3.2:1b
python -m piper.download_voices en_US-lessac-medium --data-dir voices

On macOS/Linux:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

…

How I Built It

I wanted this to run locally on lower-spec hardware (8GB RAM, integrated graphics), which meant heavy music generation models were out. Instead, I used a clever combination of lightweight open-source AI tools:

  1. Idea Engine: A Python "Concept Collider" using wonderwords pairs random adjectives/nouns with mundane activities (e.g., "A rap about a radioactive cabbage doing taxes").
  2. Lyric Generation: Ollama running locally with the lightweight Llama 3.2 (1B) model. It takes the prompt and instantly writes a 4-stanza comedy rap.
  3. Vocal Synthesis: Piper TTS, an insanely fast and low-resource neural text-to-speech engine optimized for CPUs. Using a highly expressive voice model, it speaks the lyrics like deadpan slam poetry.
  4. The DJ: Python's pydub mixes the generated vocals over local royalty-free .mp3 hip-hop beats, and pygame handles the endless playback loop. While one song plays, the next generates in the background!

Why Does Open Innovation Matter?

Open innovation is the only reason this project is possible. If I built an "endless" loop using closed-source APIs like OpenAI for text and ElevenLabs for voice, a few hours of laziness would bankrupt me in API costs!

By using open-weight models via Ollama and open-source local inference via Piper TTS, my app runs entirely offline, costs $0 to operate forever, and keeps my data completely private. Open AI makes infinite laziness affordable.

The Lazy Payoff

This app saves me the 20 minutes I usually waste skipping tracks on Spotify trying to find something fun. I ran it this weekend while cleaning my room, and the AI DJ entertained me for two hours straight without me ever touching the keyboard. Pure sloth perfection.

Prize Categories

  • Open-Source AI
  • Local AI Models

來源:DEV Community · dev.to