start.bat 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. %PYTHON_CMD% .\tools\download_models.py
  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. 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