远程服务端(客户端)代码:
pip install websocket-client==1.3.1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
_AUTHOR_ = "许潇洒"
_DATE_ = "2022/03/17 16:45"
import websocket
import json
import time
'模仿dory连接服务端发送字幕数据'
class WS:
def __init__(self, ws_url):
self.ws_url = ws_url
def on_open(self, ws):
print('on_open: start......')
while True:
ws.send(
json.dumps({'cnText': '我突然想', 'enText': 'I suddenly thought.', 'language': 'cn', 'resultType': '0',
'roomId': '123456', 'senderId': '521495', 'senderName': 'w',