Ifeanyi commited on
Commit
13c94ac
Β·
verified Β·
1 Parent(s): 4c440f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +101 -17
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=gr.themes.colors.red, secondary_hue=gr.themes.colors.pink),
5
- css="footer {display: none !important;}") as app:
6
- gr.HTML("<div style='text-align:center;overflow:hidden;'><h2>&#127760; SynthScope &#127912;</h2></div>")
7
-
8
- with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  with gr.Row():
10
  with gr.Column(scale=1):
11
- gr.Markdown("<h4>Google Search Result</h4>")
12
- text_output = gr.Markdown(height=300)
13
  with gr.Column(scale=1):
14
- gr.Markdown("<h4>Search Result Image</h4>")
15
- image_output = gr.Image(label="", show_label=False,height=300)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- with gr.Column():
18
- with gr.Row():
19
- text_input = gr.Textbox(label="Query Field", placeholder="Type in your search query")
20
- radio_input = gr.Radio(label="Select Search Result Image Style", choices=["Comic", "Cartoon", "3D", "Anime", "Ghibli", "Victorian"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- with gr.Row():
23
- btn = gr.Button("Run SynthScope")
24
- clear_btn = gr.ClearButton([text_input, radio_input, text_output, image_output], value="Clear")
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- btn.click(fn=GoogleSearchImageGen, inputs=[text_input, radio_input], outputs=[text_output, image_output])
 
 
 
 
 
 
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()