File size: 489 Bytes
e990dfa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from huggingface_hub import HfApi

HF_TOKEN = os.getenv("HF_TOKEN")
REPO_ID = "basyx/music-storage"

api = HfApi()

def upload_audio(filepath):

    if not HF_TOKEN:
        return None

    filename = os.path.basename(filepath)

    api.upload_file(
        path_or_fileobj=filepath,
        path_in_repo=filename,
        repo_id=REPO_ID,
        repo_type="dataset",
        token=HF_TOKEN
    )

    return f"https://huggingface.co/datasets/{REPO_ID}/resolve/main/{filename}"