Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
# imports
|
2 |
import gradio as gr
|
3 |
import os
|
|
|
4 |
import requests
|
5 |
from transformers import pipeline
|
6 |
import torch
|
@@ -45,11 +46,10 @@ def transcribe(audio, language):
|
|
45 |
def save_feedback(audio_file, transcription, user_id, lang, env, device, domain, accuracy,
|
46 |
transcript_edit, orthography, orthography_issues,
|
47 |
meaning, meaning_loss, errors, error_examples, performance):
|
48 |
-
|
49 |
try:
|
50 |
with open(audio_file, "rb") as f:
|
51 |
audio_content = f.read()
|
52 |
-
|
53 |
metadata = {
|
54 |
"transcription": transcription,
|
55 |
"user_id": user_id,
|
@@ -67,12 +67,13 @@ def save_feedback(audio_file, transcription, user_id, lang, env, device, domain,
|
|
67 |
"error_examples": error_examples,
|
68 |
"performance": performance
|
69 |
}
|
70 |
-
|
71 |
files = {
|
72 |
"audio_file": ("audio.wav", audio_content, "audio/wav")
|
73 |
}
|
74 |
|
75 |
-
|
|
|
76 |
|
77 |
if response.status_code == 201:
|
78 |
return "✅ Feedback submitted successfully. Thank you!"
|
|
|
1 |
# imports
|
2 |
import gradio as gr
|
3 |
import os
|
4 |
+
import cloudscraper
|
5 |
import requests
|
6 |
from transformers import pipeline
|
7 |
import torch
|
|
|
46 |
def save_feedback(audio_file, transcription, user_id, lang, env, device, domain, accuracy,
|
47 |
transcript_edit, orthography, orthography_issues,
|
48 |
meaning, meaning_loss, errors, error_examples, performance):
|
|
|
49 |
try:
|
50 |
with open(audio_file, "rb") as f:
|
51 |
audio_content = f.read()
|
52 |
+
|
53 |
metadata = {
|
54 |
"transcription": transcription,
|
55 |
"user_id": user_id,
|
|
|
67 |
"error_examples": error_examples,
|
68 |
"performance": performance
|
69 |
}
|
70 |
+
|
71 |
files = {
|
72 |
"audio_file": ("audio.wav", audio_content, "audio/wav")
|
73 |
}
|
74 |
|
75 |
+
scraper = cloudscraper.create_scraper()
|
76 |
+
response = scraper.post(BACKEND_URL, data=metadata, files=files, timeout=20)
|
77 |
|
78 |
if response.status_code == 201:
|
79 |
return "✅ Feedback submitted successfully. Thank you!"
|