Update app.py
Browse files
app.py
CHANGED
@@ -7,15 +7,15 @@ import librosa
|
|
7 |
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-large-superb-er")
|
8 |
|
9 |
def get_emotion(microphone, file_upload, task):
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
file = microphone if microphone is not None else file_upload
|
21 |
test = feature_extractor(file, sampling_rate=16000, padding=True, return_tensors="pt" ).to(torch.float32)
|
|
|
7 |
feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-large-superb-er")
|
8 |
|
9 |
def get_emotion(microphone, file_upload, task):
|
10 |
+
warn_output = ""
|
11 |
|
12 |
+
if (microphone is not None) and (file_upload is not None):
|
13 |
+
warn_output = (
|
14 |
+
"WARNING: You've uploaded an audio file and used the microphone. "
|
15 |
+
"The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
|
16 |
+
)
|
17 |
+
elif (microphone is None) and (file_upload is None):
|
18 |
+
return "ERROR: You have to either use the microphone or upload an audio file"
|
19 |
|
20 |
file = microphone if microphone is not None else file_upload
|
21 |
test = feature_extractor(file, sampling_rate=16000, padding=True, return_tensors="pt" ).to(torch.float32)
|