Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
@@ -186,14 +186,17 @@ async def process_podcast(input_text, language, speaker1, speaker2, api_key):
|
|
186 |
custom_css = """
|
187 |
body {
|
188 |
background-color: #f0f8ff;
|
|
|
189 |
}
|
190 |
.gradio-container {
|
191 |
background-color: #f0f8ff;
|
192 |
border-radius: 20px;
|
193 |
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
|
|
194 |
}
|
195 |
.center-aligned {
|
196 |
text-align: center !important;
|
|
|
197 |
color: #ff4081;
|
198 |
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
|
199 |
}
|
@@ -203,6 +206,7 @@ body {
|
|
203 |
color: white !important;
|
204 |
font-weight: bold !important;
|
205 |
transition: all 0.3s ease !important;
|
|
|
206 |
}
|
207 |
.gen-button:hover {
|
208 |
background-color: #f50057 !important;
|
@@ -211,6 +215,7 @@ body {
|
|
211 |
.gr-input, .gr-box, .gr-dropdown {
|
212 |
border-radius: 10px !important;
|
213 |
border: 2px solid #ff4081 !important;
|
|
|
214 |
}
|
215 |
.gr-input:focus, .gr-box:focus, .gr-dropdown:focus {
|
216 |
border-color: #f50057 !important;
|
@@ -220,54 +225,67 @@ body {
|
|
220 |
background-color: #B7E0FF !important;
|
221 |
padding: 15px !important;
|
222 |
border-radius: 10px !important;
|
|
|
223 |
}
|
224 |
.lng-background {
|
225 |
background-color: #FFF5CD !important;
|
226 |
padding: 5px !important;
|
227 |
border-radius: 10px !important;
|
|
|
228 |
}
|
229 |
.sk1-background {
|
230 |
background-color: #FFF5CD !important;
|
231 |
padding: 5px !important;
|
232 |
border-radius: 10px !important;
|
|
|
233 |
}
|
234 |
.sk2-background {
|
235 |
background-color: #FFF5CD !important;
|
236 |
padding: 5px !important;
|
237 |
border-radius: 10px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
}
|
239 |
.api-background {
|
240 |
background-color: #FFCFB3 !important;
|
241 |
padding: 5px !important;
|
242 |
border-radius: 10px !important;
|
|
|
243 |
}
|
244 |
.audio-background {
|
245 |
background-color: #FFF4B5 !important;
|
246 |
padding: 5px !important;
|
247 |
border-radius: 10px !important;
|
|
|
248 |
}
|
249 |
.script-background {
|
250 |
background-color: #FEF9D9 !important;
|
251 |
padding: 15px !important;
|
252 |
border-radius: 10px !important;
|
|
|
253 |
}
|
254 |
"""
|
255 |
|
256 |
with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as iface:
|
257 |
gr.Markdown("# 🎙️ 自動生成 Podcast 節目及音檔。系統布署:江信宗。 🎙️", elem_classes="center-aligned")
|
258 |
-
|
259 |
input_text = gr.Textbox(label="請輸入 Podcast 話題(建議50~500字之間)", placeholder="輸入 Podcast 話題內容,越詳細劇本越佳......", elem_classes="input-background")
|
260 |
-
|
261 |
with gr.Row():
|
262 |
Language = gr.Dropdown(
|
263 |
-
choices=["繁體中文", "Auto Detect", "English", "日本語", "한국어"],
|
264 |
-
value="繁體中文",
|
265 |
label="語言",
|
266 |
interactive=True,
|
267 |
scale=1,
|
268 |
elem_classes="lng-background"
|
269 |
)
|
270 |
-
|
271 |
speaker_choices = [
|
272 |
"家豪 - 臺灣國語 (Male)",
|
273 |
"淑芬 - 臺灣國語 (Female)",
|
@@ -288,28 +306,31 @@ with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as iface:
|
|
288 |
"Remy - French (Male)",
|
289 |
"Vivienne - French (Female)"
|
290 |
]
|
291 |
-
|
292 |
Speaker_1 = gr.Dropdown(
|
293 |
-
choices=speaker_choices,
|
294 |
-
value="家豪 - 臺灣國語 (Male)",
|
295 |
label="主持人的語音",
|
296 |
interactive=True,
|
297 |
scale=2,
|
298 |
elem_classes="sk1-background"
|
299 |
)
|
300 |
Speaker_2 = gr.Dropdown(
|
301 |
-
choices=speaker_choices,
|
302 |
-
value="品妍 - 中文 (Female)",
|
303 |
label="來賓的語音",
|
304 |
interactive=True,
|
305 |
scale=2,
|
306 |
elem_classes="sk2-background"
|
307 |
)
|
308 |
-
|
|
|
|
|
|
|
309 |
with gr.Row():
|
310 |
generate_button = gr.Button("生成 Podcast 節目及音檔", scale=2, elem_classes="gen-button")
|
311 |
api_key = gr.Textbox(label="請輸入您的 API Key", type="password", placeholder="API authentication key for large language models", scale=1, elem_classes="api-background")
|
312 |
-
|
313 |
audio_output = gr.Audio(label="Generated Podcast Audio", elem_classes="audio-background")
|
314 |
podcast_script = gr.Textbox(label="Generated Podcast 劇本", elem_classes="script-background")
|
315 |
generate_button.click(fn=process_podcast, inputs=[input_text, Language, Speaker_1, Speaker_2, api_key], outputs=[podcast_script, audio_output])
|
@@ -318,4 +339,4 @@ if __name__ == "__main__":
|
|
318 |
if "SPACE_ID" in os.environ:
|
319 |
iface.launch()
|
320 |
else:
|
321 |
-
iface.launch(share=True, show_api=False)
|
|
|
186 |
custom_css = """
|
187 |
body {
|
188 |
background-color: #f0f8ff;
|
189 |
+
margin: 0 !important;
|
190 |
}
|
191 |
.gradio-container {
|
192 |
background-color: #f0f8ff;
|
193 |
border-radius: 20px;
|
194 |
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
195 |
+
margin: 0 !important;
|
196 |
}
|
197 |
.center-aligned {
|
198 |
text-align: center !important;
|
199 |
+
margin: 0 !important;
|
200 |
color: #ff4081;
|
201 |
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
|
202 |
}
|
|
|
206 |
color: white !important;
|
207 |
font-weight: bold !important;
|
208 |
transition: all 0.3s ease !important;
|
209 |
+
margin: 0 !important;
|
210 |
}
|
211 |
.gen-button:hover {
|
212 |
background-color: #f50057 !important;
|
|
|
215 |
.gr-input, .gr-box, .gr-dropdown {
|
216 |
border-radius: 10px !important;
|
217 |
border: 2px solid #ff4081 !important;
|
218 |
+
margin: 0 !important;
|
219 |
}
|
220 |
.gr-input:focus, .gr-box:focus, .gr-dropdown:focus {
|
221 |
border-color: #f50057 !important;
|
|
|
225 |
background-color: #B7E0FF !important;
|
226 |
padding: 15px !important;
|
227 |
border-radius: 10px !important;
|
228 |
+
margin: 0 !important;
|
229 |
}
|
230 |
.lng-background {
|
231 |
background-color: #FFF5CD !important;
|
232 |
padding: 5px !important;
|
233 |
border-radius: 10px !important;
|
234 |
+
margin: 0 !important;
|
235 |
}
|
236 |
.sk1-background {
|
237 |
background-color: #FFF5CD !important;
|
238 |
padding: 5px !important;
|
239 |
border-radius: 10px !important;
|
240 |
+
margin: 0 !important;
|
241 |
}
|
242 |
.sk2-background {
|
243 |
background-color: #FFF5CD !important;
|
244 |
padding: 5px !important;
|
245 |
border-radius: 10px !important;
|
246 |
+
margin: 0 !important;
|
247 |
+
}
|
248 |
+
.clear-button {
|
249 |
+
background-color: #FFF5CD !important;
|
250 |
+
padding: 5px !important;
|
251 |
+
border-radius: 10px !important;
|
252 |
+
margin: 0 !important;
|
253 |
}
|
254 |
.api-background {
|
255 |
background-color: #FFCFB3 !important;
|
256 |
padding: 5px !important;
|
257 |
border-radius: 10px !important;
|
258 |
+
margin: 0 !important;
|
259 |
}
|
260 |
.audio-background {
|
261 |
background-color: #FFF4B5 !important;
|
262 |
padding: 5px !important;
|
263 |
border-radius: 10px !important;
|
264 |
+
margin: 0 !important;
|
265 |
}
|
266 |
.script-background {
|
267 |
background-color: #FEF9D9 !important;
|
268 |
padding: 15px !important;
|
269 |
border-radius: 10px !important;
|
270 |
+
margin: 0 !important;
|
271 |
}
|
272 |
"""
|
273 |
|
274 |
with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as iface:
|
275 |
gr.Markdown("# 🎙️ 自動生成 Podcast 節目及音檔。系統布署:江信宗。 🎙️", elem_classes="center-aligned")
|
276 |
+
|
277 |
input_text = gr.Textbox(label="請輸入 Podcast 話題(建議50~500字之間)", placeholder="輸入 Podcast 話題內容,越詳細劇本越佳......", elem_classes="input-background")
|
278 |
+
|
279 |
with gr.Row():
|
280 |
Language = gr.Dropdown(
|
281 |
+
choices=["繁體中文", "Auto Detect", "English", "日本語", "한국어"],
|
282 |
+
value="繁體中文",
|
283 |
label="語言",
|
284 |
interactive=True,
|
285 |
scale=1,
|
286 |
elem_classes="lng-background"
|
287 |
)
|
288 |
+
|
289 |
speaker_choices = [
|
290 |
"家豪 - 臺灣國語 (Male)",
|
291 |
"淑芬 - 臺灣國語 (Female)",
|
|
|
306 |
"Remy - French (Male)",
|
307 |
"Vivienne - French (Female)"
|
308 |
]
|
309 |
+
|
310 |
Speaker_1 = gr.Dropdown(
|
311 |
+
choices=speaker_choices,
|
312 |
+
value="家豪 - 臺灣國語 (Male)",
|
313 |
label="主持人的語音",
|
314 |
interactive=True,
|
315 |
scale=2,
|
316 |
elem_classes="sk1-background"
|
317 |
)
|
318 |
Speaker_2 = gr.Dropdown(
|
319 |
+
choices=speaker_choices,
|
320 |
+
value="品妍 - 中文 (Female)",
|
321 |
label="來賓的語音",
|
322 |
interactive=True,
|
323 |
scale=2,
|
324 |
elem_classes="sk2-background"
|
325 |
)
|
326 |
+
|
327 |
+
clear_input_text_button = gr.Button("清除輸入文字", scale=1, elem_classes="clear-button")
|
328 |
+
clear_input_text_button.click(fn=lambda: "", inputs=None, outputs=input_text)
|
329 |
+
|
330 |
with gr.Row():
|
331 |
generate_button = gr.Button("生成 Podcast 節目及音檔", scale=2, elem_classes="gen-button")
|
332 |
api_key = gr.Textbox(label="請輸入您的 API Key", type="password", placeholder="API authentication key for large language models", scale=1, elem_classes="api-background")
|
333 |
+
|
334 |
audio_output = gr.Audio(label="Generated Podcast Audio", elem_classes="audio-background")
|
335 |
podcast_script = gr.Textbox(label="Generated Podcast 劇本", elem_classes="script-background")
|
336 |
generate_button.click(fn=process_podcast, inputs=[input_text, Language, Speaker_1, Speaker_2, api_key], outputs=[podcast_script, audio_output])
|
|
|
339 |
if "SPACE_ID" in os.environ:
|
340 |
iface.launch()
|
341 |
else:
|
342 |
+
iface.launch(share=True, show_api=False)
|