kadirnar commited on
Commit
8eda1d3
Β·
verified Β·
1 Parent(s): 5f66bcf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +143 -0
app.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from vyvotts.audio_tokenizer import process_dataset
4
+
5
+ def process_dataset_ui(
6
+ original_dataset,
7
+ output_dataset,
8
+ model_type,
9
+ text_field,
10
+ hf_token
11
+ ):
12
+ """
13
+ Process dataset with Gradio UI.
14
+
15
+ Args:
16
+ original_dataset: HuggingFace dataset path to process
17
+ output_dataset: Output dataset path on HuggingFace Hub
18
+ model_type: Model type - either "qwen3" or "lfm2"
19
+ text_field: Name of text field in dataset
20
+ hf_token: HuggingFace token for authentication
21
+
22
+ Returns:
23
+ Status message
24
+ """
25
+ try:
26
+ # Set HuggingFace token
27
+ os.environ["HF_TOKEN"] = hf_token
28
+
29
+ # Validate inputs
30
+ if not original_dataset or not output_dataset:
31
+ return "❌ Error: Please provide both original and output dataset names"
32
+
33
+ if not hf_token:
34
+ return "❌ Error: Please provide a HuggingFace token"
35
+
36
+ if model_type not in ["qwen3", "lfm2"]:
37
+ return "❌ Error: Model type must be either 'qwen3' or 'lfm2'"
38
+
39
+ # Process dataset
40
+ process_dataset(
41
+ original_dataset=original_dataset,
42
+ output_dataset=output_dataset,
43
+ model_type=model_type,
44
+ text_field=text_field
45
+ )
46
+
47
+ return f"βœ… Dataset processed successfully and uploaded to: {output_dataset}"
48
+
49
+ except Exception as e:
50
+ return f"❌ Error: {str(e)}"
51
+
52
+ # Create Gradio interface
53
+ with gr.Blocks(title="VyvoTTS Dataset Tokenizer") as demo:
54
+ gr.Markdown("""
55
+ # πŸŽ™οΈ VyvoTTS Dataset Tokenizer
56
+
57
+ Process audio datasets for VyvoTTS training by tokenizing both audio and text.
58
+
59
+ ## Instructions:
60
+ 1. Enter your HuggingFace token (required for downloading and uploading datasets)
61
+ 2. Provide the original dataset path from HuggingFace Hub
62
+ 3. Specify the output dataset path where processed data will be uploaded
63
+ 4. Select the model type (Qwen3 or LFM2)
64
+ 5. Specify the text field name in your dataset
65
+ 6. Click "Process Dataset" to start
66
+
67
+ **Note:** This process requires a GPU and may take several minutes depending on dataset size.
68
+ """)
69
+
70
+ with gr.Row():
71
+ with gr.Column():
72
+ hf_token = gr.Textbox(
73
+ label="HuggingFace Token",
74
+ placeholder="hf_...",
75
+ type="password",
76
+ info="Your HuggingFace token for authentication"
77
+ )
78
+
79
+ original_dataset = gr.Textbox(
80
+ label="Original Dataset",
81
+ placeholder="MrDragonFox/Elise",
82
+ value="MrDragonFox/Elise",
83
+ info="HuggingFace dataset path to process"
84
+ )
85
+
86
+ output_dataset = gr.Textbox(
87
+ label="Output Dataset",
88
+ placeholder="username/dataset-name",
89
+ info="Output dataset path on HuggingFace Hub"
90
+ )
91
+
92
+ model_type = gr.Radio(
93
+ choices=["qwen3", "lfm2"],
94
+ value="qwen3",
95
+ label="Model Type",
96
+ info="Select the model type for tokenization"
97
+ )
98
+
99
+ text_field = gr.Textbox(
100
+ label="Text Field Name",
101
+ placeholder="text",
102
+ value="text",
103
+ info="Name of the text field in your dataset (e.g., 'text', 'text_scribe')"
104
+ )
105
+
106
+ process_btn = gr.Button("Process Dataset", variant="primary")
107
+
108
+ with gr.Column():
109
+ output = gr.Textbox(
110
+ label="Status",
111
+ placeholder="Status will appear here...",
112
+ lines=10
113
+ )
114
+
115
+ process_btn.click(
116
+ fn=process_dataset_ui,
117
+ inputs=[original_dataset, output_dataset, model_type, text_field, hf_token],
118
+ outputs=output
119
+ )
120
+
121
+ gr.Markdown("""
122
+ ## πŸ“ Example Values:
123
+
124
+ ### For Qwen3:
125
+ - **Original Dataset:** `MrDragonFox/Elise`
126
+ - **Output Dataset:** `username/elise-qwen3-processed`
127
+ - **Model Type:** `qwen3`
128
+ - **Text Field:** `text`
129
+
130
+ ### For LFM2:
131
+ - **Original Dataset:** `MrDragonFox/Elise`
132
+ - **Output Dataset:** `username/elise-lfm2-processed`
133
+ - **Model Type:** `lfm2`
134
+ - **Text Field:** `text`
135
+
136
+ ## ⚠️ Requirements:
137
+ - GPU with CUDA support
138
+ - HuggingFace account with write access
139
+ - Valid HuggingFace token
140
+ """)
141
+
142
+ if __name__ == "__main__":
143
+ demo.launch()