pgilles commited on
Commit
8f928e3
·
1 Parent(s): 6bf1492

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -17,17 +17,14 @@ def load_data(input_file):
17
 
18
  """ Function for resampling to ensure that the speech input is sampled at 16KHz.
19
  """
 
20
  #read the file
21
- speech, sample_rate = librosa.load(input_file)
22
- #make it 1-D
23
- if len(speech.shape) > 1:
24
- speech = speech[:,0] + speech[:,1]
25
- #Resampling at 16KHz since wav2vec2-base-960h is pretrained and fine-tuned on speech audio sampled at 16 KHz.
26
- if sample_rate !=16000:
27
- speech = librosa.resample(speech, sample_rate,16000)
28
- return speech
29
 
30
  def asr_pipe(input_file):
 
31
  transcription = p(input_file, chunk_length_s=3, stride_length_s=(1, 1))["text"]
32
  return transcription
33
 
 
17
 
18
  """ Function for resampling to ensure that the speech input is sampled at 16KHz.
19
  """
20
+ sampling_rate = 16_000
21
  #read the file
22
+ speech, sample_rate = librosa.load(input_file, sample_rate=sampling_rate, mono=True)
23
+ speech = librosa.effects.trim(speech, top_db= 10)
24
+ return speech[0]
 
 
 
 
 
25
 
26
  def asr_pipe(input_file):
27
+ load_data(input_file)
28
  transcription = p(input_file, chunk_length_s=3, stride_length_s=(1, 1))["text"]
29
  return transcription
30