start.bat 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. @echo off
  2. chcp 65001
  3. set USE_MIRROR=true
  4. set PYTHONPATH=%~dp0
  5. set PYTHON_CMD=%cd%\fishenv\env\python
  6. set API_FLAG_PATH=%~dp0API_FLAGS.txt
  7. setlocal enabledelayedexpansion
  8. set "HF_ENDPOINT=https://huggingface.co"
  9. set "no_proxy="
  10. if "%USE_MIRROR%" == "true" (
  11. set "HF_ENDPOINT=https://hf-mirror.com"
  12. set "no_proxy=localhost, 127.0.0.1, 0.0.0.0"
  13. )
  14. echo "HF_ENDPOINT: !HF_ENDPOINT!"
  15. echo "NO_PROXY: !no_proxy!"
  16. %PYTHON_CMD% .\tools\download_models.py
  17. set "API_FLAGS="
  18. set "flags="
  19. if exist "%API_FLAG_PATH%" (
  20. for /f "usebackq tokens=*" %%a in ("%API_FLAG_PATH%") do (
  21. set "line=%%a"
  22. if not "!line:~0,1!"=="#" (
  23. set "line=!line: =<SPACE>!"
  24. set "line=!line:\=!"
  25. set "line=!line:<SPACE>= !"
  26. if not "!line!"=="" (
  27. set "API_FLAGS=!API_FLAGS!!line! "
  28. )
  29. )
  30. )
  31. )
  32. if not "!API_FLAGS!"=="" set "API_FLAGS=!API_FLAGS:~0,-1!"
  33. set "flags="
  34. echo !API_FLAGS! | findstr /C:"--api" >nul 2>&1
  35. if !errorlevel! equ 0 (
  36. echo.
  37. echo Start HTTP API...
  38. set "mode=api"
  39. goto process_flags
  40. )
  41. echo !API_FLAGS! | findstr /C:"--infer" >nul 2>&1
  42. if !errorlevel! equ 0 (
  43. echo.
  44. echo Start WebUI Inference...
  45. set "mode=infer"
  46. goto process_flags
  47. )
  48. :process_flags
  49. for %%p in (!API_FLAGS!) do (
  50. if not "%%p"=="--!mode!" (
  51. set "flags=!flags! %%p"
  52. )
  53. )
  54. if not "!flags!"=="" set "flags=!flags:~1!"
  55. echo Debug: flags = !flags!
  56. if "!mode!"=="api" (
  57. %PYTHON_CMD% -m tools.api !flags!
  58. ) else if "!mode!"=="infer" (
  59. %PYTHON_CMD% -m tools.webui !flags!
  60. )
  61. echo.
  62. echo Next launch the page...
  63. %PYTHON_CMD% fish_speech\webui\manage.py
  64. :end
  65. endlocal
  66. pause