File size: 1,021 Bytes
99890d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
import gradio as gr
from gradio import mix
from gradio import inputs, outputs  # noqa: F401
import hydra
from omegaconf import DictConfig

from models_evaluation.models import BaseModel


@hydra.main(version_base=None, config_path="conf", config_name="gradio-asr.yaml")
def main(cfg: DictConfig):
    audio_input = gr.inputs.Audio(source=cfg.gradio.source, type="file", label="Audio")

    default_kwargs = {
        "theme": "dark-huggingface",
        "allow_flagging": "manual",
        "title": cfg.gradio.title,
    }

    all_io = []
    models = []
    for model_cfg in cfg.models:
        model = hydra.utils.instantiate(model_cfg)  # type: BaseModel
        model_cfg = model_cfg.cfg
        models.append(model)
        io = gr.Interface(
            model.transcribe, inputs=audio_input, outputs=gr.outputs.JSON(label=model_cfg.name)
        )
        all_io.append(io)

    parallel = mix.Parallel(*all_io, **default_kwargs)
    parallel.launch(share=True, debug=True)


if __name__ == "__main__":
    main()