Download pkg/common.py from minhvh/tts2: direct link, hf CLI and curl.
- Browser
- Download file 646 Bytes
-
https://huggingface.co/spaces/minhvh/tts2/resolve/main/pkg/common.py
- Command line
-
hf download hf://spaces/minhvh/tts2/pkg/common.py
-
curl -L -o common.py https://huggingface.co/spaces/minhvh/tts2/resolve/main/pkg/common.py
646 Bytes
| from pathlib import Path | |
| import tempfile | |
| import gdown | |
| import requests | |
| def download_file(url: str, output: str = None) -> str: | |
| if not output: | |
| with tempfile.NamedTemporaryFile(delete=False) as tmp: | |
| output = tmp.name | |
| # if Path(output).exists(): | |
| # return output | |
| if 'drive.google.com' in url: | |
| gdown.download(url, output=output, fuzzy=True) | |
| return output | |
| res = requests.get(url, stream=True) | |
| res.raise_for_status() | |
| with open(output, 'wb') as f: | |
| for chunk in res.iter_content(chunk_size=8192): | |
| f.write(chunk) | |
| return output |