Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -42,9 +42,14 @@ class_options = {
|
|
42 |
|
43 |
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-large")
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
def classify_emotion(audio):
|
46 |
#### Emotion classification ####
|
47 |
-
emotion_classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
|
48 |
out_prob, score, index, text_lab = emotion_classifier.classify_file(audio)
|
49 |
return emo_dict[text_lab[0]]
|
50 |
|
@@ -80,22 +85,23 @@ def classify_toxicity(audio_file, classify_anxiety, emo_class, explitive_selecti
|
|
80 |
|
81 |
#### Toxicity Classifier ####
|
82 |
|
83 |
-
toxicity_module = evaluate.load("toxicity", "facebook/roberta-hate-speech-dynabench-r4-target")
|
84 |
#toxicity_module = evaluate.load("toxicity", 'DaNLP/da-electra-hatespeech-detection', module_type="measurement")
|
85 |
|
86 |
toxicity_results = toxicity_module.compute(predictions=[transcribed_text])
|
87 |
|
88 |
toxicity_score = toxicity_results["toxicity"][0]
|
89 |
print(toxicity_score)
|
|
|
90 |
# emo call
|
91 |
if emo_class != None:
|
92 |
classify_emotion(audio_file)
|
93 |
|
94 |
#### Text classification #####
|
95 |
if classify_anxiety != None:
|
96 |
-
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
97 |
|
98 |
-
text_classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
99 |
|
100 |
sequence_to_classify = transcribed_text
|
101 |
print(classify_anxiety, class_options)
|
|
|
42 |
|
43 |
pipe = pipeline("automatic-speech-recognition", model="openai/whisper-large")
|
44 |
|
45 |
+
toxicity_module = evaluate.load("toxicity", "facebook/roberta-hate-speech-dynabench-r4-target")
|
46 |
+
emotion_classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
|
47 |
+
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
48 |
+
text_classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
49 |
+
|
50 |
def classify_emotion(audio):
|
51 |
#### Emotion classification ####
|
52 |
+
# EMO MODEL LINE emotion_classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")
|
53 |
out_prob, score, index, text_lab = emotion_classifier.classify_file(audio)
|
54 |
return emo_dict[text_lab[0]]
|
55 |
|
|
|
85 |
|
86 |
#### Toxicity Classifier ####
|
87 |
|
88 |
+
# TOX MODEL LINE toxicity_module = evaluate.load("toxicity", "facebook/roberta-hate-speech-dynabench-r4-target")
|
89 |
#toxicity_module = evaluate.load("toxicity", 'DaNLP/da-electra-hatespeech-detection', module_type="measurement")
|
90 |
|
91 |
toxicity_results = toxicity_module.compute(predictions=[transcribed_text])
|
92 |
|
93 |
toxicity_score = toxicity_results["toxicity"][0]
|
94 |
print(toxicity_score)
|
95 |
+
|
96 |
# emo call
|
97 |
if emo_class != None:
|
98 |
classify_emotion(audio_file)
|
99 |
|
100 |
#### Text classification #####
|
101 |
if classify_anxiety != None:
|
102 |
+
# DEVICE LINE device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
103 |
|
104 |
+
# CLASSIFICATION LINE text_classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
|
105 |
|
106 |
sequence_to_classify = transcribed_text
|
107 |
print(classify_anxiety, class_options)
|