Datasets:
Tasks:
Audio Classification
Formats:
parquet
Size:
1K - 10K
ArXiv:
Tags:
arxiv:2606.01686
music
ai-generated-music
ai-generated-music-detection
plagiarism-detection
ace-step
License:
| #!/usr/bin/env python3 | |
| """Fill missing Lyria-3 tracks by retrying failed indices with backoff.""" | |
| import json, os, os, time, random | |
| from pathlib import Path | |
| from google import genai | |
| from google.genai import types | |
| API_KEY = os.environ["GOOGLE_API_KEY"] # set your own key | |
| OUT_DIR = Path("/ssd_data/dataset/haim_dataset/A_full_generation/A2_fake/lyria-pro3") | |
| TARGET = 6000 | |
| MAX_RETRIES = 5 | |
| PROMPTS = [ | |
| "An epic cinematic orchestral piece about a journey home. Starts with a solo piano intro, builds through sweeping strings, and climaxes with a massive wall of sound.", | |
| "A dreamy indie pop song about city nights. Soft synths and reverb-heavy guitars in the verse, building to a bright, anthemic chorus with layered vocals.", | |
| "A soulful R&B ballad about lost love. Warm Rhodes piano and gentle finger-picked guitar in the verse, swelling strings and harmonies in the chorus.", | |
| "An energetic K-pop dance track with punchy synth bass, crisp electronic drums, and catchy vocal hooks. Features a rap bridge and a high-energy final chorus.", | |
| "A melancholic folk song with fingerpicked acoustic guitar and soft harmonica. The singer tells a story of leaving a small town, with a bittersweet chorus.", | |
| "A high-energy punk rock anthem with distorted power chords, fast drums, and shouted vocals about rebellion and freedom.", | |
| "A smooth jazz vocal piece with walking bass, brushed drums, and a sultry saxophone solo between verses.", | |
| "A gospel choir performance with powerful organ chords, hand claps, and call-and-response vocals building to a triumphant climax.", | |
| "A reggae song with deep dub bass, offbeat guitar skanks, and laid-back vocals about sunshine and good vibes. Features an echo-drenched melodica solo.", | |
| "A country western ballad with steel guitar, acoustic strumming, and heartfelt lyrics about a long drive through open plains.", | |
| "An atmospheric ambient instrumental piece. Evolving synthesizer pads, distant piano notes, and subtle field recordings create a meditative soundscape. Instrumental only, no vocals.", | |
| "A funky instrumental groove with slap bass, wah-wah guitar, and tight horn stabs. Think 1970s funk band jamming. Instrumental only, no vocals.", | |
| "A classical string quartet performing a dramatic piece in D minor. Starts adagio with a melancholic cello melody, builds to an allegro with all four instruments in passionate dialogue. Instrumental only, no vocals.", | |
| "A lo-fi hip hop instrumental beat with dusty vinyl crackle, mellow Rhodes piano chords, and a lazy boom-bap drum pattern. Instrumental only, no vocals.", | |
| "An intense drum and bass track with rapid breakbeats, deep sub bass, and glitchy synth textures. Instrumental only, no vocals.", | |
| "A flamenco guitar solo piece with passionate rasgueado strumming, percussive golpe taps, and intricate picado runs. Instrumental only, no vocals.", | |
| "A minimalist techno track with hypnotic repetitive synth patterns, deep kick drum, and slowly evolving filter sweeps. Instrumental only, no vocals.", | |
| "A baroque harpsichord piece in the style of Bach, featuring intricate counterpoint and ornamental trills. Instrumental only, no vocals.", | |
| "An afrobeat instrumental jam with polyrhythmic percussion, driving bass guitar, and bright horn arrangements. Instrumental only, no vocals.", | |
| "A chiptune 8-bit video game soundtrack with energetic square wave melodies and arpeggiated basslines. Instrumental only, no vocals.", | |
| """[0:00 - 0:15] Intro: Soft acoustic guitar arpeggio with ambient reverb. | |
| [0:15 - 0:45] Verse 1: A male voice sings about walking through autumn leaves, accompanied by gentle piano and light percussion. | |
| [0:45 - 1:15] Chorus: Full band enters with drums, bass, and electric guitar. The melody soars with hope and nostalgia. | |
| [1:15 - 1:45] Verse 2: The texture thins back to guitar and voice, with added cello. | |
| [1:45 - 2:15] Chorus: Bigger and more emotional, with backing vocal harmonies. | |
| [2:15 - 2:30] Outro: Fade out with solo piano.""", | |
| """[0:00 - 0:10] Intro: Begin with a pulsing electronic bass and hi-hat pattern. | |
| [0:10 - 0:40] Verse: Dark, moody synth pads with a whispered vocal about neon-lit streets. | |
| [0:40 - 1:10] Chorus: Explosive drop with heavy bass, layered synths, and powerful vocals. | |
| [1:10 - 1:40] Bridge: Stripped back to just voice and a single synth pad, building tension. | |
| [1:40 - 2:10] Final Chorus: Even bigger than before with added vocal harmonies and orchestral hits. | |
| [2:10 - 2:20] Outro: The bass pulse fades into silence.""", | |
| "A romantic French chanson about a Parisian evening. Accordion, nylon guitar, and a warm baritone voice singing about love along the Seine river.", | |
| "A passionate Spanish flamenco pop song with acoustic guitar, cajon percussion, and a powerful female voice singing about heartbreak and resilience.", | |
| "A Japanese city pop track with groovy bass, bright electric piano, and smooth vocals. The style is reminiscent of 1980s Tokyo nightlife music.", | |
| "A Brazilian bossa nova piece with gentle nylon guitar, soft brushed drums, and a breathy vocal singing in Portuguese about a tropical sunset.", | |
| "A Korean ballad with emotional piano, sweeping string arrangement, and a powerful vocal performance building from intimate verse to soaring chorus.", | |
| "A Bollywood dance number with dhol drums, synthesizers, and energetic Hindi vocals. Features a catchy hook and a rhythmic breakdown.", | |
| "A traditional Irish folk song with tin whistle, bodhran drum, and a fiddle. A pub choir joins in the chorus with hearty harmonies.", | |
| "An Arabic song with oud, qanun, and darbuka percussion. A rich tenor voice sings an ornate melody with traditional maqam scales.", | |
| "A progressive rock epic that shifts between 7/8 and 4/4 time signatures. Features a Mellotron intro, complex guitar harmonies, a Hammond organ solo, and a thunderous drum fill leading into the final section.", | |
| "A trap beat with booming 808 bass, skittering hi-hat triplets, dark piano chords, and an Auto-Tuned vocal hook about late nights and ambition.", | |
| "A synthwave retro track with warm analog synth pads, gated reverb drums, and a driving arpeggiated bassline. The mood is nostalgic and cinematic, like driving through a neon city at night. Instrumental only, no vocals.", | |
| "A grunge rock song with heavily distorted guitars, a loose and powerful drum groove, and raw, anguished vocals about disillusionment. Quiet verse, loud chorus dynamic.", | |
| "A deep house track with a four-on-the-floor kick, warm filtered chords, a rolling bassline, and chopped vocal samples creating a hypnotic groove. Instrumental only, no vocals.", | |
| "A neo-soul piece with a jazzy chord progression on Wurlitzer electric piano, a pocket groove from bass and drums, and silky vocals with subtle runs and ad-libs.", | |
| "A psychedelic rock jam with wah-wah guitar, phaser effects, droning sitar, and swirling Leslie speaker organ. The song builds from a slow groove into a wild improvised climax. Instrumental only, no vocals.", | |
| "A new age meditation piece with Tibetan singing bowls, gentle synthesizer drones, and the sound of flowing water. Peaceful and transcendent. Instrumental only, no vocals.", | |
| "An EDM festival anthem starting with a filtered build-up, clapping rhythm, and pitched vocal chops, exploding into a massive supersaw drop with sidechained bass.", | |
| "A bluegrass jam with rapid banjo picking, fiddle, mandolin, and upright bass. The tempo is fast and the energy is infectious, with each instrument taking a solo break.", | |
| ] | |
| def main(): | |
| client = genai.Client(api_key=API_KEY) | |
| existing = {int(f.stem.split("_")[1]) for f in OUT_DIR.glob("lyria3_*.mp3")} | |
| missing = sorted(set(range(TARGET)) - existing) | |
| print(f"Missing: {len(missing)} tracks") | |
| if not missing: | |
| print("All 6000 tracks present!") | |
| return | |
| meta_path = OUT_DIR / "metadata_fill.jsonl" | |
| meta_f = open(meta_path, "a", encoding="utf-8") | |
| import threading | |
| from concurrent.futures import ThreadPoolExecutor, as_completed | |
| lock = threading.Lock() | |
| filled = 0 | |
| def generate_one(i): | |
| prompt = PROMPTS[i % len(PROMPTS)] | |
| fname = f"lyria3_{i:05d}.mp3" | |
| out_path = OUT_DIR / fname | |
| for attempt in range(MAX_RETRIES): | |
| try: | |
| response = client.models.generate_content( | |
| model="lyria-3-pro-preview", | |
| contents=prompt, | |
| config=types.GenerateContentConfig( | |
| response_modalities=["AUDIO", "TEXT"], | |
| ), | |
| ) | |
| lyrics = [] | |
| audio_data = None | |
| if response.parts: | |
| for part in response.parts: | |
| if part.text is not None: | |
| lyrics.append(part.text) | |
| elif part.inline_data is not None: | |
| audio_data = part.inline_data.data | |
| if audio_data: | |
| with open(out_path, "wb") as f: | |
| f.write(audio_data) | |
| meta = { | |
| "track_id": f"lyria3_{i:05d}", | |
| "filename": fname, | |
| "platform": "google_lyria3", | |
| "model_name": "Lyria-3 Pro", | |
| "model_version": "pro-preview", | |
| "prompt": prompt[:200], | |
| "lyrics": "\n".join(lyrics) if lyrics else None, | |
| "audio_size_bytes": len(audio_data), | |
| "collection_method": "generate", | |
| "generated_at": time.strftime("%Y-%m-%dT%H:%M:%S"), | |
| } | |
| with open(OUT_DIR / f"lyria3_{i:05d}.json", "w", encoding="utf-8") as jf: | |
| json.dump(meta, jf, ensure_ascii=False, indent=2) | |
| with lock: | |
| meta_f.write(json.dumps(meta, ensure_ascii=False) + "\n") | |
| meta_f.flush() | |
| return "ok" | |
| # Empty response, retry with backoff | |
| time.sleep(2 ** attempt) | |
| except Exception as e: | |
| time.sleep(2 ** attempt) | |
| if attempt == MAX_RETRIES - 1: | |
| return f"err:{e}" | |
| return "empty_after_retries" | |
| WORKERS = 5 | |
| with ThreadPoolExecutor(max_workers=WORKERS) as pool: | |
| futures = {pool.submit(generate_one, i): i for i in missing} | |
| for fut in as_completed(futures): | |
| result = fut.result() | |
| filled += 1 | |
| if filled % 20 == 0 or filled == len(missing): | |
| mp3s = len(list(OUT_DIR.glob("*.mp3"))) | |
| print(f"[{mp3s}/{TARGET}] filled={filled}/{len(missing)} last={result}") | |
| meta_f.close() | |
| final = len(list(OUT_DIR.glob("*.mp3"))) | |
| print(f"Done: {final}/{TARGET} tracks") | |
| if final < TARGET: | |
| print(f"Still missing {TARGET - final}. Run again to retry.") | |
| if __name__ == "__main__": | |
| main() | |