From 9edc7fd7fc5c8efa9885ed3274e83103ae201777 Mon Sep 17 00:00:00 2001 From: remsky Date: Tue, 14 Jan 2025 02:19:13 -0700 Subject: [PATCH] ci: update Docker workflow to tag images as latest, enhance README with local saving instructions, and modify UI components for local saving feature --- .github/workflows/docker-publish.yml | 13 ++++++++++++- README.md | 15 +++++++++++++++ docker/gpu/docker-compose.yml | 1 + ui/lib/components/output.py | 19 ++++++++++++++----- ui/lib/interface.py | 6 +++++- 5 files changed, 47 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7bbafe1..db1630c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,6 +2,8 @@ name: Docker Build, Slim, and Publish on: push: + branches: + - master tags: [ 'v*.*.*' ] # Allow manual trigger from GitHub UI workflow_dispatch: @@ -63,6 +65,10 @@ jobs: run: | docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0 docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim + docker tag ${{ env.GPU_IMAGE_NAME }}:v0.1.0 ${{ env.GPU_IMAGE_NAME }}:latest + docker tag ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim ${{ env.GPU_IMAGE_NAME }}:latest-slim + docker push ${{ env.GPU_IMAGE_NAME }}:latest + docker push ${{ env.GPU_IMAGE_NAME }}:latest-slim # Build CPU version - name: Build CPU Docker image @@ -91,8 +97,12 @@ jobs: run: | docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0 docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim + docker tag ${{ env.CPU_IMAGE_NAME }}:v0.1.0 ${{ env.CPU_IMAGE_NAME }}:latest + docker tag ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim ${{ env.CPU_IMAGE_NAME }}:latest-slim + docker push ${{ env.CPU_IMAGE_NAME }}:latest + docker push ${{ env.CPU_IMAGE_NAME }}:latest-slim - # Build and push UI version (unchanged) + # Build and push UI version - name: Build and push UI Docker image uses: docker/build-push-action@v5 with: @@ -101,6 +111,7 @@ jobs: push: true tags: | ${{ env.UI_IMAGE_NAME }}:v0.1.0 + ${{ env.UI_IMAGE_NAME }}:latest build-args: | DOCKER_BUILDKIT=1 platforms: linux/amd64 diff --git a/README.md b/README.md index 6005451..6f8efda 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,21 @@ If you only want the API, just comment out everything in the docker-compose.yml Currently, voices created via the API are accessible here, but voice combination/creation has not yet been added *Note: Recent updates for streaming could lead to temporary glitches. If so, pull from the most recent stable release v0.0.2 to restore* + +### Disabling Local Saving + +You can disable local saving of audio files and hide the file view in the UI by setting the `DISABLE_LOCAL_SAVING` environment variable to `true`. This is useful when running the service on a server where you don't want to store generated audio files locally. + +When using Docker Compose: +```yaml +environment: + - DISABLE_LOCAL_SAVING=true +``` + +When running the Docker image directly: +```bash +docker run -p 7860:7860 -e DISABLE_LOCAL_SAVING=true ghcr.io/remsky/kokoro-fastapi-ui:latest +```
diff --git a/docker/gpu/docker-compose.yml b/docker/gpu/docker-compose.yml index c600537..c89c0b2 100644 --- a/docker/gpu/docker-compose.yml +++ b/docker/gpu/docker-compose.yml @@ -32,3 +32,4 @@ services: environment: - GRADIO_WATCH=1 # Enable hot reloading - PYTHONUNBUFFERED=1 # Ensure Python output is not buffered + - DISABLE_LOCAL_SAVING=true # Set to 'true' to disable local saving and hide file view diff --git a/ui/lib/components/output.py b/ui/lib/components/output.py index e25601d..129f06e 100644 --- a/ui/lib/components/output.py +++ b/ui/lib/components/output.py @@ -5,30 +5,39 @@ import gradio as gr from .. import files -def create_output_column() -> Tuple[gr.Column, dict]: +def create_output_column(disable_local_saving: bool = False) -> Tuple[gr.Column, dict]: """Create the output column with audio player and file list.""" with gr.Column(scale=1) as col: gr.Markdown("### Latest Output") audio_output = gr.Audio(label="Generated Speech", type="filepath") - gr.Markdown("### Generated Files") + # Create file-related components with visible=False when local saving is disabled + gr.Markdown("### Generated Files", visible=not disable_local_saving) output_files = gr.Dropdown( label="Previous Outputs", - choices=files.list_output_files(), + choices=files.list_output_files() if not disable_local_saving else [], value=None, allow_custom_value=False, + visible=not disable_local_saving, ) - play_btn = gr.Button("▶️ Play Selected", size="sm") + play_btn = gr.Button( + "▶️ Play Selected", + size="sm", + visible=not disable_local_saving, + ) selected_audio = gr.Audio( - label="Selected Output", type="filepath", visible=False + label="Selected Output", + type="filepath", + visible=False, # Always initially hidden ) clear_outputs = gr.Button( "⚠️ Delete All Previously Generated Output Audio 🗑️", size="sm", variant="secondary", + visible=not disable_local_saving, ) components = { diff --git a/ui/lib/interface.py b/ui/lib/interface.py index a23ed7c..02d3083 100644 --- a/ui/lib/interface.py +++ b/ui/lib/interface.py @@ -1,4 +1,5 @@ import gradio as gr +import os from . import api from .handlers import setup_event_handlers @@ -10,6 +11,9 @@ def create_interface(): # Skip initial status check - let the timer handle it is_available, available_voices = False, [] + # Check if local saving is disabled + disable_local_saving = os.getenv("DISABLE_LOCAL_SAVING", "false").lower() == "true" + with gr.Blocks(title="Kokoro TTS Demo", theme=gr.themes.Monochrome()) as demo: gr.HTML( value='
' @@ -26,7 +30,7 @@ def create_interface(): model_col, model_components = create_model_column( available_voices ) # Pass initial voices - output_col, output_components = create_output_column() + output_col, output_components = create_output_column(disable_local_saving) # Collect all components components = {