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