Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from inference import
|
| 3 |
from script import *
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
if Language == 'Hausa':
|
| 9 |
-
command = query(
|
| 10 |
state = activate_hausa(command)
|
| 11 |
return state
|
| 12 |
|
|
@@ -14,9 +28,9 @@ def interface(Language, Audio):
|
|
| 14 |
# command = query(Audio, lang ='en')
|
| 15 |
# state = activate_english(command)
|
| 16 |
# return state
|
| 17 |
-
|
| 18 |
elif Language == 'Yoruba':
|
| 19 |
-
command = query(
|
| 20 |
state = activate_yoruba(command)
|
| 21 |
return state
|
| 22 |
|
|
@@ -26,11 +40,11 @@ def interface(Language, Audio):
|
|
| 26 |
|
| 27 |
demo = gr.Interface(
|
| 28 |
fn=interface,
|
| 29 |
-
inputs=[gr.Dropdown(['Hausa', 'English', 'Yoruba'], value = 'Hausa', label='Select Your Prefered Language'), gr.Audio(source ='microphone', type='
|
| 30 |
outputs="text",
|
| 31 |
live=True
|
| 32 |
)
|
| 33 |
|
| 34 |
|
| 35 |
if __name__ == '__main__':
|
| 36 |
-
demo.launch()
|
|
|
|
| 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):
|
| 9 |
+
|
| 10 |
+
try:
|
| 11 |
+
_, array = audio
|
| 12 |
+
sf.write('audio.wav', array, samplerate=48000, subtype='PCM_16')
|
| 13 |
+
# audio, sr = librosa.load('audio.wav', sr=16000)
|
| 14 |
+
return 'audio.wav'
|
| 15 |
+
except TypeError as e:
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def interface(Language, Audio_Inp):
|
| 20 |
+
path = preprocess_audio(Audio_Inp)
|
| 21 |
|
| 22 |
if Language == 'Hausa':
|
| 23 |
+
command = query(path, 'ha')
|
| 24 |
state = activate_hausa(command)
|
| 25 |
return state
|
| 26 |
|
|
|
|
| 28 |
# command = query(Audio, lang ='en')
|
| 29 |
# state = activate_english(command)
|
| 30 |
# return state
|
| 31 |
+
|
| 32 |
elif Language == 'Yoruba':
|
| 33 |
+
command = query(path, 'yo')
|
| 34 |
state = activate_yoruba(command)
|
| 35 |
return state
|
| 36 |
|
|
|
|
| 40 |
|
| 41 |
demo = gr.Interface(
|
| 42 |
fn=interface,
|
| 43 |
+
inputs=[gr.Dropdown(['Hausa', 'English', 'Yoruba'], value = 'Hausa', label='Select Your Prefered Language'), gr.Audio(source ='microphone', type='numpy')],
|
| 44 |
outputs="text",
|
| 45 |
live=True
|
| 46 |
)
|
| 47 |
|
| 48 |
|
| 49 |
if __name__ == '__main__':
|
| 50 |
+
demo.launch(share=True)
|