From 7cae84872c088166b544d789de29632f2a7911dc Mon Sep 17 00:00:00 2001 From: Mehdi Boutayeb Date: Tue, 15 Sep 2026 09:50:01 +0200 Subject: [PATCH] Fix invalid escape sequences in text normalization and models Three modules use invalid escapes in non-raw string literals: - fun_text_processing/text_normalization/normalize.py - \., \w - funasr/models/fsmn_kws/encoder.py - \[ - funasr/models/fun_asr_nano/tools/format5res.py - \. On Python 3.12+ each raises SyntaxWarning: invalid escape sequence on import, and FunASR runs the 3.10-3.12 CI matrix. Escaping the backslashes leaves every string value identical (ruff W605-style). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_014HBQNzAf5C2E3MiJC48HQw --- fun_text_processing/text_normalization/normalize.py | 2 +- funasr/models/fsmn_kws/encoder.py | 12 ++++++------ funasr/models/fun_asr_nano/tools/format5res.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fun_text_processing/text_normalization/normalize.py b/fun_text_processing/text_normalization/normalize.py index c1cebdd097..7b10b65e6d 100644 --- a/fun_text_processing/text_normalization/normalize.py +++ b/fun_text_processing/text_normalization/normalize.py @@ -351,7 +351,7 @@ def split_text_into_sentences(self, text: str) -> List[str]: upper_case_unicode = "\u0410-\u042F" # Read and split transcript by utterance (roughly, sentences) - split_pattern = f"(?' assert params_split[2] == '' @@ -352,7 +352,7 @@ def to_pytorch_net(self, fread): for i in range(self.lorder): print('read conv_left weight -- %d' % i) line = fread.readline() - splits = line.strip().strip('\[\]').strip().split() + splits = line.strip().strip('\\[\\]').strip().split() assert len(splits) == self.dim cols = torch.tensor([float(item) for item in splits], dtype=torch.float32) @@ -375,7 +375,7 @@ def to_pytorch_net(self, fread): for i in range(self.rorder): print('read conv_right weight -- %d' % i) line = fread.readline() - splits = line.strip().strip('\[\]').strip().split() + splits = line.strip().strip('\\[\\]').strip().split() assert len(splits) == self.dim cols = torch.tensor([float(item) for item in splits], dtype=torch.float32) diff --git a/funasr/models/fun_asr_nano/tools/format5res.py b/funasr/models/fun_asr_nano/tools/format5res.py index 3b11bb83a7..619b9f67cb 100644 --- a/funasr/models/fun_asr_nano/tools/format5res.py +++ b/funasr/models/fun_asr_nano/tools/format5res.py @@ -320,8 +320,8 @@ def all_convert(content): continue name = tmp[0] content = tmp[1] - name = re.sub("\.pcm", "", name) - name = re.sub("\.wav", "", name) + name = re.sub("\\.pcm", "", name) + name = re.sub("\\.wav", "", name) content = recoformat(content) content = numbersingle(content) content = ch_number2digit(content)