Fedir Zadniprovskyi 2024-07-20
feat: add flag to disable/enable ui
@29f0e9733d1e91dd50242bc505617e79b501d5b1
faster_whisper_server/config.py
--- faster_whisper_server/config.py
+++ faster_whisper_server/config.py
@@ -198,6 +198,11 @@
     host: str = Field(alias="UVICORN_HOST", default="0.0.0.0")
     port: int = Field(alias="UVICORN_PORT", default=8000)
 
+    enable_ui: bool = True
+    """
+    Whether to enable the Gradio UI. You may want to disable this if you want to minimize the dependencies.
+    """
+
     default_language: Language | None = None
     default_response_format: ResponseFormat = ResponseFormat.JSON
     whisper: WhisperConfig = WhisperConfig()
faster_whisper_server/main.py
--- faster_whisper_server/main.py
+++ faster_whisper_server/main.py
@@ -21,7 +21,6 @@
 from fastapi.websockets import WebSocketState
 from faster_whisper import WhisperModel
 from faster_whisper.vad import VadOptions, get_speech_timestamps
-import gradio as gr
 import huggingface_hub
 from pydantic import AfterValidator
 
@@ -35,7 +34,6 @@
     Task,
     config,
 )
-from faster_whisper_server.gradio_app import create_gradio_demo
 from faster_whisper_server.logger import logger
 from faster_whisper_server.server_models import (
     ModelListResponse,
@@ -334,4 +332,9 @@
         await ws.close()
 
 
-app = gr.mount_gradio_app(app, create_gradio_demo(config), path="/")
+if config.enable_ui:
+    import gradio as gr
+
+    from faster_whisper_server.gradio_app import create_gradio_demo
+
+    app = gr.mount_gradio_app(app, create_gradio_demo(config), path="/")
Add a comment
List