Spaces:
Paused
Paused
koby commited on
Commit ·
f882299
1
Parent(s): d949cfd
uploads go to community bucket, bottom link to bucket
Browse files8 unmodified lines910111213141594 unmodified lines11011111211311411511611711811912012112212312412512612712812913013113213313413513613713874 unmodified lines2132142152162172182198 unmodified linesimport spacesimport torchCOMMUNITY_REPO = "directedbykobyperez/YuE2-community"REPO = "m-a-p/YuE2-3B"OUT = "/tmp/yue2_out"94 unmodified linesdef _upload_to_community(wav_path, meta_dict, song_id):"""Silently share songs/<id>/<id>.wav + meta.json to the dataset repo. Never raises."""token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_TOKEN")if not token:returntry:from huggingface_hub import HfApiapi = HfApi(token=token)meta_local = os.path.join(OUT, f"{song_id}_meta.json")with open(meta_local, "w", encoding="utf-8") as f:json.dump(meta_dict, f, ensure_ascii=False, indent=2)api.upload_file(path_or_fileobj=wav_path,path_in_repo=f"songs/{song_id}/{song_id}.wav",repo_id=COMMUNITY_REPO, repo_type="dataset",commit_message=f"add song {song_id}",)api.upload_file(path_or_fileobj=meta_local,path_in_repo=f"songs/{song_id}/meta.json",repo_id=COMMUNITY_REPO, repo_type="dataset",commit_message=f"add meta {song_id}",)print(f"[community] uploaded {song_id}")except Exception as e:print(f"[community] upload failed: {e}")74 unmodified linesduration.change(fn=_dur_label, inputs=duration, outputs=duration_txt)gr.Markdown("---\n🎶 **Community songs:** every generation is auto-shared to the ""[YuE2-community dataset](https://huggingface.co/datasets/directedbykobyperez/YuE2-community)"" · 🌐 [YuE2 website](https://map-yue2.github.io/)")8 unmodified lines91011121314151694 unmodified lines11111211311411511611711811912012112212312412512612712812913074 unmodified lines2052062072082092102118 unmodified linesimport spacesimport torchCOMMUNITY_BUCKET = "directedbykobyperez/YuE2-community"COMMUNITY_URL = "https://huggingface.co/buckets/directedbykobyperez/YuE2-community"REPO = "m-a-p/YuE2-3B"OUT = "/tmp/yue2_out"94 unmodified linesdef _upload_to_community(wav_path, meta_dict, song_id):"""Silently share songs/<id>/<id>.wav + meta.json to the community bucket. Never raises."""token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_TOKEN")if not token:returntry:from huggingface_hub import HfFileSystemfs = HfFileSystem(token=token)meta_local = os.path.join(OUT, f"{song_id}_meta.json")with open(meta_local, "w", encoding="utf-8") as f:json.dump(meta_dict, f, ensure_ascii=False, indent=2)base = f"buckets/{COMMUNITY_BUCKET}/songs/{song_id}"fs.put_file(wav_path, f"{base}/{song_id}.wav")fs.put_file(meta_local, f"{base}/meta.json")print(f"[community] uploaded {song_id} to bucket")except Exception as e:print(f"[community] upload failed: {e}")74 unmodified linesduration.change(fn=_dur_label, inputs=duration, outputs=duration_txt)gr.Markdown("---\n🎶 **Community songs:** every generation is auto-shared to the ""[YuE2-community bucket](https://huggingface.co/buckets/directedbykobyperez/YuE2-community)"" · 🌐 [YuE2 website](https://map-yue2.github.io/)")
app.py+10-18