MCPcopy Create free account
hub / github.com/modelscope/FunASR / new_connection

Method new_connection

runtime/funasr_api/funasr_core.py:85–116  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

83 traceback.print_exc()
84
85 def new_connection(self):
86 try:
87 self.websocket = create_connection(self.uri, ssl=self.ssl_context, sslopt=self.ssl_opt)
88
89 self.is_final=False
90 self.rec_text=""
91 self.rec_file_len=0
92 self.connect_state=0
93
94 message = json.dumps(
95 {
96 "mode": "2pass",
97 "chunk_size": [int(x) for x in "0,10,5".split(",")],
98 "encoder_chunk_look_back": 4,
99 "decoder_chunk_look_back": 1,
100 "chunk_interval": 10,
101 "wav_name": "funasr_api",
102 "is_speaking": True,
103 }
104 )
105
106 self.websocket.send(message)
107 self.connect_state=1
108 # thread for receive message
109 self.thread_msg = threading.Thread(
110 target=FunasrCore.thread_rec_msg, args=(self,)
111 )
112 self.thread_msg.start()
113
114 print("new_connection: ",message)
115 except Exception as e:
116 print("new_connection",e)
117
118
119

Callers 1

new_coreMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected