Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from inference import * | |
| from script import * | |
| import soundfile as sf | |
| def preprocess_audio(audio_array): | |
| try: | |
| _, array = audio_array | |
| sf.write('audio.wav', array, samplerate=48000, subtype='PCM_16') | |
| return 'audio.wav' | |
| except TypeError as e: | |
| pass | |
| def interface(Language, Audio_Inp): | |
| audio_path = preprocess_audio(Audio_Inp) | |
| if Language == 'Hausa': | |
| voice_command = query(audio_path, 'ha') | |
| state = activate_hausa(voice_command) | |
| return state | |
| # elif Language == 'English': | |
| # command = query(Audio, lang ='en') | |
| # state = activate_english(command) | |
| # return state | |
| elif Language == 'Yoruba': | |
| voice_command = query(audio_path, 'yo') | |
| state = activate_yoruba(voice_command) | |
| return state | |
| else: | |
| pass | |
| demo = gr.Interface( | |
| fn=interface, | |
| inputs=[gr.Dropdown(['Hausa', 'English', 'Yoruba'], | |
| value = 'Hausa', label='Select Your Prefered Language'), gr.Audio(source ='microphone', type='numpy')], | |
| outputs="text", | |
| live=True | |
| ) | |
| if __name__ == '__main__': | |
| demo.launch(share=False) |