Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -126,7 +126,6 @@ def classify_and_track(files, budget):
|
|
| 126 |
c.drawText(textobject)
|
| 127 |
c.save()
|
| 128 |
|
| 129 |
-
# Return sound_path for hidden audio playback
|
| 130 |
return results, status_msg, receipt_text, percent, sound_path, pdf_path
|
| 131 |
|
| 132 |
def reset_ui():
|
|
@@ -189,16 +188,6 @@ h2 {{
|
|
| 189 |
font-family: 'Poppins', sans-serif;
|
| 190 |
}}
|
| 191 |
</style>
|
| 192 |
-
<script>
|
| 193 |
-
function playAudio(soundPath) {{
|
| 194 |
-
if (soundPath) {{
|
| 195 |
-
var audio = new Audio(soundPath);
|
| 196 |
-
audio.play().catch(function(error) {{
|
| 197 |
-
console.log("Audio playback error: ", error);
|
| 198 |
-
}});
|
| 199 |
-
}}
|
| 200 |
-
}}
|
| 201 |
-
</script>
|
| 202 |
"""
|
| 203 |
|
| 204 |
with gr.Blocks(title="Grocery Classifier") as app:
|
|
@@ -223,17 +212,17 @@ with gr.Blocks(title="Grocery Classifier") as app:
|
|
| 223 |
progress_bar = gr.Slider(label="Budget Used (%)", minimum=0, maximum=100, interactive=False)
|
| 224 |
receipt_display = gr.Markdown(label="🧾 Grocery Receipt")
|
| 225 |
download_receipt = gr.File(label="📥 Download Receipt PDF", interactive=False)
|
|
|
|
| 226 |
|
| 227 |
classify_btn.click(
|
| 228 |
fn=classify_and_track,
|
| 229 |
inputs=[file_input, budget_input],
|
| 230 |
-
outputs=[gallery, status_display, receipt_display, progress_bar,
|
| 231 |
-
_js="playAudio"
|
| 232 |
)
|
| 233 |
|
| 234 |
reset_btn.click(
|
| 235 |
fn=reset_ui,
|
| 236 |
-
outputs=[gallery, status_display, receipt_display, progress_bar,
|
| 237 |
)
|
| 238 |
|
| 239 |
app.launch()
|
|
|
|
| 126 |
c.drawText(textobject)
|
| 127 |
c.save()
|
| 128 |
|
|
|
|
| 129 |
return results, status_msg, receipt_text, percent, sound_path, pdf_path
|
| 130 |
|
| 131 |
def reset_ui():
|
|
|
|
| 188 |
font-family: 'Poppins', sans-serif;
|
| 189 |
}}
|
| 190 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
"""
|
| 192 |
|
| 193 |
with gr.Blocks(title="Grocery Classifier") as app:
|
|
|
|
| 212 |
progress_bar = gr.Slider(label="Budget Used (%)", minimum=0, maximum=100, interactive=False)
|
| 213 |
receipt_display = gr.Markdown(label="🧾 Grocery Receipt")
|
| 214 |
download_receipt = gr.File(label="📥 Download Receipt PDF", interactive=False)
|
| 215 |
+
audio_output = gr.Audio(interactive=False, autoplay=True, visible=False)
|
| 216 |
|
| 217 |
classify_btn.click(
|
| 218 |
fn=classify_and_track,
|
| 219 |
inputs=[file_input, budget_input],
|
| 220 |
+
outputs=[gallery, status_display, receipt_display, progress_bar, audio_output, download_receipt]
|
|
|
|
| 221 |
)
|
| 222 |
|
| 223 |
reset_btn.click(
|
| 224 |
fn=reset_ui,
|
| 225 |
+
outputs=[gallery, status_display, receipt_display, progress_bar, audio_output, download_receipt]
|
| 226 |
)
|
| 227 |
|
| 228 |
app.launch()
|