Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,66 @@
|
|
1 |
-
import
|
|
|
|
|
2 |
from pathlib import Path
|
3 |
|
4 |
-
|
5 |
-
|
|
|
6 |
|
7 |
-
|
8 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
"""
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
if __name__ == '__main__':
|
20 |
-
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import tempfile
|
4 |
from pathlib import Path
|
5 |
|
6 |
+
import gradio as gr
|
7 |
+
from huggingface_hub import duplicate_space, upload_folder
|
8 |
+
|
9 |
|
10 |
+
def configure_training(this_space_id, csv_data, character, do_extract_vocals=False):
|
11 |
+
character = character.strip().replace('-', '').replace('_', '').replace(" ", "").lower()
|
12 |
+
ds_cfg = {
|
13 |
+
"character": character,
|
14 |
+
"do_extract_vocals": do_extract_vocals,
|
15 |
+
}
|
16 |
+
with tempfile.TemporaryDirectory() as tempdir:
|
17 |
+
temp_path = Path(tempdir)
|
18 |
+
(temp_path / 'data.csv').write_text(csv_data)
|
19 |
+
(temp_path / 'dataset_config.csv').write_text(json.dumps(ds_cfg))
|
20 |
+
upload_folder(repo_id=this_space_id, folder_path=tempdir, path_in_repo=".", repo_type="space")
|
21 |
+
print("Would normally upload here!")
|
22 |
+
print(list(temp_path.glob("*")))
|
23 |
+
return "OK! Rebooting here in a sec to start training"
|
24 |
|
25 |
+
description = """
|
26 |
+
Configure training session for voice cloning.
|
27 |
|
28 |
+
Please provide a CSV containing YouTube IDs, start times, and end times that we can use to gather the dataset for you.
|
29 |
+
|
30 |
+
It should look like this:
|
31 |
+
|
32 |
+
```
|
33 |
+
ytid,start,end
|
34 |
+
YYiQxHM0L-w,300,660
|
35 |
+
Ga-CcToGiUM,3105,3300
|
36 |
+
```
|
37 |
"""
|
38 |
|
39 |
+
if os.environ.get("HF_TOKEN", None) is not None:
|
40 |
+
interface = gr.Interface(
|
41 |
+
configure_training,
|
42 |
+
inputs=[
|
43 |
+
gr.Textbox(label="This Space's Repo ID", info="The repo ID of this space (ex. nateraw/voice-cloning-training-ui)."),
|
44 |
+
gr.TextArea(value="ytid,start,end\n", label="CSV Data", max_lines=50),
|
45 |
+
gr.Textbox(placeholder="Name of character that you're cloning."),
|
46 |
+
gr.Checkbox(
|
47 |
+
False,
|
48 |
+
label="Isolate Vocals",
|
49 |
+
info="If checked, we use demucs to isolate vocals from each audio file. You want to use this if the provided clips contain background music"
|
50 |
+
)
|
51 |
+
],
|
52 |
+
outputs="text",
|
53 |
+
title="Configure Training Session",
|
54 |
+
description=description,
|
55 |
+
)
|
56 |
+
else:
|
57 |
+
with gr.Blocks() as interface:
|
58 |
+
gr.Markdown("""
|
59 |
+
## Please Set The HF_TOKEN Environment Variable
|
60 |
+
|
61 |
+
Go to the settings tab of this space and add a new environment variable named `HF_TOKEN` with its value being **a token with write access** from [here](https://hf.co/settings/tokens).
|
62 |
+
""")
|
63 |
+
|
64 |
|
65 |
if __name__ == '__main__':
|
66 |
+
interface.launch()
|