audio-creator / model.py
vmoras's picture
Initial commit
a95b578
raw
history blame contribute delete
No virus
1.5 kB
import os
import requests
from tqdm import tqdm
def _download_file(url, destination):
response = requests.get(url, stream=True)
total_size_in_bytes = int(response.headers.get('content-length', 0))
block_size = 1024
progress_bar = tqdm(total=total_size_in_bytes, unit='iB', unit_scale=True)
with open(destination, 'wb') as file:
for data in response.iter_content(block_size):
progress_bar.update(len(data))
file.write(data)
progress_bar.close()
def download_model():
# Define files and their corresponding URLs
files_to_download = {
'LICENSE.txt': 'https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/LICENSE.txt?download=true',
'README.md': 'https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/README.md?download=true',
'config.json': 'https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/config.json?download=true',
'model.pth': 'https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/model.pth?download=true',
'vocab.json': 'https://huggingface.co/coqui/XTTS-v2/resolve/v2.0.2/vocab.json?download=true',
}
if not os.path.exists("tts_model"):
os.makedirs("tts_model")
# Download files if they don't exist
print("[COQUI TTS] STARTUP: Checking Model is Downloaded.")
for filename, url in files_to_download.items():
destination = f'tts_model/{filename}'
print(f"[COQUI TTS] STARTUP: Downloading {filename}...")
_download_file(url, destination)