diff --git a/.gitattributes b/.gitattributes index b94991b..1bef9be 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,4 @@ *.gif binary *.ttf binary *.data filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index b5a9c97..78ae45d 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -5,6 +5,7 @@ on: - main tags: - "v*" + workflow_dispatch: jobs: build-and-push: runs-on: ubuntu-latest @@ -28,9 +29,6 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_API_KEY }} - - name: Pull TTS Model - run: python ./services/web/scripts/pull_tts_assets.py - - name: Build and Push API Image run: | docker build \ diff --git a/.gitignore b/.gitignore index 763a92f..2c63bd6 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,4 @@ output /node_modules /docs/.vitepress/cache *.bak -/services/web/src/static/vendor/tts-sherpa-onnx -# binary -*.wasm -*.data diff --git a/run.sh b/run.sh index 2e6518c..6fd7e4d 100755 --- a/run.sh +++ b/run.sh @@ -205,14 +205,8 @@ function clean_environment() { python setup.py --clean } -function pull_assets() { - echo "Pulling additional assets..." - python ./services/web/scripts/pull_tts_assets.py -} - function ensure_environment() { python setup.py - pull_assets } function clean_project_images() { diff --git a/services/web/scripts/pull_tts_assets.py b/services/web/scripts/pull_tts_assets.py deleted file mode 100755 index ca03cbc..0000000 --- a/services/web/scripts/pull_tts_assets.py +++ /dev/null @@ -1,88 +0,0 @@ -import os -import shutil -import sys -import tempfile -import time -import urllib.request -from pathlib import Path - - -def get_script_dir(): - return Path(__file__).parent.resolve() - - -def setup_target_dir(): - target_dir = ( - get_script_dir().parent / "src" / "static" / "vendor" / "tts-sherpa-onnx" - ) - - if not target_dir.exists(): - raise RuntimeError(f"Target directory does not exist: {target_dir}") - if not os.access(target_dir, os.W_OK): - raise RuntimeError(f"Target directory is not writable: {target_dir}") - - return target_dir - - -def download_file(url, target_file, tmp_file, max_retries=3): - for attempt in range(max_retries): - try: - print(f"Downloading {target_file.name}...") - urllib.request.urlretrieve(url, tmp_file) - - if not os.path.exists(tmp_file): - raise RuntimeError(f"Download file not found: {tmp_file}") - if os.path.getsize(tmp_file) == 0: - raise RuntimeError(f"Downloaded file is empty: {tmp_file}") - - shutil.move(tmp_file, target_file) - print(f"Download completed successfully to: {target_file}") - return True - - except Exception as e: - if attempt < max_retries - 1: - print( - f"Download failed, retrying (attempt {attempt + 1} of {max_retries})..." - ) - time.sleep(2) - else: - print(f"Error downloading {url}: {str(e)}", file=sys.stderr) - return False - - -def main(): - files = { - "sherpa-onnx-wasm-main-tts.data": "https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-en/resolve/main/sherpa-onnx-wasm-main-tts.data", # noqa: E501 - "sherpa-onnx-wasm-main.wasm": "https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-en/resolve/main/sherpa-onnx-wasm-main.wasm", # noqa: E501 - "sherpa-onnx-wasm-main-tts.wasm": "https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-en/resolve/main/sherpa-onnx-wasm-main-tts.wasm", # noqa: E501 - } - - try: - target_dir = setup_target_dir() - - print("Pulling Wasm client side TTS...") - - with tempfile.TemporaryDirectory() as temp_dir: - for filename, url in files.items(): - target_file = target_dir / filename - - if target_file.exists(): - print(f"File already exists at: {target_file}") - print("Skipping download") - continue - - tmp_file = Path(temp_dir) / f"{filename}.tmp" - - if not download_file(url, target_file, tmp_file): - return 1 - - print("All downloads completed successfully!") - return 0 - - except Exception as e: - print(f"Error: {str(e)}", file=sys.stderr) - return 1 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/services/web/src/static/vendor/tts-sherpa-onnx/.gitattributes b/services/web/src/static/vendor/tts-sherpa-onnx/.gitattributes deleted file mode 100644 index e69de29..0000000 diff --git a/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main-tts.data b/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main-tts.data new file mode 100644 index 0000000..cae5059 --- /dev/null +++ b/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main-tts.data @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b33e49a908d597928504c72ce5b5f6a7092ce9a9586224ccae83da01479b8492 +size 96574820 diff --git a/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main-tts.wasm b/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main-tts.wasm new file mode 100644 index 0000000..5966755 --- /dev/null +++ b/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main-tts.wasm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31fb55950ac85f48710698bc17a74496254ce35598bb413b9932b2aac28b957b +size 11610917 diff --git a/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main.wasm b/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main.wasm new file mode 100644 index 0000000..db01072 --- /dev/null +++ b/services/web/src/static/vendor/tts-sherpa-onnx/sherpa-onnx-wasm-main.wasm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8039bac8f340f6007ce78bf82ef9a55c4c2d1962668f2db42ab41cb31f190068 +size 11452951