Sumit404 commited on
Commit
5fedfb2
·
verified ·
1 Parent(s): 117de54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -19
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 interface
40
- iface = gr.Interface(
41
- fn=[study_aid, submit_feedback],
42
- inputs=[
43
- [
44
- gr.Textbox(label="Question", placeholder="e.g., What is machine learning?"),
45
- gr.Textbox(label="Context (Lecture Notes)", placeholder="Paste your notes here..."),
46
- gr.Slider(12, 24, value=16, label="Font Size (px)"),
47
- gr.Checkbox(label="Generate Audio Output"),
48
- gr.Checkbox(label="Simplify Text")
49
- ],
50
- gr.Textbox(label="Feedback", placeholder="Report issues or suggestions...")
51
- ],
52
- outputs=["html", "audio", "text"],
53
- title="StudyBuddy: Accessible Study Aid for Neurodiverse Students",
54
- description="Ask questions about your college lecture notes with accessible text and audio outputs. No data is stored."
55
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
- iface.launch()
 
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()