Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,13 +11,16 @@ available_models = {
|
|
11 |
|
12 |
|
13 |
# Create a Gradio interface with audio file and text inputs
|
14 |
-
def classify_toxicity(audio_file, selected_model):
|
15 |
# Transcribe the audio file using Whisper ASR
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
# Load the selected toxicity classification model
|
23 |
toxicity_module = evaluate.load("toxicity", selected_model)
|
@@ -30,7 +33,7 @@ def classify_toxicity(audio_file, selected_model):
|
|
30 |
iface = gr.Interface(
|
31 |
fn=classify_toxicity,
|
32 |
inputs=[
|
33 |
-
gr.Audio(source="upload", type="filepath", label="Upload Audio File"),
|
34 |
gr.Radio(available_models, type="value", label="Select Model")
|
35 |
],
|
36 |
outputs="text",
|
|
|
11 |
|
12 |
|
13 |
# Create a Gradio interface with audio file and text inputs
|
14 |
+
def classify_toxicity(audio_file, text_file, selected_model):
|
15 |
# Transcribe the audio file using Whisper ASR
|
16 |
+
if audio_file != null:
|
17 |
+
whisper_module = evaluate.load("whisper")
|
18 |
+
transcription_results = whisper_module.compute(uploaded=audio_file)
|
19 |
+
|
20 |
+
# Extract the transcribed text
|
21 |
+
transcribed_text = transcription_results["transcription"]
|
22 |
+
else:
|
23 |
+
transcribed_text = open(text_file, "r")
|
24 |
|
25 |
# Load the selected toxicity classification model
|
26 |
toxicity_module = evaluate.load("toxicity", selected_model)
|
|
|
33 |
iface = gr.Interface(
|
34 |
fn=classify_toxicity,
|
35 |
inputs=[
|
36 |
+
gr.Audio(source="upload", type="filepath", label="Upload Audio File"), gr.File(label="Upload Text File"),
|
37 |
gr.Radio(available_models, type="value", label="Select Model")
|
38 |
],
|
39 |
outputs="text",
|