feat: convert python backend to a pure WebSocket API server

This commit is contained in:
akukanara
2026-05-31 16:58:25 +07:00
Unverified
parent a77c6792c0
commit c8c6bc5770
3 changed files with 27 additions and 59 deletions
+24 -12
View File
@@ -110,9 +110,10 @@ To run character models on ONNX Runtime, you must place your standard PyTorch RV
---
### 🖥️ 4. Build the Frontend (Optional)
*Note: Statically built files are already pre-compiled under `/frontend`. You only need to run this step if you have modified the Next.js workspace source files inside `/frontend-next`.*
### 🖥️ 4. Running the Frontend Client
Since the Python backend operates purely as a WebSocket API service, you must run the Next.js frontend client separately.
#### Option A: Development Server (Quick & Recommended)
1. Navigate to the frontend directory:
```bash
cd frontend-next
@@ -121,34 +122,45 @@ To run character models on ONNX Runtime, you must place your standard PyTorch RV
```bash
npm install
```
3. Build and export static assets (this will automatically compile files and synchronize them to the `/frontend` directory via `copy-build.js`):
3. Spin up the dev server:
```bash
npm run dev
```
Open your browser and navigate to **`http://localhost:3000`**.
#### Option B: Compiled Static Production Web Server
1. Navigate to `frontend-next` and build the application:
```bash
cd frontend-next
npm install
npm run build
```
*Note: This will compile static pages and copy them into the root `/frontend` folder.*
2. Serve the compiled output using a static file server of your choice:
- Using Node: `npx serve ../frontend -p 3000`
- Using Python: `python -m http.server 3000 --directory ../frontend`
Open **`http://localhost:3000`** in your browser.
---
## 🏃 Running the Voice Changer
### Option A: Quick Launch (Windows)
Double-click the [start.bat](file:///M:/Users/ahmad/project/onnx-voice-changer/start.bat) file at the root. It automatically activates the Python virtual environment and fires up the server.
### Option B: Manual CLI Execution
Run the server using your terminal:
### Step 1: Start the Python WebSocket Backend
Run the server using your terminal (defaults to port `8765`):
```bash
python server.py --host 127.0.0.1 --port 8765 --http_port 8000 --device cuda
python server.py --host 127.0.0.1 --port 8765 --device cuda
```
### ⚙️ Command-Line Arguments
#### ⚙️ Command-Line Arguments
| Argument | Description | Default |
|---|---|---|
| `--host` | The address the WebSocket server binds to. | `127.0.0.1` |
| `--port` | WebSocket communication port. | `8765` |
| `--http_port`| Port serving the static frontend Web UI. | `8000` |
| `--device` | The ONNX Runtime execution device (`cpu`, `cuda`, `dml`). | `cuda` |
| `--model` | Target folder name in `weights/` to load directly upon startup. | `None` |
Once started, the application will automatically launch your browser and direct you to the premium audio dashboard at `http://localhost:8000`.
### Step 2: Open the Frontend Dashboard
Make sure your frontend client is running (via `npm run dev` or a static server on `http://localhost:3000`), open it in your browser, and it will automatically connect to the WebSocket API backend.
---