start.bat 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. @echo off
  2. chcp 65001
  3. set USE_MIRROR=true
  4. set PYTHONPATH=%~dp0
  5. set PYTHON_CMD=python
  6. if exist "fishenv" (
  7. set PYTHON_CMD=%cd%\fishenv\env\python
  8. )
  9. set API_FLAG_PATH=%~dp0API_FLAGS.txt
  10. set KMP_DUPLICATE_LIB_OK=TRUE
  11. setlocal enabledelayedexpansion
  12. set "HF_ENDPOINT=https://huggingface.co"
  13. set "no_proxy="
  14. if "%USE_MIRROR%" == "true" (
  15. set "HF_ENDPOINT=https://hf-mirror.com"
  16. set "no_proxy=localhost, 127.0.0.1, 0.0.0.0"
  17. )
  18. echo "HF_ENDPOINT: !HF_ENDPOINT!"
  19. echo "NO_PROXY: !no_proxy!"
  20. echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~\u4E00-\u9FFF ] " >nul && (
  21. echo.
  22. echo There are special characters in the current path, please make the path of fish-speech free of special characters before running. && (
  23. goto end
  24. )
  25. )
  26. %PYTHON_CMD% .\tools\download_models.py
  27. set "API_FLAGS="
  28. set "flags="
  29. if exist "%API_FLAG_PATH%" (
  30. for /f "usebackq tokens=*" %%a in ("%API_FLAG_PATH%") do (
  31. set "line=%%a"
  32. if not "!line:~0,1!"=="#" (
  33. set "line=!line: =<SPACE>!"
  34. set "line=!line:\=!"
  35. set "line=!line:<SPACE>= !"
  36. if not "!line!"=="" (
  37. set "API_FLAGS=!API_FLAGS!!line! "
  38. )
  39. )
  40. )
  41. )
  42. if not "!API_FLAGS!"=="" set "API_FLAGS=!API_FLAGS:~0,-1!"
  43. set "flags="
  44. echo !API_FLAGS! | findstr /C:"--api" >nul 2>&1
  45. if !errorlevel! equ 0 (
  46. echo.
  47. echo Start HTTP API...
  48. set "mode=api"
  49. goto process_flags
  50. )
  51. echo !API_FLAGS! | findstr /C:"--infer" >nul 2>&1
  52. if !errorlevel! equ 0 (
  53. echo.
  54. echo Start WebUI Inference...
  55. set "mode=infer"
  56. goto process_flags
  57. )
  58. :process_flags
  59. for %%p in (!API_FLAGS!) do (
  60. if not "%%p"=="--!mode!" (
  61. set "flags=!flags! %%p"
  62. )
  63. )
  64. if not "!flags!"=="" set "flags=!flags:~1!"
  65. echo Debug: flags = !flags!
  66. if "!mode!"=="api" (
  67. %PYTHON_CMD% -m tools.api !flags!
  68. ) else if "!mode!"=="infer" (
  69. %PYTHON_CMD% -m tools.webui !flags!
  70. )
  71. echo.
  72. echo Next launch the page...
  73. %PYTHON_CMD% fish_speech\webui\manage.py
  74. :end
  75. endlocal
  76. pause