Skip to content

Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.

grpc

游雁5d96f77a1751
diff --git a/funasr/runtime/python/grpc/grpc_main_server.py b/funasr/runtime/python/grpc/grpc_main_server.py
index e862ac495..ae386faa6 100644
--- a/funasr/runtime/python/grpc/grpc_main_server.py
+++ b/funasr/runtime/python/grpc/grpc_main_server.py
@@ -10,7 +10,7 @@ def serve(args):
# interceptors=(AuthInterceptor('Bearer mysecrettoken'),)
)
paraformer_pb2_grpc.add_ASRServicer_to_server(
- ASRServicer(args.user_allowed, args.model, args.sample_rate, args.backend, args.onnx_dir), server)
+ ASRServicer(args.user_allowed, args.model, args.sample_rate, args.backend, args.onnx_dir, vad_model=args.vad_model, punc_model=args.punc_model), server)
port = "[::]:" + str(args.port)
server.add_insecure_port(port)
server.start()
@@ -34,7 +34,16 @@ if __name__ == '__main__':
type=str,
default="damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
help="model from modelscope")
-
+ parser.add_argument("--vad_model",
+ type=str,
+ default="damo/speech_fsmn_vad_zh-cn-16k-common-pytorch",
+ help="model from modelscope")
+
+ parser.add_argument("--punc_model",
+ type=str,
+ default="",
+ help="model from modelscope")
+
parser.add_argument("--sample_rate",
type=int,
default=16000,
@@ -50,6 +59,7 @@ if __name__ == '__main__':
type=str,
default="/nfs/models/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
help="onnx model dir")
+
diff --git a/funasr/runtime/python/grpc/grpc_server.py b/funasr/runtime/python/grpc/grpc_server.py
index 95fe96cdb..0fdf30c73 100644
--- a/funasr/runtime/python/grpc/grpc_server.py
+++ b/funasr/runtime/python/grpc/grpc_server.py
@@ -8,7 +8,7 @@ from paraformer_pb2 import Response
class ASRServicer(paraformer_pb2_grpc.ASRServicer):
- def __init__(self, user_allowed, model, sample_rate, backend, onnx_dir):
+ def __init__(self, user_allowed, model, sample_rate, backend, onnx_dir, vad_model='', punc_model=''):
print("ASRServicer init")
self.backend = backend
self.init_flag = 0
@@ -21,7 +21,7 @@ class ASRServicer(paraformer_pb2_grpc.ASRServicer):
from modelscope.utils.constant import Tasks
except ImportError:
raise ImportError(f"Please install modelscope")
- self.inference_16k_pipeline = pipeline(task=Tasks.auto_speech_recognition, model=model)
+ self.inference_16k_pipeline = pipeline(task=Tasks.auto_speech_recognition, model=model, vad_model=vad_model, punc_model=punc_model)
elif self.backend == "onnxruntime":
try:
from rapid_paraformer.paraformer_onnx import Paraformer