ankban commited on
Commit
6b0a0bf
Β·
verified Β·
1 Parent(s): d8a53c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -12
app.py CHANGED
@@ -13,6 +13,8 @@ os.environ["HF_HOME"] = "/data/hf"
13
  os.environ["TRANSFORMERS_CACHE"] = "/data/hf"
14
  os.environ["XDG_CACHE_HOME"] = "/data/hf"
15
 
 
 
16
  # Load Whisper and set OpenAI key
17
  model = WhisperModel("base", compute_type="int8") # Fastest CPU option
18
  openai.api_key = os.getenv("OPENAI_API_KEY")
@@ -93,18 +95,28 @@ def tutor_feedback(audio_file):
93
  return transcript, feedback_text, mp3_path
94
 
95
  # Gradio interface
96
- iface = gr.Interface(
97
- fn=tutor_feedback,
98
- inputs=gr.Audio(type="filepath", label="🎀 Upload or record your response"),
99
- outputs=[
100
- gr.Textbox(label="πŸ“ Transcript"),
101
- gr.Textbox(label="πŸ“’ Tutor Feedback"),
102
- gr.Audio(label="πŸ”Š Spoken Feedback", type="filepath")
103
- ],
104
- title="πŸ—£ Communications Tutor with Whisper + GPT",
105
- description="Speak or upload a response. The tutor will transcribe it, analyze with GPT, and respond with spoken feedback.",
106
- allow_flagging="never"
107
- )
 
 
 
 
 
 
 
 
 
 
108
 
109
  if __name__ == "__main__":
110
  print("βœ… App is launching...")
 
13
  os.environ["TRANSFORMERS_CACHE"] = "/data/hf"
14
  os.environ["XDG_CACHE_HOME"] = "/data/hf"
15
 
16
+ chatter_owl_url = "file/images/chatter_owl.png"
17
+
18
  # Load Whisper and set OpenAI key
19
  model = WhisperModel("base", compute_type="int8") # Fastest CPU option
20
  openai.api_key = os.getenv("OPENAI_API_KEY")
 
95
  return transcript, feedback_text, mp3_path
96
 
97
  # Gradio interface
98
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="green")) as iface:
99
+ gr.Markdown(
100
+ f"""
101
+ <div style="text-align: center;">
102
+ <img src="{chatter_owl_url}" width="120">
103
+ <h2>πŸ¦‰ Hi, I'm <strong>Chatter the Owl</strong>!</h2>
104
+ <p>Let's practice your speaking! Tap the mic, say something, and I’ll give you tips to get even better! πŸŽ‰</p>
105
+ </div>
106
+ """,
107
+ elem_id="header"
108
+ )
109
+
110
+ with gr.Row():
111
+ audio_input = gr.Audio(type="filepath", label="🎀 Say something here!")
112
+
113
+ with gr.Row():
114
+ transcript_box = gr.Textbox(label="πŸ“– What you said")
115
+ feedback_box = gr.Textbox(label="πŸͺ„ Chatter's Feedback")
116
+
117
+ audio_output = gr.Audio(label="πŸ”Š Chatter's Voice Reply", type="filepath")
118
+
119
+ audio_input.change(fn=tutor_feedback, inputs=audio_input, outputs=[transcript_box, feedback_box, audio_output])
120
 
121
  if __name__ == "__main__":
122
  print("βœ… App is launching...")