From 2399487e45a26f6e235e13039939c60dd1acf5e4 Mon Sep 17 00:00:00 2001 From: Chris Margach Date: Fri, 4 Apr 2025 10:54:15 +0900 Subject: [PATCH 1/2] Implement #107 --- whisperlivekit/web/live_transcription.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/whisperlivekit/web/live_transcription.html b/whisperlivekit/web/live_transcription.html index 8b6c29c..e794686 100644 --- a/whisperlivekit/web/live_transcription.html +++ b/whisperlivekit/web/live_transcription.html @@ -279,7 +279,7 @@
- +
@@ -315,6 +315,10 @@ const linesTranscriptDiv = document.getElementById("linesTranscript"); const timerElement = document.querySelector(".timer"); + const defaultWebSocketUrl = `ws://${window.location.hostname}:${window.location.port}/asr`; + websocketInput.value = defaultWebSocketUrl; + websocketUrl = defaultWebSocketUrl; + chunkSelector.addEventListener("change", () => { chunkDuration = parseInt(chunkSelector.value); }); From cfd5905fd4a64cfe6b6ce0c0b8bf16e559118da0 Mon Sep 17 00:00:00 2001 From: Quentin Fuxa Date: Fri, 4 Apr 2025 11:08:05 +0200 Subject: [PATCH 2/2] Improve WebSocket fallback logic Use window.location.hostname and port if available, otherwise fallback to localhost:8000. Co-authored-by: Chris Margach --- whisperlivekit/web/live_transcription.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/whisperlivekit/web/live_transcription.html b/whisperlivekit/web/live_transcription.html index e794686..ad232af 100644 --- a/whisperlivekit/web/live_transcription.html +++ b/whisperlivekit/web/live_transcription.html @@ -315,7 +315,9 @@ const linesTranscriptDiv = document.getElementById("linesTranscript"); const timerElement = document.querySelector(".timer"); - const defaultWebSocketUrl = `ws://${window.location.hostname}:${window.location.port}/asr`; + const host = window.location.hostname || "localhost"; + const port = window.location.port || "8000"; + const defaultWebSocketUrl = `ws://${host}:${port}/asr`; websocketInput.value = defaultWebSocketUrl; websocketUrl = defaultWebSocketUrl;