Open-source speech recognition toolkit for training, inference, streaming ASR, VAD, punctuation, speaker diarization pipelines, and OpenAI-compatible/MCP serving.
Python asraudiochineseemotion-recognitionfunasrmcp-servermultilingual-asropenai-compatible-apiparaformerpunctuationpytorchreal-time-asrspeaker-diarizationspeech-recognitionspeech-to-textstreaming-asrtranscriptionvllmvoice-activity-detectionwhisper-alternative
adjust import lib order
huangmingmingcbe4817bc1b2
diff --git a/funasr/runtime/python/grpc/.gitignore b/funasr/runtime/python/grpc/.gitignorenew file mode 100644index 000000000..eeb8a6ec4--- /dev/null+++ b/funasr/runtime/python/grpc/.gitignore@@ -0,0 +1 @@+**/__pycache__diff --git a/funasr/runtime/python/grpc/grpc_client.py b/funasr/runtime/python/grpc/grpc_client.pyindex d92632f96..8f0bcd932 100644--- a/funasr/runtime/python/grpc/grpc_client.py+++ b/funasr/runtime/python/grpc/grpc_client.py@@ -1,12 +1,10 @@-import paraformer_pb2-import paraformer_pb2_grpc-import grpcimport queue+import paraformer_pb2def transcribe_audio_bytes(stub, chunk, user='zksz', language='zh-CN', speaking = True, isEnd = False):req = paraformer_pb2.Request()if chunk is not None:- req.audio_data = chunk.tostring()+ req.audio_data = chunkreq.user = userreq.language = languagereq.speaking = speakingdiff --git a/funasr/runtime/python/grpc/grpc_main_client_mic.py b/funasr/runtime/python/grpc/grpc_main_client_mic.pyindex 8a8fe4da1..acbe90bc2 100644--- a/funasr/runtime/python/grpc/grpc_main_client_mic.py+++ b/funasr/runtime/python/grpc/grpc_main_client_mic.py@@ -1,23 +1,19 @@import pyaudio-import scipy.io.wavfile as wav-import grpc_clientimport grpcimport json-from grpc_client import transcribe_audio_bytes-from paraformer_pb2_grpc import ASRStubimport webrtcvad-import numpy as npimport timeimport asyncio-import datetimeimport argparse+from grpc_client import transcribe_audio_bytes+from paraformer_pb2_grpc import ASRStub+async def deal_chunk(sig_mic):global stub,SPEAKING,asr_user,language,sample_rate- sig = np.frombuffer(sig_mic, 'int16')- if vad.is_speech(sig.tobytes(), sample_rate): #speaking+ if vad.is_speech(sig_mic, sample_rate): #speakingSPEAKING = True- response = transcribe_audio_bytes(stub, sig, user=asr_user, language=language, speaking = True, isEnd = False) #speaking, send audio to server.+ response = transcribe_audio_bytes(stub, sig_mic, user=asr_user, language=language, speaking = True, isEnd = False) #speaking, send audio to server.else: #silencebegin_time = 0if SPEAKING: #means we have some audio recorded, send recognize order to server.diff --git a/funasr/runtime/python/grpc/grpc_main_server.py b/funasr/runtime/python/grpc/grpc_main_server.pyindex 9f7e8c205..f3b2348ee 100644--- a/funasr/runtime/python/grpc/grpc_main_server.py+++ b/funasr/runtime/python/grpc/grpc_main_server.py@@ -1,8 +1,9 @@+import grpcfrom concurrent import futures+import argparse+import paraformer_pb2_grpcfrom grpc_server import ASRServicer-import grpc-import argparsedef serve(args):server = grpc.server(futures.ThreadPoolExecutor(max_workers=10),diff --git a/funasr/runtime/python/grpc/grpc_server.py b/funasr/runtime/python/grpc/grpc_server.pyindex 292492534..19b735468 100644--- a/funasr/runtime/python/grpc/grpc_server.py+++ b/funasr/runtime/python/grpc/grpc_server.py@@ -1,13 +1,12 @@from concurrent import futuresimport grpcimport json-import paraformer_pb2-import paraformer_pb2_grpcimport time-from paraformer_pb2 import Responsefrom modelscope.pipelines import pipelinefrom modelscope.utils.constant import Tasks+import paraformer_pb2_grpc+from paraformer_pb2 import Responseclass ASRServicer(paraformer_pb2_grpc.ASRServicer):