Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,18 @@ __pycache__/
/*.wav
/flutter/
/.cache/

# --- portable bundle: distributed manually, never committed ---
/audiocpp-portable/

# --- WebUI runtime artifacts: keep the source + empty dirs, drop generated files ---
/webui/output/*
!/webui/output/.gitkeep
/webui/logs/*
!/webui/logs/.gitkeep
/webui/third_party/
/webui/llm_api_key.txt
# written by the in-UI language picker; per-machine, not a project setting
/webui/configs/ui_language.json
# personal voice recording — stays local, repo is public
/webui/voice/my-record.wav
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ target_link_libraries(engine_runtime PUBLIC ggml)
target_link_libraries(engine_runtime PRIVATE sentencepiece cjson_vendor yaml_vendor)
if (ENGINE_ENABLE_OPENMP)
target_link_libraries(engine_runtime PRIVATE OpenMP::OpenMP_CXX)
if (MSVC)
# MSVC's default /openmp implements only OpenMP 2.0 and rejects the
# '#pragma omp simd' directives in longformer_attention.cpp (error C7660).
# /openmp:experimental enables the OpenMP 4.0 SIMD support; it overrides the
# /openmp added by OpenMP::OpenMP_CXX above (harmless D9025 override notice).
target_compile_options(engine_runtime PRIVATE /openmp:experimental)
endif()
endif()

if (ENGINE_ENABLE_CUDA)
Expand Down
47 changes: 47 additions & 0 deletions _env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@echo off
REM _env.bat -- shared environment detection for the audio.cpp .bat launchers.
REM Called (not run) by run_webui.bat / run_server.bat / run_cli_tts.bat. It sets
REM common variables and deliberately does NOT use setlocal, so they propagate back
REM to the caller. Change detection logic here only.
REM
REM Exports: ROOT BUNDLE WEBUI_DIR PY HAS_CUDA BACKEND SERVER_EXE CLI_EXE GGUF_EXE

REM --- ROOT = this script's directory, without the trailing backslash ---
set "ROOT=%~dp0"
if "%ROOT:~-1%"=="\" set "ROOT=%ROOT:~0,-1%"

REM Dev tree: the repo root doubles as the bundle (models\ live under it; the
REM binaries live under build\). webui.py's own _find_bundle_root handles this.
set "BUNDLE=%ROOT%"
set "WEBUI_DIR=%ROOT%\webui"

REM --- Python with the deps (gradio/requests/torch/safetensors/opencc/...) ---
REM Order: explicit override, project venv (Scripts\ on Windows), then a bundle venv.
set "PY="
if defined AUDIOCPP_PYTHON if exist "%AUDIOCPP_PYTHON%" set "PY=%AUDIOCPP_PYTHON%"
if not defined PY if exist "%ROOT%\venv\Scripts\python.exe" set "PY=%ROOT%\venv\Scripts\python.exe"
if not defined PY if exist "%ROOT%\venv\python.exe" set "PY=%ROOT%\venv\python.exe"
if not defined PY if exist "%BUNDLE%\venv\Scripts\python.exe" set "PY=%BUNDLE%\venv\Scripts\python.exe"
if not defined PY if exist "%BUNDLE%\venv\python.exe" set "PY=%BUNDLE%\venv\python.exe"

REM --- CUDA present? (NVIDIA driver installs nvcuda.dll in System32) ---
set "HAS_CUDA="
if exist "%SystemRoot%\System32\nvcuda.dll" set "HAS_CUDA=1"

REM --- Locate the from-source binaries. The default Visual Studio generator nests
REM them in build\bin\Release (multi-config); Ninja/Makefiles use build\bin. ---
set "BIN="
if exist "%ROOT%\build\bin\Release\audiocpp_server.exe" set "BIN=%ROOT%\build\bin\Release"
if not defined BIN if exist "%ROOT%\build\bin\audiocpp_server.exe" set "BIN=%ROOT%\build\bin"
if defined BIN set "SERVER_EXE=%BIN%\audiocpp_server.exe"
if defined BIN set "CLI_EXE=%BIN%\audiocpp_cli.exe"
if defined BIN set "GGUF_EXE=%BIN%\audiocpp_gguf.exe"

REM --- BACKEND: read the actual build's GGML_CUDA flag from its CMakeCache, so we
REM never advertise a GPU backend a CPU-only build can't serve. cuda when ON, else cpu. ---
set "BACKEND=cpu"
if exist "%ROOT%\build\CMakeCache.txt" (
for /f "tokens=2 delims==" %%A in ('findstr /b /c:"GGML_CUDA:BOOL" "%ROOT%\build\CMakeCache.txt" 2^>nul') do (
if /I "%%A"=="ON" set "BACKEND=cuda"
)
)
87 changes: 87 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# audio.cpp -- unified Python requirements (webui + SpeakType + tools)
# Frozen from the project venv on 2026-07-15.
# One env covers every Python layer of the project:
# webui/ gradio UI + realtime pipeline (gradio, numpy, requests; torch for silero VAD)
# SpeakType/ voice dictation demo (sounddevice, pywebview, pywin32, pyperclip; torch for silero VAD)
# tools/ model_manager etc. (requests, huggingface-hub, safetensors, tqdm)
# The portable bundle ships this same env pre-installed as audiocpp-portable\venv.
# Windows-only wheels (pywin32 and the pythonnet/pywebview desktop stack, used by
# SpeakType) carry a sys_platform marker so this file also installs cleanly on Linux.
# Regenerate: venv\Scripts\python.exe -m pip freeze > requirements.txt
#annotated-doc==0.0.4
annotated-types==0.7.0
anyio==4.14.1
bottle==0.13.4
brotli==1.2.0
certifi==2026.6.17
cffi==2.1.0
charset-normalizer==3.4.7
click==8.4.2
clr_loader==0.3.1; sys_platform == "win32"
colorama==0.4.6
fastapi==0.138.2
filelock==3.29.4
fsspec==2026.6.0
gradio==6.19.0
gradio_client==2.5.0
groovy==0.1.2
h11==0.16.0
hf-gradio==0.4.1
hf-xet==1.5.1
httpcore==1.0.9
httptools==0.8.0
httpx==0.28.1
huggingface_hub==1.21.0
idna==3.18
iniconfig==2.3.0
Jinja2==3.1.6
markdown-it-py==4.2.0
MarkupSafe==3.0.3
mdurl==0.1.2
mpmath==1.3.0
networkx==3.6.1
numpy==2.4.6
opencc-python-reimplemented==0.1.7
orjson==3.11.9
packaging==26.2
pandas==3.0.3
pillow==12.2.0
pluggy==1.6.0
proxy_tools==0.1.0; sys_platform == "win32"
pycparser==3.0
pydantic==2.13.4
pydantic_core==2.46.4
pydub==0.25.1
Pygments==2.20.0
pyperclip==1.11.0
pytest==9.1.1
python-dateutil==2.9.0.post0
python-dotenv==1.2.2
python-multipart==0.0.32
pythonnet==3.1.0; sys_platform == "win32"
pytz==2026.2
pywebview==6.2.1; sys_platform == "win32"
pywin32==312; sys_platform == "win32"
PyYAML==6.0.3
requests==2.34.2
rich==15.0.0
safehttpx==0.1.7
safetensors==0.8.0
semantic-version==2.10.0
shellingham==1.5.4
six==1.17.0
sounddevice==0.5.5
starlette==1.3.1
sympy==1.14.0
tomlkit==0.14.0
torch==2.12.1
torchaudio==2.11.0
tqdm==4.68.3
typer==0.25.1
typing-inspection==0.4.2
typing_extensions==4.15.0
tzdata==2026.2
urllib3==2.7.0
uvicorn==0.49.0
watchfiles==1.2.0
websockets==16.0
32 changes: 32 additions & 0 deletions run_webui.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off
setlocal
chcp 65001 >nul
cd /d "%~dp0"
call "%~dp0_env.bat"

REM _env.bat auto-detected BACKEND (cuda|cpu) from the NVIDIA driver + bundled exes;
REM hand it to webui.py unless the user already chose via AUDIOCPP_BACKEND.
if not defined AUDIOCPP_BACKEND (
if /I "%BACKEND%"=="cuda" ( set "AUDIOCPP_BACKEND=gpu" ) else ( set "AUDIOCPP_BACKEND=cpu" )
)

REM Python (with gradio/requests/torch/safetensors/...) is located by _env.bat (PY).
if not exist "%PY%" (
echo [run_webui] no Python with deps found. Looked for:
echo %BUNDLE%\venv\python.exe ^(bundle venv^)
echo %ROOT%\venv\python.exe ^(root venv^)
echo %ROOT%\venv\Scripts\python.exe ^(project venv^)
echo Install into one of them: gradio requests torch safetensors pyyaml huggingface_hub
pause
exit /b 1
)
echo [run_webui] python: %PY%

echo [run_webui] the WebUI starts/switches audiocpp_server on demand
echo [run_webui] pick a model in the UI and click "load" (no need to run run_server.bat)
echo [run_webui] backend: %AUDIOCPP_BACKEND% (auto-detected; override with AUDIOCPP_BACKEND=gpu or cpu)
echo [run_webui] UI -^> http://127.0.0.1:7860
"%PY%" "%WEBUI_DIR%\webui.py"

endlocal
pause
35 changes: 35 additions & 0 deletions run_webui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Launch the audio.cpp WebUI on Linux/macOS (POSIX counterpart of run_webui.bat).
#
# The WebUI starts/switches audiocpp_server on demand — pick a model in the UI and
# click load; no need to start a server separately. Backend (cuda|cpu) is auto-detected
# by webui.py from nvidia-smi and the available build; override with AUDIOCPP_BACKEND=gpu|cpu.
# UI language: English by default, with 中文 / 中文繁體 selectable from the picker in the
# UI. That pick is saved to webui/configs/ui_language.json and wins on later runs, so
# AUDIOCPP_LANG (en|zh|zh-Hant) only sets the default before anything has been picked.
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WEBUI_DIR="$ROOT/webui"

# Locate a Python that has the deps (gradio/requests/torch/safetensors/opencc/...).
PY=""
for cand in \
"${AUDIOCPP_PYTHON:-}" \
"$ROOT/venv/bin/python" \
"$ROOT/.venv/bin/python" \
"$(command -v python3 || true)" \
"$(command -v python || true)"; do
if [ -n "$cand" ] && [ -x "$cand" ]; then PY="$cand"; break; fi
done

if [ -z "$PY" ]; then
echo "[run_webui] no Python found. Create a venv and install deps:" >&2
echo " python3 -m venv venv && ./venv/bin/pip install -r requirements.txt" >&2
exit 1
fi

echo "[run_webui] python: $PY"
echo "[run_webui] backend: ${AUDIOCPP_BACKEND:-auto} language: ${AUDIOCPP_LANG:-en (unless already picked in the UI)}"
echo "[run_webui] UI -> http://127.0.0.1:7860"
exec "$PY" "$WEBUI_DIR/webui.py"
Loading
Loading