MCPcopy Index your code
hub / github.com/modelscope/FunASR / ws_client

Function ws_client

runtime/python/websocket/funasr_wss_client.py:474–510  ·  view source on GitHub ↗
(id, chunk_begin, chunk_size)

Source from the content-addressed store, hash-verified

472
473
474async def ws_client(id, chunk_begin, chunk_size):
475 if args.audio_in is None:
476 chunk_begin = 0
477 chunk_size = 1
478 global websocket, voices, offline_msg_done
479
480 for i in range(chunk_begin, chunk_begin + chunk_size):
481 offline_msg_done = False
482 voices = Queue()
483
484 if args.ssl == 1:
485 ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
486 ssl_context.check_hostname = False
487 ssl_context.verify_mode = ssl.CERT_NONE
488 uri = "wss://{}:{}".format(args.host, args.port)
489 else:
490 uri = "ws://{}:{}".format(args.host, args.port)
491 ssl_context = None
492
493 print("connect to", uri)
494
495 async with websockets.connect(
496 uri, subprotocols=["binary"], ping_interval=None, ssl=ssl_context
497 ) as websocket:
498 meeting_tag = f"{id}_{i}"
499 writer = MeetingWriter(args.log_dir, meeting_id=meeting_tag, flush_every=args.log_flush_every)
500 try:
501 if args.audio_in is not None:
502 task = asyncio.create_task(record_from_scp(i, 1))
503 else:
504 task = asyncio.create_task(record_microphone())
505 task3 = asyncio.create_task(message(str(id) + "_" + str(i), writer)) # processid+fileid
506 await asyncio.gather(task, task3)
507 finally:
508 writer.close()
509
510 return
511
512
513def one_thread(id, chunk_begin, chunk_size):

Callers 1

one_threadFunction · 0.85

Calls 5

closeMethod · 0.95
MeetingWriterClass · 0.85
record_from_scpFunction · 0.85
record_microphoneFunction · 0.85
messageFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…