Download scripts/probe_space.py from uri410/NovelReader_translate_tool: direct link, hf CLI and curl.
- Browser
- Download file 688 Bytes
-
https://huggingface.co/spaces/uri410/NovelReader_translate_tool/resolve/main/scripts/probe_space.py
- Command line
-
hf download hf://spaces/uri410/NovelReader_translate_tool/scripts/probe_space.py
-
curl -L -o probe_space.py https://huggingface.co/spaces/uri410/NovelReader_translate_tool/resolve/main/scripts/probe_space.py
688 Bytes
| """Run from the project root: python scripts/probe_space.py [--translate].""" | |
| import json | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0,str(Path(__file__).resolve().parents[1])) | |
| from gradio_client import Client | |
| c=Client('ngocdang83/HachimiMT-demo',httpx_kwargs={'timeout':30}) | |
| api=c.view_api(return_format='dict',print_info=False) | |
| p=Path(__file__).resolve().parents[1]/'docs/space-api.json';p.write_text(json.dumps(api,ensure_ascii=False,indent=2),encoding='utf-8') | |
| print('Saved',p) | |
| if '--translate' in sys.argv: | |
| from translation.engines import SpaceEngine | |
| engine=SpaceEngine();engine.load() | |
| print(engine.translate(['林羽站在山门前。'],{'林羽':'Lâm Vũ'})) | |