maher13 commited on
Commit
00592d4
·
1 Parent(s): 21872db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -9,7 +9,11 @@ processor = Wav2Vec2Processor.from_pretrained("maher13/arabic-iti")
9
  model = Wav2Vec2ForCTC.from_pretrained("maher13/arabic-iti").eval()
10
  # define function to read in sound file
11
  def map_to_array(file):
12
- speech, _ = sf.read(file)
 
 
 
 
13
  return speech
14
 
15
  # tokenize
 
9
  model = Wav2Vec2ForCTC.from_pretrained("maher13/arabic-iti").eval()
10
  # define function to read in sound file
11
  def map_to_array(file):
12
+ speech, sr= sf.read(file)
13
+ if sr != 16000:
14
+ transform = torchaudio.transforms.Resample(orig_freq=sampling_rate,
15
+ new_freq=16000)
16
+ speech= transform(speech)[0].numpy()
17
  return speech
18
 
19
  # tokenize