Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,99 +1,44 @@
|
|
1 |
import gradio as gr
|
2 |
-
import sqlite3
|
3 |
import torch
|
4 |
import os
|
5 |
import zipfile
|
6 |
import requests
|
7 |
from TTS.api import TTS
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
# Define a button to share a model
|
48 |
-
share_button = gr.components.Button("Share Model")
|
49 |
-
|
50 |
-
# Define a dropdown menu to retrieve shared models
|
51 |
-
shared_models = get_shared_models()
|
52 |
-
model_dropdown = gr.components.Dropdown(choices=[], label="Shared Models")
|
53 |
-
|
54 |
-
# Define the clone function
|
55 |
-
def clone_with_dropdown(text, url, language, model_id):
|
56 |
-
# Retrieve the shared model from the database
|
57 |
-
cursor.execute("SELECT * FROM shared_models WHERE id=?", (model_id,))
|
58 |
-
model = cursor.fetchone()
|
59 |
-
if model:
|
60 |
-
# Call the clone function with the shared model URL
|
61 |
-
return clone(text, model[1], language)
|
62 |
-
else:
|
63 |
-
# Call the original clone function
|
64 |
-
return original_clone(text, url, language)
|
65 |
-
|
66 |
-
# Update the interface
|
67 |
-
iface = gr.Interface(fn=clone_with_dropdown,
|
68 |
-
inputs=[
|
69 |
-
gr.components.Text("", label="the text to be said"),
|
70 |
-
gr.components.Text("", label="URL of the zip file with the dataset on hf.co (10 seconds is fine)"),
|
71 |
-
gr.Dropdown(choices=languages, label="Language"),
|
72 |
-
community_links,
|
73 |
-
share_button,
|
74 |
-
model_dropdown
|
75 |
-
],
|
76 |
-
outputs=gr.Audio(type='filepath'),
|
77 |
-
title='Voice Clone',
|
78 |
-
description="""
|
79 |
-
by [Angetyde](https://youtube.com/@Angetyde?si=7nusP31nTumIkPTF) and [Tony Assi](https://www.tonyassi.com/ )
|
80 |
-
use this colab with caution <3.
|
81 |
-
""",
|
82 |
-
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate"))
|
83 |
-
|
84 |
-
# Define a function to handle the share button click event
|
85 |
-
def handle_share_button(text, url, language):
|
86 |
-
# Split the text into model name and URL
|
87 |
-
model_name, model_url = text.split(",")
|
88 |
-
# Store the shared model in the database
|
89 |
-
store_shared_model(model_url, model_name)
|
90 |
-
# Update the shared models list
|
91 |
-
shared_models = get_shared_models()
|
92 |
-
model_dropdown.update(choices=[(model[1], model[0]) for model in shared_models])
|
93 |
-
# Clear the textbox
|
94 |
-
community_links.update(value="")
|
95 |
-
|
96 |
-
# Connect the share button to the handle_share_button function
|
97 |
-
share_button.click(fn=handle_share_button, inputs=[community_links])
|
98 |
-
|
99 |
-
iface.launch(share=True, on_launch=get_shared_models)
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import torch
|
3 |
import os
|
4 |
import zipfile
|
5 |
import requests
|
6 |
from TTS.api import TTS
|
7 |
|
8 |
+
#... (rest of the code remains the same)
|
9 |
+
|
10 |
+
# Add a new section for model sharing
|
11 |
+
model_sharing_section = gr.components.Section("Model Sharing")
|
12 |
+
|
13 |
+
model_input = gr.components.Textbox(label="Share your model/link")
|
14 |
+
model_output = gr.components.Markdown(label="Shared Models")
|
15 |
+
|
16 |
+
model_sharing_iface = gr.Interface(
|
17 |
+
fn=lambda x: x, # dummy function to display the input
|
18 |
+
inputs=model_input,
|
19 |
+
outputs=model_output,
|
20 |
+
title="Share Your Model",
|
21 |
+
description="Share your model or link with the community!"
|
22 |
+
)
|
23 |
+
|
24 |
+
# Combine the two interfaces
|
25 |
+
iface = gr.Interface(
|
26 |
+
fn=clone,
|
27 |
+
inputs=[
|
28 |
+
gr.components.Text("", label="the text to be said"),
|
29 |
+
gr.components.Text("", label="URL of the zip file with the dataset on hf.co (10 seconds is fine)"),
|
30 |
+
gr.Dropdown(choices=languages, label="Language")
|
31 |
+
],
|
32 |
+
outputs=gr.Audio(type='filepath'),
|
33 |
+
title='Voice Clone',
|
34 |
+
description="""
|
35 |
+
by [Angetyde](https://youtube.com/@Angetyde?si=7nusP31nTumIkPTF) and [Tony Assi](https://www.tonyassi.com/ )
|
36 |
+
use this colab with caution <3.
|
37 |
+
""",
|
38 |
+
theme=gr.themes.Base(primary_hue="teal", secondary_hue="teal", neutral_hue="slate"),
|
39 |
+
tabs=["Voice Clone", "Model Sharing"]
|
40 |
+
)
|
41 |
+
|
42 |
+
iface.add_component(model_sharing_iface, "Model Sharing")
|
43 |
+
|
44 |
+
iface.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|