Download funasr/bin/inference.py from ml-resources/FunASR-bmodel: direct link, hf CLI and curl.
- Browser
- Download file 771 Bytes
-
https://huggingface.co/ml-resources/FunASR-bmodel/resolve/main/funasr/bin/inference.py
- Command line
-
hf download hf://ml-resources/FunASR-bmodel/funasr/bin/inference.py
-
curl -L -o inference.py https://huggingface.co/ml-resources/FunASR-bmodel/resolve/main/funasr/bin/inference.py
771 Bytes
| import hydra | |
| import logging | |
| from omegaconf import DictConfig, OmegaConf, ListConfig | |
| from funasr.auto.auto_model import AutoModel | |
| def main_hydra(cfg: DictConfig): | |
| def to_plain_list(cfg_item): | |
| if isinstance(cfg_item, ListConfig): | |
| return OmegaConf.to_container(cfg_item, resolve=True) | |
| elif isinstance(cfg_item, DictConfig): | |
| return {k: to_plain_list(v) for k, v in cfg_item.items()} | |
| else: | |
| return cfg_item | |
| kwargs = to_plain_list(cfg) | |
| if kwargs.get("debug", False): | |
| import pdb | |
| pdb.set_trace() | |
| model = AutoModel(**kwargs) | |
| res = model.generate(input=kwargs["input"]) | |
| print(res) | |
| if __name__ == "__main__": | |
| main_hydra() | |