start.bat 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. %PYTHON_CMD% .\tools\download_models.py
  21. set "API_FLAGS="
  22. set "flags="
  23. if exist "%API_FLAG_PATH%" (
  24. for /f "usebackq tokens=*" %%a in ("%API_FLAG_PATH%") do (
  25. set "line=%%a"
  26. if not "!line:~0,1!"=="#" (
  27. set "line=!line: =<SPACE>!"
  28. set "line=!line:\=!"
  29. set "line=!line:<SPACE>= !"
  30. if not "!line!"=="" (
  31. set "API_FLAGS=!API_FLAGS!!line! "
  32. )
  33. )
  34. )
  35. )
  36. if not "!API_FLAGS!"=="" set "API_FLAGS=!API_FLAGS:~0,-1!"
  37. set "flags="
  38. echo !API_FLAGS! | findstr /C:"--api" >nul 2>&1
  39. if !errorlevel! equ 0 (
  40. echo.
  41. echo Start HTTP API...
  42. set "mode=api"
  43. goto process_flags
  44. )
  45. echo !API_FLAGS! | findstr /C:"--infer" >nul 2>&1
  46. if !errorlevel! equ 0 (
  47. echo.
  48. echo Start WebUI Inference...
  49. set "mode=infer"
  50. goto process_flags
  51. )
  52. :process_flags
  53. for %%p in (!API_FLAGS!) do (
  54. if not "%%p"=="--!mode!" (
  55. set "flags=!flags! %%p"
  56. )
  57. )
  58. if not "!flags!"=="" set "flags=!flags:~1!"
  59. echo Debug: flags = !flags!
  60. if "!mode!"=="api" (
  61. %PYTHON_CMD% -m tools.api !flags!
  62. ) else if "!mode!"=="infer" (
  63. %PYTHON_CMD% -m tools.webui !flags!
  64. )
  65. echo.
  66. echo Next launch the page...
  67. %PYTHON_CMD% fish_speech\webui\manage.py
  68. :end
  69. endlocal
  70. pause