ci: update Docker workflow to tag images as latest, enhance README with local saving instructions, and modify UI components for local saving feature

This commit is contained in:
remsky 2025-01-14 02:19:13 -07:00
parent da324b0959
commit 9edc7fd7fc
5 changed files with 47 additions and 7 deletions

View file

@ -2,6 +2,8 @@ name: Docker Build, Slim, and Publish
on: on:
push: push:
branches:
- master
tags: [ 'v*.*.*' ] tags: [ 'v*.*.*' ]
# Allow manual trigger from GitHub UI # Allow manual trigger from GitHub UI
workflow_dispatch: workflow_dispatch:
@ -63,6 +65,10 @@ jobs:
run: | run: |
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0 docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim 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 # Build CPU version
- name: Build CPU Docker image - name: Build CPU Docker image
@ -91,8 +97,12 @@ jobs:
run: | run: |
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0 docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim 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 - name: Build and push UI Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
@ -101,6 +111,7 @@ jobs:
push: true push: true
tags: | tags: |
${{ env.UI_IMAGE_NAME }}:v0.1.0 ${{ env.UI_IMAGE_NAME }}:v0.1.0
${{ env.UI_IMAGE_NAME }}:latest
build-args: | build-args: |
DOCKER_BUILDKIT=1 DOCKER_BUILDKIT=1
platforms: linux/amd64 platforms: linux/amd64

View file

@ -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 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* *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
```
</details> </details>
<details> <details>

View file

@ -32,3 +32,4 @@ services:
environment: environment:
- GRADIO_WATCH=1 # Enable hot reloading - GRADIO_WATCH=1 # Enable hot reloading
- PYTHONUNBUFFERED=1 # Ensure Python output is not buffered - PYTHONUNBUFFERED=1 # Ensure Python output is not buffered
- DISABLE_LOCAL_SAVING=true # Set to 'true' to disable local saving and hide file view

View file

@ -5,30 +5,39 @@ import gradio as gr
from .. import files 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.""" """Create the output column with audio player and file list."""
with gr.Column(scale=1) as col: with gr.Column(scale=1) as col:
gr.Markdown("### Latest Output") gr.Markdown("### Latest Output")
audio_output = gr.Audio(label="Generated Speech", type="filepath") 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( output_files = gr.Dropdown(
label="Previous Outputs", label="Previous Outputs",
choices=files.list_output_files(), choices=files.list_output_files() if not disable_local_saving else [],
value=None, value=None,
allow_custom_value=False, 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( 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( clear_outputs = gr.Button(
"⚠️ Delete All Previously Generated Output Audio 🗑️", "⚠️ Delete All Previously Generated Output Audio 🗑️",
size="sm", size="sm",
variant="secondary", variant="secondary",
visible=not disable_local_saving,
) )
components = { components = {

View file

@ -1,4 +1,5 @@
import gradio as gr import gradio as gr
import os
from . import api from . import api
from .handlers import setup_event_handlers from .handlers import setup_event_handlers
@ -10,6 +11,9 @@ def create_interface():
# Skip initial status check - let the timer handle it # Skip initial status check - let the timer handle it
is_available, available_voices = False, [] 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: with gr.Blocks(title="Kokoro TTS Demo", theme=gr.themes.Monochrome()) as demo:
gr.HTML( gr.HTML(
value='<div style="display: flex; gap: 0;">' value='<div style="display: flex; gap: 0;">'
@ -26,7 +30,7 @@ def create_interface():
model_col, model_components = create_model_column( model_col, model_components = create_model_column(
available_voices available_voices
) # Pass initial voices ) # Pass initial voices
output_col, output_components = create_output_column() output_col, output_components = create_output_column(disable_local_saving)
# Collect all components # Collect all components
components = { components = {