Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,23 +5,21 @@ from script import *
|
|
5 |
import soundfile as sf
|
6 |
|
7 |
|
8 |
-
def preprocess_audio(
|
9 |
-
|
10 |
try:
|
11 |
-
_, array =
|
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 |
-
|
21 |
|
22 |
if Language == 'Hausa':
|
23 |
-
|
24 |
-
state = activate_hausa(
|
25 |
return state
|
26 |
|
27 |
# elif Language == 'English':
|
@@ -30,8 +28,8 @@ def interface(Language, Audio_Inp):
|
|
30 |
# return state
|
31 |
|
32 |
elif Language == 'Yoruba':
|
33 |
-
|
34 |
-
state = activate_yoruba(
|
35 |
return state
|
36 |
|
37 |
else:
|
@@ -40,11 +38,12 @@ def interface(Language, Audio_Inp):
|
|
40 |
|
41 |
demo = gr.Interface(
|
42 |
fn=interface,
|
43 |
-
inputs=[gr.Dropdown(['Hausa', 'English', 'Yoruba'],
|
|
|
44 |
outputs="text",
|
45 |
live=True
|
46 |
)
|
47 |
|
48 |
|
49 |
if __name__ == '__main__':
|
50 |
-
demo.launch()
|
|
|
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
|
15 |
|
16 |
|
17 |
def interface(Language, Audio_Inp):
|
18 |
+
audio_path = preprocess_audio(Audio_Inp)
|
19 |
|
20 |
if Language == 'Hausa':
|
21 |
+
voice_command = query(audio_path, 'ha')
|
22 |
+
state = activate_hausa(voice_command)
|
23 |
return state
|
24 |
|
25 |
# elif Language == 'English':
|
|
|
28 |
# return state
|
29 |
|
30 |
elif Language == 'Yoruba':
|
31 |
+
voice_command = query(audio_path, 'yo')
|
32 |
+
state = activate_yoruba(voice_command)
|
33 |
return state
|
34 |
|
35 |
else:
|
|
|
38 |
|
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 |
)
|
46 |
|
47 |
|
48 |
if __name__ == '__main__':
|
49 |
+
demo.launch(share=False)
|