Skip to content

Commit

Permalink
fix: dynamically fetch voice names from Hugging Face repository
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Jan 29, 2025
1 parent 46067cc commit a28a144
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions scripts/fetch_voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,21 @@
import numpy as np
import requests
import torch

names = [
"af",
"af_bella",
"af_nicole",
"af_sarah",
"af_sky",
"am_adam",
"am_michael",
"bf_emma",
"bf_isabella",
"bm_george",
"bm_lewis",
]
import re

pattern = "https://huggingface.co/hexgrad/Kokoro-82M/resolve/main/voices/{name}.pt"
url = "https://huggingface.co/hexgrad/Kokoro-82M/tree/main/voices"
voices = {}

for name in names:
names = re.findall(
'href="/hexgrad/Kokoro-82M/blob/main/voices/(.+).pt', requests.get(url).text
)
print(", ".join(names))

count = len(names)
for i, name in enumerate(names, 1):
url = pattern.format(name=name)
print(f"Downloading {url}")
print(f"Downloading {url} ({i}/{count})")
r = requests.get(url)
r.raise_for_status() # Ensure the request was successful
content = io.BytesIO(r.content)
Expand Down

0 comments on commit a28a144

Please sign in to comment.