From fa9a6cdb1eade68c258eed7297f5a8a8a5329ac6 Mon Sep 17 00:00:00 2001
From: Flute <41096447+fluteink@users.noreply.github.com>
Date: 星期三, 01 十月 2025 14:44:28 +0800
Subject: [PATCH] 更新文档和运行脚本,修复文档拼写错误 (#2688)

---
 funasr/utils/load_utils.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/funasr/utils/load_utils.py b/funasr/utils/load_utils.py
index 072b578..d208f7d 100644
--- a/funasr/utils/load_utils.py
+++ b/funasr/utils/load_utils.py
@@ -107,7 +107,8 @@
                     data_or_path_or_list
                 ).squeeze()  # [n_samples,]
         elif data_type == "text" and tokenizer is not None:
-            data_or_path_or_list = tokenizer.encode(data_or_path_or_list)
+            with open(data_or_path_or_list, "r") as f:
+                data_or_path_or_list = tokenizer.encode(f.read().strip())
         elif data_type == "image":  # undo
             pass
         elif data_type == "video":  # undo
@@ -240,10 +241,19 @@
     # This launches a subprocess to decode audio while down-mixing
     # and resampling as necessary.  Requires the ffmpeg CLI in PATH.
     # fmt: off
+    pcm_params = []
+    if file.lower().endswith('.pcm'):
+        pcm_params = [
+            "-f", "s16le",
+            "-ar", str(sr),
+            "-ac", "1"
+        ]
+
     cmd = [
         "ffmpeg",
         "-nostdin",
         "-threads", "0",
+        *pcm_params,  # PCM files need input format specified before -i since PCM is raw data without headers
         "-i", file,
         "-f", "s16le",
         "-ac", "1",

--
Gitblit v1.9.1