From 528f92f7a2a26cade1c57ccf26b0ba6524e7cae5 Mon Sep 17 00:00:00 2001
From: TnR2 <115166373+TnR2@users.noreply.github.com>
Date: 星期三, 01 十月 2025 14:45:17 +0800
Subject: [PATCH] fix: handle empty strings after event removal in transcription processing (def rich_transcription_postprocess(s)) (#2681)

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

diff --git a/funasr/utils/load_utils.py b/funasr/utils/load_utils.py
index c38f1d9..d208f7d 100644
--- a/funasr/utils/load_utils.py
+++ b/funasr/utils/load_utils.py
@@ -241,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