Download data/tests/utils.py from introvoyz045/elevenlabs-python: direct link, hf CLI and curl.
- Browser
- Download file 742 Bytes
-
https://huggingface.co/datasets/introvoyz045/elevenlabs-python/resolve/main/data/tests/utils.py
- Command line
-
hf download hf://datasets/introvoyz045/elevenlabs-python/data/tests/utils.py
-
curl -L -o utils.py https://huggingface.co/datasets/introvoyz045/elevenlabs-python/resolve/main/data/tests/utils.py
742 Bytes
| import os | |
| import tempfile | |
| import httpx | |
| from typing import Sequence, Generator | |
| IN_GITHUB = "GITHUB_ACTIONS" in os.environ | |
| DEFAULT_VOICE = "IRHApOXLvnW57QJPQH2P" | |
| DEFAULT_TEXT = "Hello" | |
| DEFAULT_MODEL = "eleven_multilingual_v2" | |
| DEFAULT_VOICE_FILE = "tests/fixtures/voice_sample.mp3" | |
| def as_local_files(urls: Sequence[str]) -> Generator[str, None, None]: | |
| """Util to download files from urls and return local file paths""" | |
| temp_files = [] | |
| for url in urls: | |
| response = httpx.get(url) | |
| temp_file = tempfile.NamedTemporaryFile() | |
| temp_file.write(response.content) | |
| temp_files.append(temp_file) | |
| yield temp_file.name | |
| # Remove the files | |
| for temp_file in temp_files: | |
| temp_file.close() | |