From d80ac2fd2df4e7fb8a28acfa512bb11472b5cc99 Mon Sep 17 00:00:00 2001
From: liugz18 <57401541+liugz18@users.noreply.github.com>
Date: 星期四, 18 七月 2024 21:34:55 +0800
Subject: [PATCH] Rename 'res' in line 514 to avoid with naming conflict with line 365

---
 examples/aishell/paraformer/utils/text2token.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/examples/aishell/paraformer/utils/text2token.py b/examples/aishell/paraformer/utils/text2token.py
index 263cb9d..c39db1e 100755
--- a/examples/aishell/paraformer/utils/text2token.py
+++ b/examples/aishell/paraformer/utils/text2token.py
@@ -8,6 +8,7 @@
 import codecs
 import re
 import sys
+import json
 
 is_python2 = sys.version_info[0] == 2
 
@@ -60,6 +61,12 @@
                         read from SI1279.PHN file -> "sil b r ih sil k s aa r er n aa l
                         sil t er n ih sil t ih v sil" """,
     )
+    parser.add_argument(
+        "--text_format",
+        default="text",
+        type=str,
+        help="text, jsonl",
+    )
     return parser
 
 
@@ -82,6 +89,9 @@
     line = f.readline()
     n = args.nchar
     while line:
+        if args.text_format == "jsonl":
+            data = json.loads(line.strip())
+            line = data["target"]
         x = line.split()
         print(" ".join(x[: args.skip_ncols]), end=" ")
         a = " ".join(x[args.skip_ncols :])

--
Gitblit v1.9.1