Update app.py
Browse files
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 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 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...")
|