download_models.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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"
  21. local_dir_1 = "./checkpoints"
  22. files_1 = [
  23. "firefly-gan-base-generator.ckpt",
  24. "README.md",
  25. "special_tokens_map.json",
  26. "text2semantic-sft-large-v1.1-4k.pth",
  27. "text2semantic-sft-medium-v1.1-4k.pth",
  28. "tokenizer_config.json",
  29. "tokenizer.json",
  30. "vits_decoder_v1.1.ckpt",
  31. "vq-gan-group-fsq-2x1024.pth",
  32. ]
  33. # 2nd
  34. repo_id_2 = "SpicyqSama007/fish-speech-packed"
  35. local_dir_2 = ".cache/whisper"
  36. files_2 = [
  37. "medium.pt",
  38. "small.pt",
  39. ]
  40. # 3rd
  41. repo_id_3 = "fishaudio/fish-speech-1"
  42. local_dir_3 = "./"
  43. files_3 = [
  44. "ffmpeg.exe",
  45. "ffprobe.exe",
  46. ]
  47. # 4th
  48. repo_id_4 = "SpicyqSama007/fish-speech-packed"
  49. local_dir_4 = "./"
  50. files_4 = [
  51. "asr-label-win-x64.exe",
  52. ]
  53. check_and_download_files(repo_id_1, files_1, local_dir_1)
  54. check_and_download_files(repo_id_2, files_2, local_dir_2)
  55. check_and_download_files(repo_id_3, files_3, local_dir_3)
  56. check_and_download_files(repo_id_4, files_4, local_dir_4)