adds ssl possibility in basic server
Browse files- README.md +10 -0
- whisperlivekit/basic_server.py +25 -9
- whisperlivekit/web/live_transcription.html +2 -1
README.md
CHANGED
|
@@ -53,6 +53,14 @@ whisperlivekit-server --model tiny.en
|
|
| 53 |
# Open your browser at http://localhost:8000
|
| 54 |
```
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
That's it! Start speaking and watch your words appear on screen.
|
| 57 |
|
| 58 |
## 🛠️ Installation Options
|
|
@@ -201,6 +209,8 @@ WhisperLiveKit offers extensive configuration options:
|
|
| 201 |
| `--no-vad` | Disable Voice Activity Detection | `False` |
|
| 202 |
| `--buffer_trimming` | Buffer trimming strategy (`sentence` or `segment`) | `segment` |
|
| 203 |
| `--warmup-file` | Audio file path for model warmup | `jfk.wav` |
|
|
|
|
|
|
|
| 204 |
|
| 205 |
## 🔧 How It Works
|
| 206 |
|
|
|
|
| 53 |
# Open your browser at http://localhost:8000
|
| 54 |
```
|
| 55 |
|
| 56 |
+
### Quick Start with SSL
|
| 57 |
+
```bash
|
| 58 |
+
# You must provide a certificate and key
|
| 59 |
+
whisperlivekit-server -ssl-certfile public.crt --ssl-keyfile private.key
|
| 60 |
+
|
| 61 |
+
# Open your browser at https://localhost:8000
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
That's it! Start speaking and watch your words appear on screen.
|
| 65 |
|
| 66 |
## 🛠️ Installation Options
|
|
|
|
| 209 |
| `--no-vad` | Disable Voice Activity Detection | `False` |
|
| 210 |
| `--buffer_trimming` | Buffer trimming strategy (`sentence` or `segment`) | `segment` |
|
| 211 |
| `--warmup-file` | Audio file path for model warmup | `jfk.wav` |
|
| 212 |
+
| `--ssl-certfile` | Path to the SSL certificate file (for HTTPS support) | `None` |
|
| 213 |
+
| `--ssl-keyfile` | Path to the SSL private key file (for HTTPS support) | `None` |
|
| 214 |
|
| 215 |
## 🔧 How It Works
|
| 216 |
|
whisperlivekit/basic_server.py
CHANGED
|
@@ -8,7 +8,8 @@ from whisperlivekit.audio_processor import AudioProcessor
|
|
| 8 |
|
| 9 |
import asyncio
|
| 10 |
import logging
|
| 11 |
-
import os
|
|
|
|
| 12 |
|
| 13 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
| 14 |
logging.getLogger().setLevel(logging.WARNING)
|
|
@@ -74,14 +75,29 @@ def main():
|
|
| 74 |
|
| 75 |
args = parse_args()
|
| 76 |
|
| 77 |
-
|
| 78 |
-
"whisperlivekit.basic_server:app",
|
| 79 |
-
host
|
| 80 |
-
port
|
| 81 |
-
reload
|
| 82 |
-
log_level
|
| 83 |
-
lifespan
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
if __name__ == "__main__":
|
| 87 |
main()
|
|
|
|
| 8 |
|
| 9 |
import asyncio
|
| 10 |
import logging
|
| 11 |
+
import os, sys
|
| 12 |
+
import argparse
|
| 13 |
|
| 14 |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
| 15 |
logging.getLogger().setLevel(logging.WARNING)
|
|
|
|
| 75 |
|
| 76 |
args = parse_args()
|
| 77 |
|
| 78 |
+
uvicorn_kwargs = {
|
| 79 |
+
"app": "whisperlivekit.basic_server:app",
|
| 80 |
+
"host":args.host,
|
| 81 |
+
"port":args.port,
|
| 82 |
+
"reload": False,
|
| 83 |
+
"log_level": "info",
|
| 84 |
+
"lifespan": "on",
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
ssl_kwargs = {}
|
| 88 |
+
if args.ssl_certfile or args.ssl_keyfile:
|
| 89 |
+
if not (args.ssl_certfile and args.ssl_keyfile):
|
| 90 |
+
raise ValueError("Both --ssl-certfile and --ssl-keyfile must be specified together.")
|
| 91 |
+
ssl_kwargs = {
|
| 92 |
+
"ssl_certfile": args.ssl_certfile,
|
| 93 |
+
"ssl_keyfile": args.ssl_keyfile
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
if ssl_kwargs:
|
| 98 |
+
uvicorn_kwargs = {**uvicorn_kwargs, **ssl_kwargs}
|
| 99 |
+
|
| 100 |
+
uvicorn.run(**uvicorn_kwargs)
|
| 101 |
|
| 102 |
if __name__ == "__main__":
|
| 103 |
main()
|
whisperlivekit/web/live_transcription.html
CHANGED
|
@@ -321,7 +321,8 @@
|
|
| 321 |
|
| 322 |
const host = window.location.hostname || "localhost";
|
| 323 |
const port = window.location.port || "8000";
|
| 324 |
-
const
|
|
|
|
| 325 |
websocketInput.value = defaultWebSocketUrl;
|
| 326 |
websocketUrl = defaultWebSocketUrl;
|
| 327 |
|
|
|
|
| 321 |
|
| 322 |
const host = window.location.hostname || "localhost";
|
| 323 |
const port = window.location.port || "8000";
|
| 324 |
+
const protocol = window.location.protocol === "https:" ? "wss" : "ws";
|
| 325 |
+
const defaultWebSocketUrl = `${protocol}://${host}:${port}/asr`;
|
| 326 |
websocketInput.value = defaultWebSocketUrl;
|
| 327 |
websocketUrl = defaultWebSocketUrl;
|
| 328 |
|