download_models.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. local_dir = "./checkpoints"
  18. os.makedirs(local_dir, exist_ok=True)
  19. # 检查每个文件是否存在,如果不存在则从 Hugging Face 仓库下载
  20. for file in files:
  21. file_path = os.path.join(local_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. resume_download=True,
  28. local_dir=local_dir,
  29. local_dir_use_symlinks=False,
  30. )
  31. else:
  32. print(f"{file} 已存在,跳过下载。")
  33. files = [
  34. "medium.pt",
  35. "small.pt",
  36. ]
  37. # Hugging Face 仓库信息
  38. repo_id = "SpicyqSama007/fish-speech-packed"
  39. local_dir = ".cache/whisper"
  40. os.makedirs(local_dir, exist_ok=True)
  41. for file in files:
  42. file_path = os.path.join(local_dir, file)
  43. if not os.path.exists(file_path):
  44. print(f"{file} 不存在,从 Hugging Face 仓库下载...")
  45. hf_hub_download(
  46. repo_id=repo_id,
  47. filename=file,
  48. resume_download=True,
  49. local_dir=local_dir,
  50. local_dir_use_symlinks=False,
  51. )
  52. else:
  53. print(f"{file} 已存在,跳过下载。")