Skip to content

Commit 61b67ef

Browse files
committed
Fix read_json_with_comments
1 parent d47b6df commit 61b67ef

File tree

2 files changed

+3
-64
lines changed

2 files changed

+3
-64
lines changed

Diff for: .github/workflows/zoo_tests_tortoise.yml

-58
This file was deleted.

Diff for: TTS/config/__init__.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ def read_json_with_comments(json_path):
1616
# fallback to json
1717
with fsspec.open(json_path, "r", encoding="utf-8") as f:
1818
input_str = f.read()
19-
# handle comments
20-
input_str = re.sub(r"\\\n", "", input_str)
21-
input_str = re.sub(r"//.*\n", "\n", input_str)
22-
data = json.loads(input_str)
23-
return data
24-
19+
# handle comments but not urls with //
20+
input_str = re.sub(r"(\"(?:[^\"\\]|\\.)*\")|(/\*(?:.|[\\n\\r])*?\*/)|(//.*)", lambda m: m.group(1) or m.group(2) or "", input_str)
21+
return json.loads(input_str)
2522

2623
def register_config(model_name: str) -> Coqpit:
2724
"""Find the right config for the given model name.

0 commit comments

Comments
 (0)