From efc829e893c41ac5bd596752e7efc05a52efc8e8 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期三, 22 三月 2023 17:48:39 +0800
Subject: [PATCH] cer tool
---
funasr/bin/vad_inference_online.py | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/funasr/bin/vad_inference_online.py b/funasr/bin/vad_inference_online.py
index cee1929..faee1fc 100644
--- a/funasr/bin/vad_inference_online.py
+++ b/funasr/bin/vad_inference_online.py
@@ -1,5 +1,6 @@
import argparse
import logging
+import os
import sys
import json
from pathlib import Path
@@ -96,7 +97,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 +237,14 @@
# 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]:
+ if "MODELSCOPE_ENVIRONMENT" in os.environ and os.environ["MODELSCOPE_ENVIRONMENT"] == "eas":
+ 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