How reteps/real-time-lyrics works
1. Repository shape
- This is a small Python application, not a multi-service system.
- The architecture is centered around two runnable CLI entry points:
- acrcloud_cmdline.py
- lyrics_spotify_camera.py
- fads.py appears to hold shared helper logic used by one or both flows.
2. Primary runtime
- Everything runs locally under Python 3.
- Dependencies are installed via requirements.txt.
- Configuration is environment-driven, with credentials for external services supplied through env vars such as ACR_ACCESS_KEY, ACR_ACCESS_SECRET, SPOTIFY_ID, and SPOTIFY_SECRET.
3. Workflow A: microphone → recognition → lyric lookup
- acrcloud_cmdline.py implements the main “real time lyric detection” path.
- The local machine records audio from the microphone, writes the captured sample to out.wav, then sends the audio to ACRCloud for song identification.
- After a track is identified, the program looks up lyric timing data from LRC lyric sources to map recognized song sections to synchronized lyrics.
4. Workflow B: Spotify → camera/overlay
- lyrics_spotify_camera.py is a separate flow focused on whatever song is currently playing in Spotify.
- It uses Spotify API credentials to identify the current track.
- The readme indicates it then creates a camera feed via OBS-Camera with lyrics, so the output boundary is a video/camera integration rather than just terminal output.
5. External service boundaries
- ACRCloud is the audio recognition boundary for the microphone-based path.
- Spotify API is the track-detection boundary for the camera/overlay path.
- LRC lyric sites are the lyric-source boundary, used after song identification to fetch timed lyrics.
- These are the main remote dependencies that determine the app’s behavior.
6. Local data flow and artifacts
- The app writes transient files into the working directory:
- out.wav for the captured audio sample
- logs/res_dump.json for the recognition response dump
- These files are important operational artifacts, not core domain data stores.
- The presence of logs/ suggests the system is mostly stateless between runs aside from debug/trace output.
7. Likely internal layering
- The code is probably organized as:
- CLI orchestration scripts at the top
- helper/utilities in fads.py
- external API calls for recognition and metadata lookup
- lyric/timing parsing and display logic
- There is no sign of a database, web server, queue, or background worker architecture.
8. Core domain behavior
- The domain problem is synchronizing lyrics to a currently playing song.
- The hard part is not just retrieving lyrics, but aligning them to the correct track segment after recognition.
- The readme’s bug notes show that recognition confidence and lyric timing alignment are central concerns.
9. Operational constraints and failure modes
- Recognition quality affects the whole pipeline: if ACRCloud matches the wrong snippet or a chorus from the wrong section, lyric timing can drift.
- The system also depends on the quality of lyric text returned by external LRC sources; heavily censored lyrics can reduce recoverability.
- This means the architecture is sensitive to upstream metadata quality rather than internal persistence.
10. What to draw in an architecture diagram
- Draw a local Python CLI application split into two entry points.
- Show a microphone input path feeding ACRCloud, then lyric lookup, then local output.
- Show a Spotify-based path feeding lyric display through OBS-Camera.
- Put ACRCloud, Spotify, and LRC lyric sites outside the app boundary.
- Show out.wav and logs/res_dump.json as local scratch/debug artifacts.
11. Repository-level takeaway
- This repo is a thin client/orchestrator around third-party audio, music metadata, and lyric services.
- It does not appear to own a durable backend; its value is in coordinating recognition, lookup, and presentation of synchronized lyrics in real time.
Main entry points: acrcloud_cmdline.py ACRCloud CLI · lyrics_spotify_camera.py Spotify camera · fads.py Shared helpers · requirements.txt Dependencies
Components 14
Local app
Python CLI application and runtime artifacts
- ACRCloud CLI · Main microphone-to-lyrics command line flow
acrcloud_cmdline.py - Spotify camera · Spotify-driven lyrics overlay flow
lyrics_spotify_camera.py - Shared helpers · Common support logic used by the CLI flows
fads.py - Microphone · Local live audio capture source
- out.wav · Transient captured audio sample
out.wav - res_dump.json · Recognition response dump under logs/
logs/res_dump.json - Lyric sync · Maps identified songs to timed lyric sections
- OBS camera · Camera/feed integration used for lyric display
- Env config · ACR and Spotify credentials provided via environment variables
- Dependencies · Runtime dependencies installed from requirements.txt
requirements.txt - README · Project notes and workflow description
readme.md
External services
Remote APIs and lyric sources
- ACRCloud · Remote song identification service
- Spotify API · Remote track and playback metadata service
- LRC sources · Timed lyric sites used after recognition
Connections 18
- ACRCloud CLI → Microphone: records · Captures live audio from the microphone
- Microphone → out.wav: writes · Stores the captured sample as a WAV file
- ACRCloud CLI → ACRCloud: recognizes · Sends captured audio for song identification
- ACRCloud CLI → res_dump.json: logs · Writes recognition response for inspection
- ACRCloud CLI → LRC sources: fetches lyrics · Uses identified track info to retrieve timed lyrics
- LRC sources → Lyric sync: provides timing · Supplies lyric text and timestamps
- ACRCloud CLI → Lyric sync: aligns · Maps recognition results to synchronized lyric sections
- Spotify camera → Spotify API: reads track · Uses Spotify credentials to detect the current song
- Spotify camera → Lyric sync: syncs lyrics · Aligns current track with lyric timing for display
- Spotify camera → OBS camera: outputs · Feeds lyrics into the camera/overlay integration
- Shared helpers → ACRCloud CLI: supports · Shared helper logic used by the microphone flow
- Shared helpers → Spotify camera: supports · Shared helper logic used by the Spotify flow
- Env config → ACRCloud: configures · Provides ACRCloud access credentials
- Env config → Spotify API: configures · Provides Spotify API credentials
- Dependencies → ACRCloud CLI: installs · Declares runtime dependencies for the CLI app
- Dependencies → Spotify camera: installs · Declares runtime dependencies for the CLI app
- README → ACRCloud CLI: documents · Describes the real-time lyric detection flow
- README → Spotify camera: documents · Describes the Spotify-to-camera flow