Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,29 +29,49 @@ def study_aid(question, context, font_size=16, audio_output=False, simplify_text
|
|
| 29 |
audio = tts(answer)
|
| 30 |
return output, audio
|
| 31 |
|
| 32 |
-
return output
|
| 33 |
|
| 34 |
def submit_feedback(feedback):
|
| 35 |
with open("feedback.txt", "a") as f:
|
| 36 |
f.write(feedback + "\n")
|
| 37 |
return "Feedback submitted!"
|
| 38 |
|
| 39 |
-
# Create Gradio
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
gr.Textbox(label="
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
|
|
|
| 29 |
audio = tts(answer)
|
| 30 |
return output, audio
|
| 31 |
|
| 32 |
+
return output, None
|
| 33 |
|
| 34 |
def submit_feedback(feedback):
|
| 35 |
with open("feedback.txt", "a") as f:
|
| 36 |
f.write(feedback + "\n")
|
| 37 |
return "Feedback submitted!"
|
| 38 |
|
| 39 |
+
# Create Gradio app with Blocks
|
| 40 |
+
with gr.Blocks(title="StudyBuddy: Accessible Study Aid for Neurodiverse Students") as app:
|
| 41 |
+
gr.Markdown(
|
| 42 |
+
"""
|
| 43 |
+
# StudyBuddy: Accessible Study Aid for Neurodiverse Students
|
| 44 |
+
Ask questions about your college lecture notes with accessible text and audio outputs. No data is stored.
|
| 45 |
+
"""
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
# Tab 1: Study Aid
|
| 49 |
+
with gr.Tab("Ask a Question"):
|
| 50 |
+
question_input = gr.Textbox(label="Question", placeholder="e.g., What is machine learning?")
|
| 51 |
+
context_input = gr.Textbox(label="Context (Lecture Notes)", placeholder="Paste your notes here...")
|
| 52 |
+
font_size_input = gr.Slider(12, 24, value=16, label="Font Size (px)")
|
| 53 |
+
audio_output_input = gr.Checkbox(label="Generate Audio Output")
|
| 54 |
+
simplify_text_input = gr.Checkbox(label="Simplify Text")
|
| 55 |
+
study_submit_btn = gr.Button("Get Answer")
|
| 56 |
+
study_output_text = gr.HTML(label="Answer")
|
| 57 |
+
study_output_audio = gr.Audio(label="Audio Narration")
|
| 58 |
+
|
| 59 |
+
study_submit_btn.click(
|
| 60 |
+
fn=study_aid,
|
| 61 |
+
inputs=[question_input, context_input, font_size_input, audio_output_input, simplify_text_input],
|
| 62 |
+
outputs=[study_output_text, study_output_audio]
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
# Tab 2: Feedback
|
| 66 |
+
with gr.Tab("Submit Feedback"):
|
| 67 |
+
feedback_input = gr.Textbox(label="Feedback", placeholder="Report issues or suggestions...")
|
| 68 |
+
feedback_submit_btn = gr.Button("Submit Feedback")
|
| 69 |
+
feedback_output = gr.Text(label="Feedback Status")
|
| 70 |
+
|
| 71 |
+
feedback_submit_btn.click(
|
| 72 |
+
fn=submit_feedback,
|
| 73 |
+
inputs=feedback_input,
|
| 74 |
+
outputs=feedback_output
|
| 75 |
+
)
|
| 76 |
|
| 77 |
+
app.launch()
|