Zled commited on
Commit
a57990c
·
1 Parent(s): 5701657

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -4,9 +4,9 @@ from transformers import Wav2Vec2FeatureExtractor
4
  from datasets import Dataset
5
  import librosa
6
 
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):
@@ -17,6 +17,7 @@ def get_emotion(microphone, file_upload, task):
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)
22
  logits = model(**test).logits
 
4
  from datasets import Dataset
5
  import librosa
6
 
 
 
7
  def get_emotion(microphone, file_upload, task):
8
+
9
+ feature_extractor = Wav2Vec2FeatureExtractor.from_pretrained("superb/hubert-large-superb-er")
10
  warn_output = ""
11
 
12
  if (microphone is not None) and (file_upload is not None):
 
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
+
21
  file = microphone if microphone is not None else file_upload
22
  test = feature_extractor(file, sampling_rate=16000, padding=True, return_tensors="pt" ).to(torch.float32)
23
  logits = model(**test).logits