SeyedAli commited on
Commit
1253b4a
1 Parent(s): bddc971

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,9 +1,9 @@
1
  import torch
2
  import torchaudio
3
- from transformers import Wav2Vec2ForCTC,Wav2Vec2Processor,pipeline
4
 
5
- processor = Wav2Vec2Processor.from_pretrained("SeyedAli/Persian-Speech-Emotion-HuBert-V1")
6
- model = Wav2Vec2ForCTC.from_pretrained("SeyedAli/Persian-Speech-Emotion-HuBert-V1")
7
 
8
  def speech_file_to_array_fn(path, sampling_rate):
9
  speech_array, _sampling_rate = torchaudio.load(path)
@@ -24,7 +24,7 @@ def predict(path, sampling_rate):
24
  return outputs
25
 
26
  def SER(Audio):
27
- return predict(Audio,processor.sampling_rate)
28
 
29
  iface = gr.Interface(fn=SER, inputs="audio", outputs="text")
30
  iface.launch(share=False)
 
1
  import torch
2
  import torchaudio
3
+ from transformers import Wav2Vec2FeatureExtractor,AutoConfig,pipeline
4
 
5
+ config = AutoConfig.from_pretrained("SeyedAli/Persian-Speech-Emotion-HuBert-V1")
6
+ model = Wav2Vec2FeatureExtractor.from_pretrained("SeyedAli/Persian-Speech-Emotion-HuBert-V1")
7
 
8
  def speech_file_to_array_fn(path, sampling_rate):
9
  speech_array, _sampling_rate = torchaudio.load(path)
 
24
  return outputs
25
 
26
  def SER(Audio):
27
+ return predict(Audio,model.sampling_rate)
28
 
29
  iface = gr.Interface(fn=SER, inputs="audio", outputs="text")
30
  iface.launch(share=False)