File size: 918 Bytes
0fb9949
93523d1
8ee87f4
3ad86d1
dd7ac9d
 
8ee87f4
2271f6b
8ee87f4
 
 
cd3a52e
8ee87f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
import os
from gradio_client import Client

auth_token = os.environ.get("HUGGING_FACE_HUB_TOKEN")

#iface = gr.load(name="mutisya/transcribe-api", hf_token=auth_token, src="spaces")

langs = "Swahili (swa), Kikuyu (kik), Luo (luo), Somali (som), Meru (mer), Kamba (kam)"
lang_list = [lang.strip() for lang in langs.split(',')]

client = Client("mutisya/transcribe-api",hf_token=auth_token)

def transcribe(audio_microphone, language):
    output = client.predict(audio_microphone, language)
    return  output

gradio_ui = gr.Interface(
    fn=transcribe,
    title="Speech Recognition",
    description="",
    inputs=[gr.Audio(sources=["microphone","upload"], type="filepath",label="input audio"),
            gr.Dropdown(
            lang_list,
            label="Language",
            value="Kikuyu (kik)",
        ),],
    outputs=[gr.Textbox(label="Recognized speech")]
)

gradio_ui.launch()