Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,15 +13,21 @@ from database_functions import add_user_privacy, add_submission
|
|
| 13 |
from tab_teachers_dashboard import create_teachers_dashboard_tab
|
| 14 |
from config import CLASS_OPTIONS
|
| 15 |
import spaces
|
| 16 |
-
from streaming_stt_nemo import Model
|
| 17 |
import edge_tts
|
| 18 |
import tempfile
|
| 19 |
|
| 20 |
# Load environment variables
|
| 21 |
load_dotenv()
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# For maintaining user session (to keep track of userID)
|
| 27 |
user_state = gr.State(value="")
|
|
@@ -33,11 +39,12 @@ image_path = "picturePerformance.jpg"
|
|
| 33 |
img_html = get_image_html(image_path)
|
| 34 |
|
| 35 |
@spaces.GPU(duration=120)
|
| 36 |
-
def transcribe(
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
@spaces.GPU(duration=120)
|
| 43 |
def generate_feedback(user_id, question_choice, strategy_choice, message, feedback_level):
|
|
|
|
| 13 |
from tab_teachers_dashboard import create_teachers_dashboard_tab
|
| 14 |
from config import CLASS_OPTIONS
|
| 15 |
import spaces
|
|
|
|
| 16 |
import edge_tts
|
| 17 |
import tempfile
|
| 18 |
|
| 19 |
# Load environment variables
|
| 20 |
load_dotenv()
|
| 21 |
|
| 22 |
+
# Whisper API settings
|
| 23 |
+
API_URL = "https://api-inference.huggingface.co/models/whisper-large"
|
| 24 |
+
headers = {"Authorization": f"Bearer {os.getenv('HF_AUTH_TOKEN')}"}
|
| 25 |
+
|
| 26 |
+
def whisper_query(filename):
|
| 27 |
+
with open(filename, "rb") as f:
|
| 28 |
+
data = f.read()
|
| 29 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
| 30 |
+
return response.json()
|
| 31 |
|
| 32 |
# For maintaining user session (to keep track of userID)
|
| 33 |
user_state = gr.State(value="")
|
|
|
|
| 39 |
img_html = get_image_html(image_path)
|
| 40 |
|
| 41 |
@spaces.GPU(duration=120)
|
| 42 |
+
def transcribe(audio_path):
|
| 43 |
+
response = whisper_query(audio_path)
|
| 44 |
+
if "text" in response:
|
| 45 |
+
return response["text"]
|
| 46 |
+
else:
|
| 47 |
+
raise ValueError("Transcription failed.")
|
| 48 |
|
| 49 |
@spaces.GPU(duration=120)
|
| 50 |
def generate_feedback(user_id, question_choice, strategy_choice, message, feedback_level):
|