From 1e4eba6a72ea97d9a9e733df3e3b1eb86e4fd44d Mon Sep 17 00:00:00 2001
From: speech_asr <wangjiaming.wjm@alibaba-inc.com>
Date: 星期二, 14 三月 2023 23:22:31 +0800
Subject: [PATCH] update

---
 funasr/bin/vad_inference_online.py |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/funasr/bin/vad_inference_online.py b/funasr/bin/vad_inference_online.py
index cee1929..d18488e 100644
--- a/funasr/bin/vad_inference_online.py
+++ b/funasr/bin/vad_inference_online.py
@@ -96,7 +96,7 @@
             }
             # a. To device
             batch = to_device(batch, device=self.device)
-            segments, in_cache = self.vad_model(**batch)
+            segments, in_cache = self.vad_model.forward_online(**batch)
             # in_cache.update(batch['in_cache'])
             # in_cache = {key: value for key, value in batch['in_cache'].items()}
         return fbanks, segments, in_cache
@@ -236,12 +236,13 @@
             # param_dict['in_cache'] = batch['in_cache']
             if results:
                 for i, _ in enumerate(keys):
-                    results[i] = json.dumps(results[i])
-                    item = {'key': keys[i], 'value': results[i]}
-                    vad_results.append(item)
-                    if writer is not None:
-                        results[i] = json.loads(results[i])
-                        ibest_writer["text"][keys[i]] = "{}".format(results[i])
+                    if results[i]:
+                        results[i] = json.dumps(results[i])
+                        item = {'key': keys[i], 'value': results[i]}
+                        vad_results.append(item)
+                        if writer is not None:
+                            results[i] = json.loads(results[i])
+                            ibest_writer["text"][keys[i]] = "{}".format(results[i])
 
         return vad_results
 

--
Gitblit v1.9.1