Spaces:
Running
Running
CuddleBuddys
commited on
Commit
•
e0566c0
1
Parent(s):
02c59ad
Update openvoice_app.py
Browse files- openvoice_app.py +66 -35
openvoice_app.py
CHANGED
@@ -116,43 +116,74 @@ def predict(prompt, style, audio_file_pth, voice_name, customer_email):
|
|
116 |
|
117 |
return text_hint, save_path, audio_file_pth
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
# Gradio interface setup
|
120 |
with gr.Blocks(gr.themes.Glass()) as demo:
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
demo.queue()
|
158 |
demo.launch(debug=True, show_api=False, share=args.share)
|
|
|
116 |
|
117 |
return text_hint, save_path, audio_file_pth
|
118 |
|
119 |
+
# Consent agreement text
|
120 |
+
CONSENT_TEXT = """
|
121 |
+
By using this app, you agree to the following:
|
122 |
+
|
123 |
+
1. This app is intended for use only with CuddleBuddy products.
|
124 |
+
2. CuddleBuddy and any of its partners are not responsible for any misuse of this app or its output.
|
125 |
+
3. You will not use this app for any illegal or unethical purposes.
|
126 |
+
4. You understand that the voice cloning technology should be used responsibly and with respect for others' privacy and rights.
|
127 |
+
|
128 |
+
Do you agree to these terms?
|
129 |
+
"""
|
130 |
+
|
131 |
+
# Function to handle consent
|
132 |
+
def handle_consent(agree):
|
133 |
+
if agree:
|
134 |
+
return gr.update(visible=True), gr.update(visible=False)
|
135 |
+
else:
|
136 |
+
return gr.update(visible=False), gr.update(visible=True)
|
137 |
+
|
138 |
# Gradio interface setup
|
139 |
with gr.Blocks(gr.themes.Glass()) as demo:
|
140 |
+
consent_view = gr.Column(visible=True)
|
141 |
+
main_view = gr.Column(visible=False)
|
142 |
+
|
143 |
+
with consent_view:
|
144 |
+
gr.Markdown("# Consent Agreement")
|
145 |
+
gr.Markdown(CONSENT_TEXT)
|
146 |
+
agree_button = gr.Button("I Agree")
|
147 |
+
disagree_button = gr.Button("I Disagree")
|
148 |
+
|
149 |
+
with main_view:
|
150 |
+
with gr.Row():
|
151 |
+
with gr.Column():
|
152 |
+
input_text_gr = gr.Textbox(
|
153 |
+
label="Create This",
|
154 |
+
info="One or two sentences at a time is better. Up to 200 text characters.",
|
155 |
+
value="He hoped there would be stew for dinner, turnips and carrots and bruised potatoes and fat mutton pieces to be ladled out in thick, peppered, flour-fattened sauce.",
|
156 |
+
)
|
157 |
+
style_gr = gr.Dropdown(
|
158 |
+
label="Style",
|
159 |
+
choices=['default', 'whispering', 'cheerful', 'terrified', 'angry', 'sad', 'friendly'],
|
160 |
+
info="Please upload a reference audio file that is at least 1 minute long. For best results, ensure the audio is clear. You can use Adobe Podcast Enhance(https://podcast.adobe.com/enhance) to improve the audio quality before uploading.",
|
161 |
+
max_choices=1,
|
162 |
+
value="default",
|
163 |
+
)
|
164 |
+
ref_gr = gr.Audio(
|
165 |
+
label="Original Audio",
|
166 |
+
type="filepath",
|
167 |
+
sources=["upload"],
|
168 |
+
)
|
169 |
+
voice_name_gr = gr.Textbox(
|
170 |
+
label="Your name and Product you bought",
|
171 |
+
value="Sam"
|
172 |
+
)
|
173 |
+
customer_email_gr = gr.Textbox(
|
174 |
+
label="Your Email",
|
175 |
+
info="We'll send you a downloadable file to this email address."
|
176 |
+
)
|
177 |
+
tts_button = gr.Button("Start", elem_id="send-btn", visible=True)
|
178 |
+
|
179 |
+
with gr.Column():
|
180 |
+
out_text_gr = gr.Text(label="Info")
|
181 |
+
audio_gr = gr.Audio(label="Replicated Sound", autoplay=True)
|
182 |
+
ref_audio_gr = gr.Audio(label="Original Audio Used ")
|
183 |
+
|
184 |
+
agree_button.click(handle_consent, inputs=[gr.Boolean(True)], outputs=[main_view, consent_view])
|
185 |
+
disagree_button.click(handle_consent, inputs=[gr.Boolean(False)], outputs=[main_view, consent_view])
|
186 |
+
tts_button.click(predict, [input_text_gr, style_gr, ref_gr, voice_name_gr, customer_email_gr], outputs=[out_text_gr, audio_gr, ref_audio_gr])
|
187 |
|
188 |
demo.queue()
|
189 |
demo.launch(debug=True, show_api=False, share=args.share)
|