From 61b67ef16ff2bfdc7533f380226c33d7c55105f9 Mon Sep 17 00:00:00 2001 From: WeberJulian Date: Mon, 11 Dec 2023 23:58:52 +0100 Subject: [PATCH] Fix read_json_with_comments --- .github/workflows/zoo_tests_tortoise.yml | 58 ------------------------ TTS/config/__init__.py | 9 ++-- 2 files changed, 3 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/zoo_tests_tortoise.yml diff --git a/.github/workflows/zoo_tests_tortoise.yml b/.github/workflows/zoo_tests_tortoise.yml deleted file mode 100644 index 04ebb0fa58..0000000000 --- a/.github/workflows/zoo_tests_tortoise.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: zoo-tests-tortoise - -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - check_skip: - # always skip this job while tortoise zoo is not fixed - if: false - runs-on: ubuntu-latest - steps: - - name: Check skip - run: echo "Skipping zoo-tests-tortoise" - - # if: "! contains(github.event.head_commit.message, '[ci skip]')" - # steps: - # - run: echo "${{ github.event.head_commit.message }}" - - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: [3.9, "3.10", "3.11"] - experimental: [false] - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - architecture: x64 - cache: 'pip' - cache-dependency-path: 'requirements*' - - name: check OS - run: cat /etc/os-release - - name: set ENV - run: export TRAINER_TELEMETRY=0 - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y git make gcc - sudo apt-get install espeak espeak-ng - make system-deps - - name: Install/upgrade Python setup deps - run: python3 -m pip install --upgrade pip setuptools wheel - - name: Replace scarf urls - run: | - sed -i 's/https:\/\/coqui.gateway.scarf.sh\//https:\/\/github.com\/coqui-ai\/TTS\/releases\/download\//g' TTS/.models.json - - name: Install TTS - run: | - python3 -m pip install .[all] - python3 setup.py egg_info - - name: Unit tests - run: nose2 -F -v -B --with-coverage --coverage TTS tests.zoo_tests.test_models.test_tortoise diff --git a/TTS/config/__init__.py b/TTS/config/__init__.py index 25b4baef81..c5a6dd68e2 100644 --- a/TTS/config/__init__.py +++ b/TTS/config/__init__.py @@ -16,12 +16,9 @@ def read_json_with_comments(json_path): # fallback to json with fsspec.open(json_path, "r", encoding="utf-8") as f: input_str = f.read() - # handle comments - input_str = re.sub(r"\\\n", "", input_str) - input_str = re.sub(r"//.*\n", "\n", input_str) - data = json.loads(input_str) - return data - + # handle comments but not urls with // + input_str = re.sub(r"(\"(?:[^\"\\]|\\.)*\")|(/\*(?:.|[\\n\\r])*?\*/)|(//.*)", lambda m: m.group(1) or m.group(2) or "", input_str) + return json.loads(input_str) def register_config(model_name: str) -> Coqpit: """Find the right config for the given model name.