Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,113 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from synthscope import GoogleSearchImageGen
|
| 3 |
|
| 4 |
-
with gr.Blocks(theme=gr.themes.Default(primary_hue=
|
| 5 |
-
css="
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
with gr.Row():
|
| 10 |
with gr.Column(scale=1):
|
| 11 |
-
gr.
|
| 12 |
-
text_output = gr.Markdown(height=
|
| 13 |
with gr.Column(scale=1):
|
| 14 |
-
gr.
|
| 15 |
-
image_output = gr.Image(label="", show_label=False,height=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
with gr.
|
| 18 |
-
with gr.
|
| 19 |
-
text_input = gr.Textbox(
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|
| 29 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from synthscope import GoogleSearchImageGen
|
| 3 |
|
| 4 |
+
with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="amber"),
|
| 5 |
+
css="""
|
| 6 |
+
footer {display: none !important;}
|
| 7 |
+
.audio-container {
|
| 8 |
+
padding: 10px;
|
| 9 |
+
border-radius: 8px;
|
| 10 |
+
background: rgba(0,0,0,0.02);
|
| 11 |
+
}
|
| 12 |
+
.audio-container audio {
|
| 13 |
+
width: 100%;
|
| 14 |
+
height: 60px;
|
| 15 |
+
border-radius: 6px;
|
| 16 |
+
}
|
| 17 |
+
.output-section {
|
| 18 |
+
margin-bottom: 20px;
|
| 19 |
+
padding: 15px;
|
| 20 |
+
border-radius: 20px;
|
| 21 |
+
background: rgba(255,255,255,0.5);
|
| 22 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 23 |
+
}
|
| 24 |
+
.input-section {
|
| 25 |
+
padding: 20px;
|
| 26 |
+
background: rgba(0,150,136,0.05);
|
| 27 |
+
border-radius: 20px;
|
| 28 |
+
margin-top: 20px;
|
| 29 |
+
}
|
| 30 |
+
.section-title {
|
| 31 |
+
color: #00695c;
|
| 32 |
+
font-weight: bold;
|
| 33 |
+
margin-bottom: 10px;
|
| 34 |
+
font-size: 1.1em;
|
| 35 |
+
}
|
| 36 |
+
""") as app:
|
| 37 |
+
|
| 38 |
+
gr.HTML("<div style='text-align:center;overflow:hidden;padding:20px;'><h1 style='color:#00695c;'>π SynthScope π¨</h1><p style='color:#666;'>Search, Visualize, and Listen to Information</p></div>")
|
| 39 |
+
|
| 40 |
+
# Output Section
|
| 41 |
+
with gr.Column(elem_classes="output-section"):
|
| 42 |
+
gr.HTML("<div class='section-title'>π Search Results</div>")
|
| 43 |
+
|
| 44 |
+
# Text and Image in a row
|
| 45 |
with gr.Row():
|
| 46 |
with gr.Column(scale=1):
|
| 47 |
+
gr.HTML("<h4 style='color:#00695c; margin-bottom:10px;'>π Text Summary</h4>")
|
| 48 |
+
text_output = gr.Markdown(height=320, container=True)
|
| 49 |
with gr.Column(scale=1):
|
| 50 |
+
gr.HTML("<h4 style='color:#00695c; margin-bottom:10px;'>π¨ Generated Image</h4>")
|
| 51 |
+
image_output = gr.Image(label="", show_label=False, height=320, container=True)
|
| 52 |
+
|
| 53 |
+
# Audio in its own row with proper spacing
|
| 54 |
+
with gr.Row():
|
| 55 |
+
with gr.Column():
|
| 56 |
+
gr.HTML("<h4 style='color:#00695c; margin-bottom:10px;'>π Audio Narration</h4>")
|
| 57 |
+
audio_output = gr.Audio(
|
| 58 |
+
label="",
|
| 59 |
+
type="filepath",
|
| 60 |
+
show_label=False,
|
| 61 |
+
elem_classes="audio-container",
|
| 62 |
+
interactive=False
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
# Input Section
|
| 66 |
+
with gr.Column(elem_classes="input-section"):
|
| 67 |
+
gr.HTML("<div class='section-title'>π§ Controls</div>")
|
| 68 |
|
| 69 |
+
with gr.Row():
|
| 70 |
+
with gr.Column(scale=2):
|
| 71 |
+
text_input = gr.Textbox(
|
| 72 |
+
label="π Search Query",
|
| 73 |
+
placeholder="Enter your search query here...",
|
| 74 |
+
lines=2
|
| 75 |
+
)
|
| 76 |
+
with gr.Column(scale=1):
|
| 77 |
+
dropdown_input = gr.Dropdown(
|
| 78 |
+
label="π€Select Voice",
|
| 79 |
+
choices=["Kore", "Zephyr", "Orus", "Fenrir", "Charon", "Umbriel", "Schedar", "Iapetus", "Puck", "Gacrux"],
|
| 80 |
+
value="Kore"
|
| 81 |
+
)
|
| 82 |
+
with gr.Column(scale=1):
|
| 83 |
+
radio_input = gr.Radio(
|
| 84 |
+
label="π¨ Image Style",
|
| 85 |
+
choices=["Comic", "Cartoon", "3D", "Anime", "Ghibli", "Victorian", "Movie", "Star Wars", "Marvel"],
|
| 86 |
+
value="Comic"
|
| 87 |
+
)
|
| 88 |
|
| 89 |
+
with gr.Row():
|
| 90 |
+
with gr.Column(scale=1):
|
| 91 |
+
btn = gr.Button(
|
| 92 |
+
"π Run SynthScope",
|
| 93 |
+
variant="primary",
|
| 94 |
+
size="lg"
|
| 95 |
+
)
|
| 96 |
+
with gr.Column(scale=1):
|
| 97 |
+
clear_btn = gr.ClearButton(
|
| 98 |
+
[text_input, radio_input, text_output, image_output, audio_output],
|
| 99 |
+
value="ποΈ Clear All",
|
| 100 |
+
variant="secondary",
|
| 101 |
+
size="lg"
|
| 102 |
+
)
|
| 103 |
|
| 104 |
+
# Event handlers
|
| 105 |
+
btn.click(
|
| 106 |
+
fn=GoogleSearchImageGen,
|
| 107 |
+
inputs=[text_input, radio_input, dropdown_input],
|
| 108 |
+
outputs=[text_output, image_output, audio_output],
|
| 109 |
+
show_progress=True
|
| 110 |
+
)
|
| 111 |
|
| 112 |
if __name__ == "__main__":
|
| 113 |
app.launch()
|