download_models.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import os
  2. from huggingface_hub import hf_hub_download
  3. # 要检查和下载的文件列表
  4. files = [
  5. "firefly-gan-base-generator.ckpt",
  6. "README.md",
  7. "special_tokens_map.json",
  8. "text2semantic-sft-large-v1.1-4k.pth",
  9. "text2semantic-sft-medium-v1.1-4k.pth",
  10. "tokenizer_config.json",
  11. "tokenizer.json",
  12. "vits_decoder_v1.1.ckpt",
  13. "vq-gan-group-fsq-2x1024.pth",
  14. ]
  15. # Hugging Face 仓库信息
  16. repo_id = "fishaudio/fish-speech-1"
  17. cache_dir = "./checkpoints"
  18. os.makedirs(cache_dir, exist_ok=True)
  19. # 检查每个文件是否存在,如果不存在则从 Hugging Face 仓库下载
  20. for file in files:
  21. file_path = os.path.join(cache_dir, file)
  22. if not os.path.exists(file_path):
  23. print(f"{file} 不存在,从 Hugging Face 仓库下载...")
  24. hf_hub_download(
  25. repo_id=repo_id,
  26. filename=file,
  27. cache_dir=cache_dir,
  28. local_dir_use_symlinks=False,
  29. )
  30. else:
  31. print(f"{file} 已存在,跳过下载。")
  32. files = [
  33. "medium.pt",
  34. "small.pt",
  35. ]
  36. # Hugging Face 仓库信息
  37. repo_id = "SpicyqSama007/fish-speech-packed"
  38. cache_dir = ".cache/whisper"
  39. os.makedirs(cache_dir, exist_ok=True)
  40. for file in files:
  41. file_path = os.path.join(cache_dir, file)
  42. if not os.path.exists(file_path):
  43. print(f"{file} 不存在,从 Hugging Face 仓库下载...")
  44. hf_hub_download(
  45. repo_id=repo_id,
  46. filename=file,
  47. cache_dir=cache_dir,
  48. local_dir_use_symlinks=False,
  49. )
  50. else:
  51. print(f"{file} 已存在,跳过下载。")