SamSwift commited on
Commit
4f4776d
·
1 Parent(s): ade0b05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,14 +1,16 @@
1
  import gradio as gr
2
  from inference import *
3
  from script import *
4
- # import librosa
5
  import soundfile as sf
6
 
7
 
8
  def preprocess_audio(audio_array):
9
  try:
10
- _, array = audio_array
11
- sf.write('audio.wav', array, samplerate=48000, subtype='PCM_16')
 
 
12
  return 'audio.wav'
13
  except TypeError as e:
14
  pass
@@ -39,7 +41,7 @@ def interface(Language, Audio_Inp):
39
  demo = gr.Interface(
40
  fn=interface,
41
  inputs=[gr.Dropdown(['Hausa', 'English', 'Yoruba'],
42
- value = 'Hausa', label='Select Your Prefered Language'), gr.Audio(source ='microphone', type='numpy')],
43
  outputs="text",
44
  live=True
45
  )
 
1
  import gradio as gr
2
  from inference import *
3
  from script import *
4
+ import librosa
5
  import soundfile as sf
6
 
7
 
8
  def preprocess_audio(audio_array):
9
  try:
10
+ #_, array = audio_array
11
+ #sf.write('audio.wav', array, samplerate=48000, subtype='PCM_16')
12
+ y, sr = librosa.load(audio_array, sr=16000)
13
+ sf.write('audio.wav', y, samplerate=16000, subtype='PCM_16')
14
  return 'audio.wav'
15
  except TypeError as e:
16
  pass
 
41
  demo = gr.Interface(
42
  fn=interface,
43
  inputs=[gr.Dropdown(['Hausa', 'English', 'Yoruba'],
44
+ value = 'Hausa', label='Select Your Prefered Language'), gr.Audio(source ='microphone', type='filepath')],
45
  outputs="text",
46
  live=True
47
  )