download_models.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import os
  2. from huggingface_hub import hf_hub_download
  3. # Download
  4. def check_and_download_files(repo_id, file_list, local_dir):
  5. os.makedirs(local_dir, exist_ok=True)
  6. for file in file_list:
  7. file_path = os.path.join(local_dir, file)
  8. if not os.path.exists(file_path):
  9. print(f"{file} 不存在,从 Hugging Face 仓库下载...")
  10. hf_hub_download(
  11. repo_id=repo_id,
  12. filename=file,
  13. resume_download=True,
  14. local_dir=local_dir,
  15. local_dir_use_symlinks=False,
  16. )
  17. else:
  18. print(f"{file} 已存在,跳过下载。")
  19. # 1st
  20. repo_id_1 = "fishaudio/fish-speech-1.2-sft"
  21. local_dir_1 = "./checkpoints/fish-speech-1.2-sft"
  22. files_1 = [
  23. "model.pth",
  24. "README.md",
  25. "special_tokens_map.json",
  26. "tokenizer_config.json",
  27. "tokenizer.json",
  28. "config.json",
  29. "firefly-gan-vq-fsq-4x1024-42hz-generator.pth",
  30. ]
  31. # 2nd
  32. repo_id_2 = "SpicyqSama007/fish-speech-packed"
  33. local_dir_2 = ".cache/whisper"
  34. files_2 = [
  35. "medium.pt",
  36. "small.pt",
  37. ]
  38. # 3rd
  39. repo_id_3 = "fishaudio/fish-speech-1"
  40. local_dir_3 = "./"
  41. files_3 = [
  42. "ffmpeg.exe",
  43. "ffprobe.exe",
  44. ]
  45. # 4th
  46. repo_id_4 = "SpicyqSama007/fish-speech-packed"
  47. local_dir_4 = "./"
  48. files_4 = [
  49. "asr-label-win-x64.exe",
  50. ]
  51. check_and_download_files(repo_id_1, files_1, local_dir_1)
  52. check_and_download_files(repo_id_2, files_2, local_dir_2)
  53. check_and_download_files(repo_id_3, files_3, local_dir_3)
  54. check_and_download_files(repo_id_4, files_4, local_dir_4)