rahideer commited on
Commit
c099445
·
verified ·
1 Parent(s): 8309cc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -42
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("## 🧠 Kasoti")
132
- gr.Markdown("Think of something. I will try to guess it in 20 yes/no questions. "
133
- "Answer with **yes/no** or **ہاں/نہیں**.")
 
 
 
 
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("### 🎤 Input")
143
- lang_sel = gr.CheckboxGroup(["English", "Urdu"], label="Select Language", value=["English"])
144
- mic_input = gr.Audio(sources=["microphone"], type="numpy", label="Record Your Answer")
145
- transcribe = gr.Button("🎙️ Transcribe")
146
- typed_ans = gr.Textbox(label="✍️ Or type your answer")
147
- submit = gr.Button("✅ Submit Answer")
148
 
149
  with gr.Column(scale=2):
150
- gr.Markdown("### 🎮 Game Status")
151
- game_q_box = gr.Textbox(label="🧩 Current Question", interactive=False, lines=2)
152
- game_history = gr.Textbox(label="🧾 Hint / Status", interactive=False, lines=2)
153
- final_answer_box = gr.Textbox(label="🎯 Final Answer", visible=False, lines=2, interactive=False)
154
-
155
- # Button click events
156
- start.click(
157
- fn=begin_game,
158
- outputs=[game_q_box, game_history, final_answer_box, submit, final_answer_box]
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()