From 65676c0aaefacff0dfbfb7e1785dda516460d9eb Mon Sep 17 00:00:00 2001
From: Yabin Li <wucong.lyb@alibaba-inc.com>
Date: 星期一, 18 十二月 2023 09:39:47 +0800
Subject: [PATCH] Update readme.md
---
runtime/python/websocket/funasr_wss_client.py | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/runtime/python/websocket/funasr_wss_client.py b/runtime/python/websocket/funasr_wss_client.py
index 66b3ce0..e469319 100644
--- a/runtime/python/websocket/funasr_wss_client.py
+++ b/runtime/python/websocket/funasr_wss_client.py
@@ -41,6 +41,10 @@
type=str,
default=None,
help="audio_in")
+parser.add_argument("--audio_fs",
+ type=int,
+ default=16000,
+ help="audio_fs")
parser.add_argument("--send_without_sleep",
action="store_true",
default=True,
@@ -164,7 +168,7 @@
hotword_msg=json.dumps(fst_dict)
print (hotword_msg)
- sample_rate = 16000
+ sample_rate = args.audio_fs
wav_format = "pcm"
use_itn=True
if args.use_itn == 0:
@@ -194,8 +198,7 @@
with open(wav_path, "rb") as f:
audio_bytes = f.read()
- # stride = int(args.chunk_size/1000*16000*2)
- stride = int(60 * args.chunk_size[1] / args.chunk_interval / 1000 * 16000 * 2)
+ stride = int(60 * args.chunk_size[1] / args.chunk_interval / 1000 * sample_rate * 2)
chunk_num = (len(audio_bytes) - 1) // stride + 1
# print(stride)
@@ -253,6 +256,7 @@
wav_name = meg.get("wav_name", "demo")
text = meg["text"]
timestamp=""
+ offline_msg_done = meg.get("is_final", False)
if "timestamp" in meg:
timestamp = meg["timestamp"]
@@ -262,7 +266,9 @@
else:
text_write_line = "{}\t{}\n".format(wav_name, text)
ibest_writer.write(text_write_line)
-
+
+ if 'mode' not in meg:
+ continue
if meg["mode"] == "online":
text_print += "{}".format(text)
text_print = text_print[-args.words_max_print:]
@@ -289,7 +295,7 @@
text_print = text_print[-args.words_max_print:]
os.system('clear')
print("\rpid" + str(id) + ": " + text_print)
- offline_msg_done=True
+ # offline_msg_done=True
except Exception as e:
print("Exception:", e)
--
Gitblit v1.9.1