np fix bug

This commit is contained in:
游雁 2023-07-06 19:13:00 +08:00
parent 9321718b3a
commit 7a207808bc
9 changed files with 17 additions and 15 deletions

View File

@ -92,7 +92,7 @@ pip3 install -U modelscope
#### python版本示例
支持实时流式语音识别并且会用非流式模型进行纠错输出文本带有标点。目前只支持单个client如需多并发请参考c++版本服务部署SDK[点击此处]()
支持实时流式语音识别并且会用非流式模型进行纠错输出文本带有标点。目前只支持单个client如需多并发请参考下方c++版本服务部署SDK
##### 服务端部署
```shell
@ -107,6 +107,7 @@ python funasr_wss_client.py --host "127.0.0.1" --port 10095 --mode 2pass --chunk
```
更多例子可以参考([点击此处](https://alibaba-damo-academy.github.io/FunASR/en/runtime/websocket_python.html#id2)
<a name="cpp版本示例"></a>
#### c++版本示例
目前已支持离线文件转写服务CPU支持上百路并发请求
@ -162,9 +163,9 @@ cd egs/aishell/paraformer
<a name="联系我们"></a>
## 联系我们
如果您在使用中遇到困难,可以通过下方式联系我们
如果您在使用中遇到困难,可以通过下方式联系我们
- email: [funasr@list.alibaba-inc.com](funasr@list.alibaba-inc.com)
- 邮件: [funasr@list.alibaba-inc.com](funasr@list.alibaba-inc.com)
| 钉钉群 | 微信 |
|:---------------------------------------------------------------------:|:-----------------------------------------------------:|

View File

@ -639,7 +639,8 @@ def inference_paraformer_vad_punc(
batch_size_token_ms = batch_size_token*60
if speech2text.device == "cpu":
batch_size_token_ms = 0
batch_size_token_ms = max(batch_size_token_ms, sorted_data[0][0][1] - sorted_data[0][0][0])
if len(sorted_data) > 0 and len(sorted_data[0]) > 0:
batch_size_token_ms = max(batch_size_token_ms, sorted_data[0][0][1] - sorted_data[0][0][0])
batch_size_token_ms_cum = 0
beg_idx = 0

View File

@ -179,7 +179,7 @@ class Speech2DiarizationSOND:
@staticmethod
def seq2arr(seq, vec_dim=8):
def int2vec(x, vec_dim=8, dtype=np.int):
def int2vec(x, vec_dim=8, dtype=np.int32):
b = ('{:0' + str(vec_dim) + 'b}').format(x)
# little-endian order: lower bit first
return (np.array(list(b)[::-1]) == '1').astype(dtype)

View File

@ -46,12 +46,12 @@ class RNNEncoder(AbsEncoder):
raise ValueError(f"Not supported rnn_type={rnn_type}")
if subsample is None:
subsample = np.ones(num_layers + 1, dtype=np.int)
subsample = np.ones(num_layers + 1, dtype=np.int32)
else:
subsample = subsample[:num_layers]
# Append 1 at the beginning because the second or later is used
subsample = np.pad(
np.array(subsample, dtype=np.int),
np.array(subsample, dtype=np.int32),
[1, num_layers - len(subsample)],
mode="constant",
constant_values=1,

View File

@ -105,7 +105,7 @@ def compute_mask_indices(
for length in sorted(lengths, reverse=True):
lens = np.fromiter(
(e - s if e - s >= length + min_space else 0 for s, e in parts),
np.int,
np.int32,
)
l_sum = np.sum(lens)
if l_sum == 0:

View File

@ -13,7 +13,7 @@ from funasr.modules.rnn.encoders import RNNP
class MaskEstimator(torch.nn.Module):
def __init__(self, type, idim, layers, units, projs, dropout, nmask=1):
super().__init__()
subsample = np.ones(layers + 1, dtype=np.int)
subsample = np.ones(layers + 1, dtype=np.int32)
typ = type.lstrip("vgg").rstrip("p")
if type[-1] == "p":

View File

@ -407,7 +407,7 @@ def get_subsample(train_args, mode, arch):
elif mode == "mt" and arch == "rnn":
# +1 means input (+1) and layers outputs (train_args.elayer)
subsample = np.ones(train_args.elayers + 1, dtype=np.int)
subsample = np.ones(train_args.elayers + 1, dtype=np.int32)
logging.warning("Subsampling is not performed for machine translation.")
logging.info("subsample: " + " ".join([str(x) for x in subsample]))
return subsample
@ -417,7 +417,7 @@ def get_subsample(train_args, mode, arch):
or (mode == "mt" and arch == "rnn")
or (mode == "st" and arch == "rnn")
):
subsample = np.ones(train_args.elayers + 1, dtype=np.int)
subsample = np.ones(train_args.elayers + 1, dtype=np.int32)
if train_args.etype.endswith("p") and not train_args.etype.startswith("vgg"):
ss = train_args.subsample.split("_")
for j in range(min(train_args.elayers + 1, len(ss))):
@ -432,7 +432,7 @@ def get_subsample(train_args, mode, arch):
elif mode == "asr" and arch == "rnn_mix":
subsample = np.ones(
train_args.elayers_sd + train_args.elayers + 1, dtype=np.int
train_args.elayers_sd + train_args.elayers + 1, dtype=np.int32
)
if train_args.etype.endswith("p") and not train_args.etype.startswith("vgg"):
ss = train_args.subsample.split("_")
@ -451,7 +451,7 @@ def get_subsample(train_args, mode, arch):
elif mode == "asr" and arch == "rnn_mulenc":
subsample_list = []
for idx in range(train_args.num_encs):
subsample = np.ones(train_args.elayers[idx] + 1, dtype=np.int)
subsample = np.ones(train_args.elayers[idx] + 1, dtype=np.int32)
if train_args.etype[idx].endswith("p") and not train_args.etype[
idx
].startswith("vgg"):

View File

@ -12,7 +12,7 @@ def statistic_model_parameters(model, prefix=None):
return numel
def int2vec(x, vec_dim=8, dtype=np.int):
def int2vec(x, vec_dim=8, dtype=np.int32):
b = ('{:0' + str(vec_dim) + 'b}').format(x)
# little-endian order: lower bit first
return (np.array(list(b)[::-1]) == '1').astype(dtype)

View File

@ -1 +1 @@
0.6.8
0.6.9