From 4a71a391b80d344e8a014617973d63236baa928d Mon Sep 17 00:00:00 2001 From: Quentin Fuxa Date: Sat, 30 Aug 2025 13:44:06 +0200 Subject: [PATCH] get_web_interface_html to get_inline_ui_html for embedded web interface HTML --- README.md | 2 +- whisperlivekit/web/web_interface.py | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index aecd5ad..90c23e5 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ async def websocket_endpoint(websocket: WebSocket): await audio_processor.process_audio(message) ``` -**Frontend Implementation**: The package includes an HTML/JavaScript implementation [here](https://github.com/QuentinFuxa/WhisperLiveKit/blob/main/whisperlivekit/web/live_transcription.html). You can also import it using `from whisperlivekit import get_web_interface_html` & `page = get_web_interface_html()` +**Frontend Implementation**: The package includes an HTML/JavaScript implementation [here](https://github.com/QuentinFuxa/WhisperLiveKit/blob/main/whisperlivekit/web/live_transcription.html). You can also import it using `from whisperlivekit import get_inline_ui_html` & `page = get_inline_ui_html()` ## Parameters & Configuration diff --git a/whisperlivekit/web/web_interface.py b/whisperlivekit/web/web_interface.py index 44cfd4f..80eba56 100644 --- a/whisperlivekit/web/web_interface.py +++ b/whisperlivekit/web/web_interface.py @@ -16,32 +16,25 @@ def get_web_interface_html(): def get_inline_ui_html(): """Returns the complete web interface HTML with all assets embedded in a single call.""" try: - # Load HTML template with resources.files('whisperlivekit.web').joinpath('live_transcription.html').open('r', encoding='utf-8') as f: - html_content = f.read() - - # Load CSS and embed it + html_content = f.read() with resources.files('whisperlivekit.web').joinpath('live_transcription.css').open('r', encoding='utf-8') as f: css_content = f.read() - - # Load JS and embed it with resources.files('whisperlivekit.web').joinpath('live_transcription.js').open('r', encoding='utf-8') as f: js_content = f.read() - # Load SVG files and convert to data URIs + # SVG files with resources.files('whisperlivekit.web').joinpath('src', 'system_mode.svg').open('r', encoding='utf-8') as f: system_svg = f.read() system_data_uri = f"data:image/svg+xml;base64,{base64.b64encode(system_svg.encode('utf-8')).decode('utf-8')}" - with resources.files('whisperlivekit.web').joinpath('src', 'light_mode.svg').open('r', encoding='utf-8') as f: light_svg = f.read() light_data_uri = f"data:image/svg+xml;base64,{base64.b64encode(light_svg.encode('utf-8')).decode('utf-8')}" - with resources.files('whisperlivekit.web').joinpath('src', 'dark_mode.svg').open('r', encoding='utf-8') as f: dark_svg = f.read() dark_data_uri = f"data:image/svg+xml;base64,{base64.b64encode(dark_svg.encode('utf-8')).decode('utf-8')}" - # Replace external references with embedded content + # Replace external references html_content = html_content.replace( '', f'' @@ -52,7 +45,7 @@ def get_inline_ui_html(): f'' ) - # Replace SVG references with data URIs + # Replace SVG references html_content = html_content.replace( '', f''