Update app.py
Browse files
app.py
CHANGED
@@ -127,10 +127,14 @@ def toggle_hint_mode():
|
|
127 |
)
|
128 |
import gradio as gr
|
129 |
|
130 |
-
with gr.Blocks(title="Kasoti") as demo:
|
131 |
-
gr.Markdown(
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
134 |
|
135 |
with gr.Row():
|
136 |
start = gr.Button("🎲 Start Game", scale=1)
|
@@ -139,45 +143,24 @@ with gr.Blocks(title="Kasoti") as demo:
|
|
139 |
|
140 |
with gr.Row():
|
141 |
with gr.Column(scale=1):
|
142 |
-
gr.Markdown("### 🎤
|
143 |
-
lang_sel = gr.CheckboxGroup(["English", "Urdu"], label="
|
144 |
-
mic_input = gr.Audio(sources=["microphone"], type="numpy", label="
|
145 |
-
transcribe = gr.Button("
|
146 |
-
typed_ans = gr.Textbox(label="✍️ Or
|
147 |
-
submit = gr.Button("✅ Submit
|
148 |
|
149 |
with gr.Column(scale=2):
|
150 |
-
gr.Markdown("### 🎮 Game
|
151 |
-
game_q_box = gr.Textbox(label="
|
152 |
-
game_history = gr.Textbox(label="🧾
|
153 |
-
final_answer_box = gr.Textbox(label="🎯 Final
|
154 |
-
|
155 |
-
# Button
|
156 |
-
start.click(
|
157 |
-
|
158 |
-
|
159 |
-
)
|
160 |
-
|
161 |
-
hint_toggle.click(
|
162 |
-
fn=toggle_hint_mode,
|
163 |
-
outputs=[hint_status, game_history]
|
164 |
-
)
|
165 |
-
|
166 |
-
hint_toggle.click(
|
167 |
-
fn=hint_response,
|
168 |
-
outputs=[game_history]
|
169 |
-
)
|
170 |
-
|
171 |
-
transcribe.click(
|
172 |
-
fn=convert_audio_to_text,
|
173 |
-
inputs=[mic_input, lang_sel],
|
174 |
-
outputs=[typed_ans]
|
175 |
-
)
|
176 |
-
|
177 |
-
submit.click(
|
178 |
-
fn=interpret_answer,
|
179 |
-
inputs=[typed_ans],
|
180 |
-
outputs=[game_q_box, typed_ans, final_answer_box, game_history, final_answer_box]
|
181 |
-
)
|
182 |
|
183 |
demo.launch()
|
|
|
127 |
)
|
128 |
import gradio as gr
|
129 |
|
130 |
+
with gr.Blocks(title="Kasoti", theme=gr.themes.Soft(primary_hue="pink", secondary_hue="blue")) as demo:
|
131 |
+
gr.Markdown(
|
132 |
+
"""
|
133 |
+
<div style='text-align: center; font-size: 28px; font-weight: bold; color: #ff69b4;'>🧠 Kasoti - Let's Play a Mind Game!</div>
|
134 |
+
<p style='text-align: center; color: #666;'>Think of something mysterious and I'll try to guess it in 20 fun questions! 🕵️♀️<br>
|
135 |
+
Just answer with <b>yes/no</b> or <b>ہاں/نہیں</b>.</p>
|
136 |
+
""",
|
137 |
+
)
|
138 |
|
139 |
with gr.Row():
|
140 |
start = gr.Button("🎲 Start Game", scale=1)
|
|
|
143 |
|
144 |
with gr.Row():
|
145 |
with gr.Column(scale=1):
|
146 |
+
gr.Markdown("### 🎤 Your Answer")
|
147 |
+
lang_sel = gr.CheckboxGroup(["English", "Urdu"], label="🌐 Choose Language", value=["English"])
|
148 |
+
mic_input = gr.Audio(sources=["microphone"], type="numpy", label="🎙️ Speak Your Answer")
|
149 |
+
transcribe = gr.Button("📝 Transcribe Voice")
|
150 |
+
typed_ans = gr.Textbox(label="✍️ Or Type Your Answer")
|
151 |
+
submit = gr.Button("✅ Submit")
|
152 |
|
153 |
with gr.Column(scale=2):
|
154 |
+
gr.Markdown("### 🎮 Game Progress")
|
155 |
+
game_q_box = gr.Textbox(label="❓ Current Question", interactive=False, lines=2)
|
156 |
+
game_history = gr.Textbox(label="🧾 Game Updates", interactive=False, lines=3)
|
157 |
+
final_answer_box = gr.Textbox(label="🎯 My Final Guess!", visible=False, lines=2, interactive=False)
|
158 |
+
|
159 |
+
# Button functionality
|
160 |
+
start.click(fn=begin_game, outputs=[game_q_box, game_history, final_answer_box, submit, final_answer_box])
|
161 |
+
hint_toggle.click(fn=toggle_hint_mode, outputs=[hint_status, game_history])
|
162 |
+
hint_toggle.click(fn=hint_response, outputs=[game_history])
|
163 |
+
transcribe.click(fn=convert_audio_to_text, inputs=[mic_input, lang_sel], outputs=[typed_ans])
|
164 |
+
submit.click(fn=interpret_answer, inputs=[typed_ans], outputs=[game_q_box, typed_ans, final_answer_box, game_history, final_answer_box])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
demo.launch()
|