提供funasr集成
1、修正语音和文字的交互逻辑; 2、提供funasr的可选集成。
This commit is contained in:
parent
d90d699b58
commit
524e4d0e65
@ -10,6 +10,8 @@ Fay数字人助理版是fay开源项目的重要分支,专注于构建智能
|
||||
|
||||
## **推荐集成**
|
||||
|
||||
给Fay加上本地免费语音识别(达摩院funaar): https://www.bilibili.com/video/BV1qs4y1g74e/?share_source=copy_web&vd_source=64cd9062f5046acba398177b62bea9ad
|
||||
|
||||
消费级pc大模型(ChatGLM-6B的基础上前置Rasa会话管理):https://m.bilibili.com/video/BV1D14y1f7pr
|
||||
|
||||
UE5工程:https://github.com/xszyou/fay-ue5
|
||||
@ -153,7 +155,8 @@ python main.py
|
||||
|
||||
| 代码模块 | 描述 | 链接 |
|
||||
| ------------------------- | -------------------------- | ------------------------------------------------------------ |
|
||||
| ./ai_module/ali_nls.py | 阿里云 实时语音识别 | https://ai.aliyun.com/nls/trans |
|
||||
| ./ai_module/ali_nls.py | 实时语音识别(免费3个月,asr二选一) | https://ai.aliyun.com/nls/trans |
|
||||
| ./ai_module/funasr.py | 达摩院开源免费本地asr (asr二选一) | fay/test/funasr/README.MD |
|
||||
| ./ai_module/ms_tts_sdk.py | 微软 文本转情绪语音(可选) | https://azure.microsoft.com/zh-cn/services/cognitive-services/text-to-speech/ |
|
||||
| ./ai_module/xf_ltp.py | 讯飞 情感分析 | https://www.xfyun.cn/service/emotion-analysis |
|
||||
| ./utils/ngrok_util.py | ngrok.cc 外网穿透(可选) | http://ngrok.cc |
|
||||
|
120
ai_module/funasr.py
Normal file
120
ai_module/funasr.py
Normal file
@ -0,0 +1,120 @@
|
||||
"""
|
||||
感谢北京中科大脑神经算法工程师张聪聪提供funasr集成代码
|
||||
"""
|
||||
from threading import Thread
|
||||
import websocket
|
||||
import json
|
||||
import time
|
||||
import ssl
|
||||
import _thread as thread
|
||||
|
||||
from core import wsa_server, song_player
|
||||
from utils import config_util as cfg
|
||||
|
||||
class FunASR:
|
||||
# 初始化
|
||||
def __init__(self):
|
||||
self.__URL = "ws://{}:{}".format(cfg.local_asr_ip, cfg.local_asr_port)
|
||||
self.__ws = None
|
||||
self.__connected = False
|
||||
self.__frames = []
|
||||
self.__state = 0
|
||||
self.__closing = False
|
||||
self.__task_id = ''
|
||||
self.done = False
|
||||
self.finalResults = ""
|
||||
|
||||
|
||||
def __on_msg(self):
|
||||
if "暂停" in self.finalResults or "不想听了" in self.finalResults or "别唱了" in self.finalResults:
|
||||
song_player.stop()
|
||||
|
||||
# 收到websocket消息的处理
|
||||
def on_message(self, ws, message):
|
||||
try:
|
||||
self.done = True
|
||||
self.finalResults = message
|
||||
wsa_server.get_web_instance().add_cmd({"panelMsg": self.finalResults})
|
||||
self.__on_msg()
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
if self.__closing:
|
||||
try:
|
||||
self.__ws.close()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# 收到websocket错误的处理
|
||||
def on_close(self, ws, code, msg):
|
||||
self.__connected = False
|
||||
print("### CLOSE:", msg)
|
||||
|
||||
# 收到websocket错误的处理
|
||||
def on_error(self, ws, error):
|
||||
print("### error:", error)
|
||||
|
||||
# 收到websocket连接建立的处理
|
||||
def on_open(self, ws):
|
||||
self.__connected = True
|
||||
|
||||
def run(*args):
|
||||
while self.__connected:
|
||||
try:
|
||||
if len(self.__frames) > 0:
|
||||
frame = self.__frames[0]
|
||||
|
||||
self.__frames.pop(0)
|
||||
if type(frame) == dict:
|
||||
ws.send(json.dumps(frame))
|
||||
elif type(frame) == bytes:
|
||||
ws.send(frame, websocket.ABNF.OPCODE_BINARY)
|
||||
# print('发送 ------> ' + str(type(frame)))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
time.sleep(0.04)
|
||||
|
||||
thread.start_new_thread(run, ())
|
||||
|
||||
def __connect(self):
|
||||
self.finalResults = ""
|
||||
self.done = False
|
||||
self.__frames.clear()
|
||||
websocket.enableTrace(False)
|
||||
self.__ws = websocket.WebSocketApp(self.__URL, on_message=self.on_message,on_close=self.on_close,on_error=self.on_error,subprotocols=["binary"])
|
||||
self.__ws.on_open = self.on_open
|
||||
|
||||
self.__ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})
|
||||
|
||||
def add_frame(self, frame):
|
||||
self.__frames.append(frame)
|
||||
|
||||
def send(self, buf):
|
||||
self.__frames.append(buf)
|
||||
|
||||
def start(self):
|
||||
Thread(target=self.__connect, args=[]).start()
|
||||
data = {
|
||||
'vad_need':False,
|
||||
'state':'StartTranscription'
|
||||
}
|
||||
self.add_frame(data)
|
||||
|
||||
def end(self):
|
||||
if self.__connected:
|
||||
try:
|
||||
for frame in self.__frames:
|
||||
self.__frames.pop(0)
|
||||
if type(frame) == dict:
|
||||
self.__ws.send(json.dumps(frame))
|
||||
elif type(frame) == bytes:
|
||||
self.__ws.send(frame, websocket.ABNF.OPCODE_BINARY)
|
||||
time.sleep(0.4)
|
||||
self.__frames.clear()
|
||||
frame = {'vad_need':False,'state':'StopTranscription'}
|
||||
self.__ws.send(json.dumps(frame))
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.__closing = True
|
||||
self.__connected = False
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><doc>
|
||||
<assembly>
|
||||
<name>System.Buffers</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:System.Buffers.ArrayPool`1">
|
||||
<summary>Provides a resource pool that enables reusing instances of type <see cref="T[]"></see>.</summary>
|
||||
<typeparam name="T">The type of the objects that are in the resource pool.</typeparam>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.#ctor">
|
||||
<summary>Initializes a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Create">
|
||||
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class.</summary>
|
||||
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class.</returns>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Create(System.Int32,System.Int32)">
|
||||
<summary>Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1"></see> class using the specifed configuration.</summary>
|
||||
<param name="maxArrayLength">The maximum length of an array instance that may be stored in the pool.</param>
|
||||
<param name="maxArraysPerBucket">The maximum number of array instances that may be stored in each bucket in the pool. The pool groups arrays of similar lengths into buckets for faster access.</param>
|
||||
<returns>A new instance of the <see cref="System.Buffers.ArrayPool`1"></see> class with the specified configuration.</returns>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Rent(System.Int32)">
|
||||
<summary>Retrieves a buffer that is at least the requested length.</summary>
|
||||
<param name="minimumLength">The minimum length of the array.</param>
|
||||
<returns>An array of type <see cref="T[]"></see> that is at least <paramref name="minimumLength">minimumLength</paramref> in length.</returns>
|
||||
</member>
|
||||
<member name="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)">
|
||||
<summary>Returns an array to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method on the same <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
|
||||
<param name="array">A buffer to return to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method.</param>
|
||||
<param name="clearArray">Indicates whether the contents of the buffer should be cleared before reuse. If <paramref name="clearArray">clearArray</paramref> is set to true, and if the pool will store the buffer to enable subsequent reuse, the <see cref="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)"></see> method will clear the <paramref name="array">array</paramref> of its contents so that a subsequent caller using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)"></see> method will not see the content of the previous caller. If <paramref name="clearArray">clearArray</paramref> is set to false or if the pool will release the buffer, the array&#39;s contents are left unchanged.</param>
|
||||
</member>
|
||||
<member name="P:System.Buffers.ArrayPool`1.Shared">
|
||||
<summary>Gets a shared <see cref="T:System.Buffers.ArrayPool`1"></see> instance.</summary>
|
||||
<returns>A shared <see cref="System.Buffers.ArrayPool`1"></see> instance.</returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,355 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><doc>
|
||||
<assembly>
|
||||
<name>System.Memory</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:System.Span`1">
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:System.Span`1.#ctor(`0[])">
|
||||
<param name="array"></param>
|
||||
</member>
|
||||
<member name="M:System.Span`1.#ctor(System.Void*,System.Int32)">
|
||||
<param name="pointer"></param>
|
||||
<param name="length"></param>
|
||||
</member>
|
||||
<member name="M:System.Span`1.#ctor(`0[],System.Int32)">
|
||||
<param name="array"></param>
|
||||
<param name="start"></param>
|
||||
</member>
|
||||
<member name="M:System.Span`1.#ctor(`0[],System.Int32,System.Int32)">
|
||||
<param name="array"></param>
|
||||
<param name="start"></param>
|
||||
<param name="length"></param>
|
||||
</member>
|
||||
<member name="M:System.Span`1.Clear">
|
||||
|
||||
</member>
|
||||
<member name="M:System.Span`1.CopyTo(System.Span{`0})">
|
||||
<param name="destination"></param>
|
||||
</member>
|
||||
<member name="M:System.Span`1.DangerousCreate(System.Object,`0@,System.Int32)">
|
||||
<param name="obj"></param>
|
||||
<param name="objectData"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.DangerousGetPinnableReference">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.Span`1.Empty">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.Equals(System.Object)">
|
||||
<param name="obj"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.Fill(`0)">
|
||||
<param name="value"></param>
|
||||
</member>
|
||||
<member name="M:System.Span`1.GetHashCode">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.Span`1.IsEmpty">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.Span`1.Item(System.Int32)">
|
||||
<param name="index"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.Span`1.Length">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.op_Equality(System.Span{`0},System.Span{`0})">
|
||||
<param name="left"></param>
|
||||
<param name="right"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.op_Implicit(System.ArraySegment{T})~System.Span{T}">
|
||||
<param name="arraySegment"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.op_Implicit(System.Span{T})~System.ReadOnlySpan{T}">
|
||||
<param name="span"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.op_Implicit(T[])~System.Span{T}">
|
||||
<param name="array"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.op_Inequality(System.Span{`0},System.Span{`0})">
|
||||
<param name="left"></param>
|
||||
<param name="right"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.Slice(System.Int32)">
|
||||
<param name="start"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.Slice(System.Int32,System.Int32)">
|
||||
<param name="start"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.ToArray">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.Span`1.TryCopyTo(System.Span{`0})">
|
||||
<param name="destination"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:System.SpanExtensions">
|
||||
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.AsBytes``1(System.ReadOnlySpan{``0})">
|
||||
<param name="source"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.AsBytes``1(System.Span{``0})">
|
||||
<param name="source"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.AsSpan(System.String)">
|
||||
<param name="text"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.AsSpan``1(System.ArraySegment{``0})">
|
||||
<param name="arraySegment"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.AsSpan``1(``0[])">
|
||||
<param name="array"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.CopyTo``1(``0[],System.Span{``0})">
|
||||
<param name="array"></param>
|
||||
<param name="destination"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf(System.Span{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf(System.Span{System.Byte},System.Byte)">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf(System.ReadOnlySpan{System.Byte},System.Byte)">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf(System.ReadOnlySpan{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf``1(System.ReadOnlySpan{``0},System.ReadOnlySpan{``0})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf``1(System.ReadOnlySpan{``0},``0)">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf``1(System.Span{``0},System.ReadOnlySpan{``0})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOf``1(System.Span{``0},``0)">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOfAny(System.ReadOnlySpan{System.Byte},System.Byte,System.Byte,System.Byte)">
|
||||
<param name="span"></param>
|
||||
<param name="value0"></param>
|
||||
<param name="value1"></param>
|
||||
<param name="value2"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOfAny(System.Span{System.Byte},System.Byte,System.Byte,System.Byte)">
|
||||
<param name="span"></param>
|
||||
<param name="value0"></param>
|
||||
<param name="value1"></param>
|
||||
<param name="value2"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOfAny(System.Span{System.Byte},System.Byte,System.Byte)">
|
||||
<param name="span"></param>
|
||||
<param name="value0"></param>
|
||||
<param name="value1"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOfAny(System.ReadOnlySpan{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="span"></param>
|
||||
<param name="values"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOfAny(System.Span{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="span"></param>
|
||||
<param name="values"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.IndexOfAny(System.ReadOnlySpan{System.Byte},System.Byte,System.Byte)">
|
||||
<param name="span"></param>
|
||||
<param name="value0"></param>
|
||||
<param name="value1"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.NonPortableCast``2(System.ReadOnlySpan{``0})">
|
||||
<param name="source"></param>
|
||||
<typeparam name="TFrom"></typeparam>
|
||||
<typeparam name="TTo"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.NonPortableCast``2(System.Span{``0})">
|
||||
<param name="source"></param>
|
||||
<typeparam name="TFrom"></typeparam>
|
||||
<typeparam name="TTo"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.SequenceEqual(System.ReadOnlySpan{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="first"></param>
|
||||
<param name="second"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.SequenceEqual(System.Span{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="first"></param>
|
||||
<param name="second"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.SequenceEqual``1(System.ReadOnlySpan{``0},System.ReadOnlySpan{``0})">
|
||||
<param name="first"></param>
|
||||
<param name="second"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.SequenceEqual``1(System.Span{``0},System.ReadOnlySpan{``0})">
|
||||
<param name="first"></param>
|
||||
<param name="second"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.StartsWith(System.ReadOnlySpan{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.StartsWith(System.Span{System.Byte},System.ReadOnlySpan{System.Byte})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.StartsWith``1(System.ReadOnlySpan{``0},System.ReadOnlySpan{``0})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.SpanExtensions.StartsWith``1(System.Span{``0},System.ReadOnlySpan{``0})">
|
||||
<param name="span"></param>
|
||||
<param name="value"></param>
|
||||
<typeparam name="T"></typeparam>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:System.ReadOnlySpan`1">
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.#ctor(`0[])">
|
||||
<param name="array"></param>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.#ctor(System.Void*,System.Int32)">
|
||||
<param name="pointer"></param>
|
||||
<param name="length"></param>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.#ctor(`0[],System.Int32)">
|
||||
<param name="array"></param>
|
||||
<param name="start"></param>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.#ctor(`0[],System.Int32,System.Int32)">
|
||||
<param name="array"></param>
|
||||
<param name="start"></param>
|
||||
<param name="length"></param>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.CopyTo(System.Span{`0})">
|
||||
<param name="destination"></param>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.DangerousCreate(System.Object,`0@,System.Int32)">
|
||||
<param name="obj"></param>
|
||||
<param name="objectData"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.DangerousGetPinnableReference">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.ReadOnlySpan`1.Empty">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.Equals(System.Object)">
|
||||
<param name="obj"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.GetHashCode">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.ReadOnlySpan`1.IsEmpty">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.ReadOnlySpan`1.Item(System.Int32)">
|
||||
<param name="index"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:System.ReadOnlySpan`1.Length">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.op_Equality(System.ReadOnlySpan{`0},System.ReadOnlySpan{`0})">
|
||||
<param name="left"></param>
|
||||
<param name="right"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.op_Implicit(System.ArraySegment{T})~System.ReadOnlySpan{T}">
|
||||
<param name="arraySegment"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.op_Implicit(T[])~System.ReadOnlySpan{T}">
|
||||
<param name="array"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.op_Inequality(System.ReadOnlySpan{`0},System.ReadOnlySpan{`0})">
|
||||
<param name="left"></param>
|
||||
<param name="right"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.Slice(System.Int32)">
|
||||
<param name="start"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.Slice(System.Int32,System.Int32)">
|
||||
<param name="start"></param>
|
||||
<param name="length"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.ToArray">
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:System.ReadOnlySpan`1.TryCopyTo(System.Span{`0})">
|
||||
<param name="destination"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,200 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><doc>
|
||||
<assembly>
|
||||
<name>System.Runtime.CompilerServices.Unsafe</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:System.Runtime.CompilerServices.Unsafe">
|
||||
<summary>Contains generic, low-level functionality for manipulating pointers.</summary>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(``0@,System.Int32)">
|
||||
<summary>Adds an element offset to the given reference.</summary>
|
||||
<param name="source">The reference to add the offset to.</param>
|
||||
<param name="elementOffset">The offset to add.</param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>A new reference that reflects the addition of offset to pointer.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(``0@,System.IntPtr)">
|
||||
<summary>Adds an element offset to the given reference.</summary>
|
||||
<param name="source">The reference to add the offset to.</param>
|
||||
<param name="elementOffset">The offset to add.</param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>A new reference that reflects the addition of offset to pointer.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.AddByteOffset``1(``0@,System.IntPtr)">
|
||||
<summary>Adds a byte offset to the given reference.</summary>
|
||||
<param name="source">The reference to add the offset to.</param>
|
||||
<param name="byteOffset">The offset to add.</param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>A new reference that reflects the addition of byte offset to pointer.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.AreSame``1(``0@,``0@)">
|
||||
<summary>Determines whether the specified references point to the same location.</summary>
|
||||
<param name="left">The first reference to compare.</param>
|
||||
<param name="right">The second reference to compare.</param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>true if <paramref name="left">left</paramref> and <paramref name="right">right</paramref> point to the same location; otherwise, false.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.As``1(System.Object)">
|
||||
<summary>Casts the given object to the specified type.</summary>
|
||||
<param name="o">The object to cast.</param>
|
||||
<typeparam name="T">The type which the object will be cast to.</typeparam>
|
||||
<returns>The original object, casted to the given type.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.As``2(``0@)">
|
||||
<summary>Reinterprets the given reference as a reference to a value of type <typeparamref name="TTo">TTo</typeparamref>.</summary>
|
||||
<param name="source">The reference to reinterpret.</param>
|
||||
<typeparam name="TFrom">The type of reference to reinterpret..</typeparam>
|
||||
<typeparam name="TTo">The desired type of the reference.</typeparam>
|
||||
<returns>A reference to a value of type <typeparamref name="TTo">TTo</typeparamref>.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.AsPointer``1(``0@)">
|
||||
<summary>Returns a pointer to the given by-ref parameter.</summary>
|
||||
<param name="value">The object whose pointer is obtained.</param>
|
||||
<typeparam name="T">The type of object.</typeparam>
|
||||
<returns>A pointer to the given value.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.AsRef``1(System.Void*)">
|
||||
<summary>Reinterprets the given location as a reference to a value of type <typeparamref name="T">T</typeparamref>.</summary>
|
||||
<param name="source">The location of the value to reference.</param>
|
||||
<typeparam name="T">The type of the interpreted location.</typeparam>
|
||||
<returns>A reference to a value of type <typeparamref name="T">T</typeparamref>.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.ByteOffset``1(``0@,``0@)">
|
||||
<summary>Determines the byte offset from origin to target from the given references.</summary>
|
||||
<param name="origin">The reference to origin.</param>
|
||||
<param name="target">The reference to target.</param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>Byte offset from origin to target i.e. <paramref name="target">target</paramref> - <paramref name="origin">origin</paramref>.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Copy``1(System.Void*,``0@)">
|
||||
<summary>Copies a value of type <typeparamref name="T">T</typeparamref> to the given location.</summary>
|
||||
<param name="destination">The location to copy to.</param>
|
||||
<param name="source">A reference to the value to copy.</param>
|
||||
<typeparam name="T">The type of value to copy.</typeparam>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Copy``1(``0@,System.Void*)">
|
||||
<summary>Copies a value of type <typeparamref name="T">T</typeparamref> to the given location.</summary>
|
||||
<param name="destination">The location to copy to.</param>
|
||||
<param name="source">A pointer to the value to copy.</param>
|
||||
<typeparam name="T">The type of value to copy.</typeparam>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Byte@,System.Byte@,System.UInt32)">
|
||||
<summary>Copies bytes from the source address to the destination address.</summary>
|
||||
<param name="destination">The destination address to copy to.</param>
|
||||
<param name="source">The source address to copy from.</param>
|
||||
<param name="byteCount">The number of bytes to copy.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Void*,System.Void*,System.UInt32)">
|
||||
<summary>Copies bytes from the source address to the destination address.</summary>
|
||||
<param name="destination">The destination address to copy to.</param>
|
||||
<param name="source">The source address to copy from.</param>
|
||||
<param name="byteCount">The number of bytes to copy.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Void*,System.Void*,System.UInt32)">
|
||||
<summary>Copies bytes from the source address to the destination address
|
||||
without assuming architecture dependent alignment of the addresses.</summary>
|
||||
<param name="destination">The destination address to copy to.</param>
|
||||
<param name="source">The source address to copy from.</param>
|
||||
<param name="byteCount">The number of bytes to copy.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Byte@,System.Byte@,System.UInt32)">
|
||||
<summary>Copies bytes from the source address to the destination address
|
||||
without assuming architecture dependent alignment of the addresses.</summary>
|
||||
<param name="destination">The destination address to copy to.</param>
|
||||
<param name="source">The source address to copy from.</param>
|
||||
<param name="byteCount">The number of bytes to copy.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Byte@,System.Byte,System.UInt32)">
|
||||
<summary>Initializes a block of memory at the given location with a given initial value.</summary>
|
||||
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||
<param name="value">The value to initialize the block to.</param>
|
||||
<param name="byteCount">The number of bytes to initialize.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Void*,System.Byte,System.UInt32)">
|
||||
<summary>Initializes a block of memory at the given location with a given initial value.</summary>
|
||||
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||
<param name="value">The value to initialize the block to.</param>
|
||||
<param name="byteCount">The number of bytes to initialize.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Byte@,System.Byte,System.UInt32)">
|
||||
<summary>Initializes a block of memory at the given location with a given initial value
|
||||
without assuming architecture dependent alignment of the address.</summary>
|
||||
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||
<param name="value">The value to initialize the block to.</param>
|
||||
<param name="byteCount">The number of bytes to initialize.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Void*,System.Byte,System.UInt32)">
|
||||
<summary>Initializes a block of memory at the given location with a given initial value
|
||||
without assuming architecture dependent alignment of the address.</summary>
|
||||
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||
<param name="value">The value to initialize the block to.</param>
|
||||
<param name="byteCount">The number of bytes to initialize.</param>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Read``1(System.Void*)">
|
||||
<summary>Reads a value of type <typeparamref name="T">T</typeparamref> from the given location.</summary>
|
||||
<param name="source">The location to read from.</param>
|
||||
<typeparam name="T">The type to read.</typeparam>
|
||||
<returns>An object of type <typeparamref name="T">T</typeparamref> read from the given location.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.ReadUnaligned``1(System.Byte@)">
|
||||
<summary>Reads a value of type <typeparamref name="T">T</typeparamref> from the given location
|
||||
without assuming architecture dependent alignment of the addresses.</summary>
|
||||
<param name="source">The location to read from.</param>
|
||||
<typeparam name="T">The type to read.</typeparam>
|
||||
<returns>An object of type <typeparamref name="T">T</typeparamref> read from the given location.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.ReadUnaligned``1(System.Void*)">
|
||||
<summary>Reads a value of type <typeparamref name="T">T</typeparamref> from the given location
|
||||
without assuming architecture dependent alignment of the addresses.</summary>
|
||||
<param name="source">The location to read from.</param>
|
||||
<typeparam name="T">The type to read.</typeparam>
|
||||
<returns>An object of type <typeparamref name="T">T</typeparamref> read from the given location.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.SizeOf``1">
|
||||
<summary>Returns the size of an object of the given type parameter.</summary>
|
||||
<typeparam name="T">The type of object whose size is retrieved.</typeparam>
|
||||
<returns>The size of an object of type <typeparamref name="T">T</typeparamref>.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(``0@,System.Int32)">
|
||||
<summary>Subtracts an element offset from the given reference.</summary>
|
||||
<param name="source">The reference to subtract the offset from.</param>
|
||||
<param name="elementOffset">The offset to subtract.</param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>A new reference that reflects the subraction of offset from pointer.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(``0@,System.IntPtr)">
|
||||
<summary>Subtracts an element offset from the given reference.</summary>
|
||||
<param name="source">The reference to subtract the offset from.</param>
|
||||
<param name="elementOffset">The offset to subtract.</param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>A new reference that reflects the subraction of offset from pointer.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.SubtractByteOffset``1(``0@,System.IntPtr)">
|
||||
<summary>Subtracts a byte offset from the given reference.</summary>
|
||||
<param name="source">The reference to subtract the offset from.</param>
|
||||
<param name="byteOffset"></param>
|
||||
<typeparam name="T">The type of reference.</typeparam>
|
||||
<returns>A new reference that reflects the subraction of byte offset from pointer.</returns>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.Write``1(System.Void*,``0)">
|
||||
<summary>Writes a value of type <typeparamref name="T">T</typeparamref> to the given location.</summary>
|
||||
<param name="destination">The location to write to.</param>
|
||||
<param name="value">The value to write.</param>
|
||||
<typeparam name="T">The type of value to write.</typeparam>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.WriteUnaligned``1(System.Byte@,``0)">
|
||||
<summary>Writes a value of type <typeparamref name="T">T</typeparamref> to the given location
|
||||
without assuming architecture dependent alignment of the addresses.</summary>
|
||||
<param name="destination">The location to write to.</param>
|
||||
<param name="value">The value to write.</param>
|
||||
<typeparam name="T">The type of value to write.</typeparam>
|
||||
</member>
|
||||
<member name="M:System.Runtime.CompilerServices.Unsafe.WriteUnaligned``1(System.Void*,``0)">
|
||||
<summary>Writes a value of type <typeparamref name="T">T</typeparamref> to the given location
|
||||
without assuming architecture dependent alignment of the addresses.</summary>
|
||||
<param name="destination">The location to write to.</param>
|
||||
<param name="value">The value to write.</param>
|
||||
<typeparam name="T">The type of value to write.</typeparam>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
@ -1,582 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Response{
|
||||
repeated Message messages = 1;
|
||||
string cursor = 2;
|
||||
int64 fetchInterval = 3;
|
||||
int64 now = 4;
|
||||
string internalExt = 5;
|
||||
int32 fetchType = 6;
|
||||
map<string, string> routeParams = 7;
|
||||
int64 heartbeatDuration = 8;
|
||||
bool needAck = 9;
|
||||
string pushServer = 10;
|
||||
string liveCursor = 11;
|
||||
bool historyNoMore = 12;
|
||||
}
|
||||
|
||||
message Message{
|
||||
string method = 1;
|
||||
bytes payload = 2;
|
||||
int64 msgId = 3;
|
||||
int32 msgType = 4;
|
||||
int64 offset = 5;
|
||||
}
|
||||
|
||||
message RoomUserSeqMessage {
|
||||
Common common = 1;
|
||||
repeated Contributor ranks = 2;
|
||||
int64 total = 3;
|
||||
string popStr = 4;
|
||||
repeated Contributor seats = 5;
|
||||
int64 popularity = 6;
|
||||
int64 totalUser = 7;
|
||||
string totalUserStr = 8;
|
||||
string totalStr = 9;
|
||||
string onlineUserForAnchor = 10;
|
||||
string totalPvForAnchor = 11;
|
||||
|
||||
message Contributor {
|
||||
int64 score = 1;
|
||||
User user = 2;
|
||||
int64 rank = 3;
|
||||
int64 delta = 4;
|
||||
bool isHidden = 5;
|
||||
string scoreDescription = 6;
|
||||
string exactlyScore = 7;
|
||||
}
|
||||
}
|
||||
|
||||
message GiftMessage {
|
||||
Common common = 1;
|
||||
int64 giftId = 2;
|
||||
int64 fanTicketCount = 3;
|
||||
int64 groupCount = 4;
|
||||
int64 repeatCount = 5;
|
||||
int64 comboCount = 6;
|
||||
User user = 7;
|
||||
User toUser = 8;
|
||||
int32 repeatEnd = 9;
|
||||
TextEffect textEffect = 10;
|
||||
int64 groupId = 11;
|
||||
int64 incomeTaskgifts = 12;
|
||||
int64 roomFanTicketCount = 13;
|
||||
GiftIMPriority priority = 14;
|
||||
GiftStruct gift = 15;
|
||||
string logId = 16;
|
||||
int64 sendType = 17;
|
||||
PublicAreaCommon publicAreaCommon = 18;
|
||||
Text trayDisplayText = 19;
|
||||
int64 bannedDisplayEffects = 20;
|
||||
GiftTrayInfo trayInfo = 21;
|
||||
AssetEffectMixInfo assetEffectMixInfo = 24;
|
||||
|
||||
message TextEffect{
|
||||
Detail portrait = 1;
|
||||
Detail landscape = 2;
|
||||
|
||||
message Detail {
|
||||
Text text = 1;
|
||||
int32 textFontSize = 2;
|
||||
Image background = 3;
|
||||
int32 start = 4;
|
||||
int32 duration = 5;
|
||||
int32 x = 6;
|
||||
int32 y = 7;
|
||||
int32 width = 8;
|
||||
int32 height = 9;
|
||||
int32 shadowDx = 10;
|
||||
int32 shadowDy = 11;
|
||||
int32 shadowRadius = 12;
|
||||
string shadowColor = 13;
|
||||
string strokeColor = 14;
|
||||
int32 strokeWidth = 15;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message LikeMessage {
|
||||
Common common = 1;
|
||||
int64 count = 2;
|
||||
int64 total = 3;
|
||||
int64 color = 4;
|
||||
User user = 5;
|
||||
string icon = 6;
|
||||
}
|
||||
|
||||
message ChatMessage {
|
||||
Common common = 1;
|
||||
User user = 2;
|
||||
string content = 3;
|
||||
bool visibleToSender = 4;
|
||||
Image backgroundImage = 5;
|
||||
string fullScreenTextColor = 6;
|
||||
Image backgroundImageV2 = 7;
|
||||
PublicAreaCommon publicAreaCommon = 9;
|
||||
Image giftImage = 10;
|
||||
}
|
||||
|
||||
message SocialMessage {
|
||||
Common common = 1;
|
||||
User user = 2;
|
||||
int64 shareType = 3;
|
||||
int64 action = 4;
|
||||
string shareTarget = 5;
|
||||
int64 followCount = 6;
|
||||
PublicAreaCommon publicAreaCommon = 7;
|
||||
}
|
||||
|
||||
message MemberMessage{
|
||||
Common common = 1;
|
||||
User user = 2;
|
||||
int64 memberCount = 3;
|
||||
User operator = 4;
|
||||
bool isSetToAdmin = 5;
|
||||
bool isTopUser = 6;
|
||||
int64 rankScore = 7;
|
||||
int64 topUserNo = 8;
|
||||
int64 enterType = 9;
|
||||
int64 action = 10;
|
||||
string actionDescription = 11;
|
||||
int64 userId = 12;
|
||||
EffectConfig effectConfig = 13;
|
||||
string popStr = 14;
|
||||
EffectConfig enterEffectConfig = 15;
|
||||
Image backgroundImage = 16;
|
||||
Image backgroundImageV2 = 17;
|
||||
Text anchorDisplayText = 18;
|
||||
PublicAreaCommon publicAreaCommon = 19;
|
||||
|
||||
message EffectConfig{
|
||||
int64 type = 1;
|
||||
Image icon = 2;
|
||||
int64 avatarPos = 3;
|
||||
Text text = 4;
|
||||
Image textIcon = 5;
|
||||
int32 stayTime = 6;
|
||||
int64 animAssetId = 7;
|
||||
Image badge = 8;
|
||||
repeated int64 flexSettingArray = 9;
|
||||
Image textIconOverlay = 10;
|
||||
Image animatedBadge = 11;
|
||||
bool hasSweepLight = 12;
|
||||
repeated int64 textFlexSettingArray = 13;
|
||||
int64 centerAnimAssetId = 14;
|
||||
}
|
||||
}
|
||||
|
||||
message ControlMessage {
|
||||
Common common = 1;
|
||||
int32 status = 2;
|
||||
}
|
||||
|
||||
message FansclubMessage {
|
||||
Common commonInfo = 1;
|
||||
// 升级是1,加入是2
|
||||
int32 type = 2;
|
||||
string content = 3;
|
||||
User user = 4;
|
||||
}
|
||||
|
||||
message Common{
|
||||
string method = 1;
|
||||
int64 msgId = 2;
|
||||
int64 roomId = 3;
|
||||
int64 createTime = 4;
|
||||
int32 monitor = 5;
|
||||
bool isShowMsg = 6;
|
||||
string describe = 7;
|
||||
Text displayText = 8;
|
||||
int64 foldType = 9;
|
||||
int64 anchorFoldType = 10;
|
||||
int64 priorityScore = 11;
|
||||
string logId = 12;
|
||||
string msgProcessFilterK = 13;
|
||||
string msgProcessFilterV = 14;
|
||||
User user = 15;
|
||||
Room room = 16;
|
||||
int64 anchorFoldTypeV2 = 17;
|
||||
int64 processAtSeiTimeMs = 18;
|
||||
}
|
||||
|
||||
message Text{
|
||||
string key = 1;
|
||||
string defaultPattern = 2;
|
||||
TextFormat defaultFormat = 3;
|
||||
repeated TextPiece pieces = 4;
|
||||
}
|
||||
|
||||
message Room {
|
||||
int64 id = 1;
|
||||
string idStr = 2;
|
||||
int64 status = 3;
|
||||
int64 ownerUserId = 4;
|
||||
string title = 5;
|
||||
int64 userCount = 6;
|
||||
int64 createTime = 7;
|
||||
int64 linkmicLayout = 8;
|
||||
int64 finishTime = 9;
|
||||
RoomExtra extra = 10;
|
||||
string dynamicCoverUri = 11;
|
||||
map<int64, string> dynamicCoverDict = 12;
|
||||
int64 lastPingTime = 13;
|
||||
int64 liveId = 14;
|
||||
int64 streamProvider = 15;
|
||||
int64 osType = 16;
|
||||
int64 clientVersion = 17;
|
||||
bool withLinkmic = 18;
|
||||
bool enableRoomPerspective = 19;
|
||||
Image cover = 20;
|
||||
Image dynamicCover = 21;
|
||||
Image dynamicCoverLow = 22;
|
||||
string shareUrl = 23;
|
||||
string anchorShareText = 24;
|
||||
string userShareText = 25;
|
||||
int64 streamId = 26;
|
||||
string streamIdStr = 27;
|
||||
StreamUrl streamUrl = 28;
|
||||
int64 mosaicStatus = 29;
|
||||
string mosaicTip = 30;
|
||||
int64 cellStyle = 31;
|
||||
LinkMic linkMic = 32;
|
||||
int64 luckymoneyNum = 33;
|
||||
repeated Decoration decoList = 34;
|
||||
repeated TopFan topFans = 35;
|
||||
RoomStats stats = 36;
|
||||
string sunDailyIconContent = 37;
|
||||
string distance = 38;
|
||||
string distanceCity = 39;
|
||||
string location = 40;
|
||||
string realDistance = 41;
|
||||
Image feedRoomLabel = 42;
|
||||
string commonLabelList = 43;
|
||||
RoomUserAttr livingRoomAttrs = 44;
|
||||
repeated int64 adminUserIds = 45;
|
||||
User owner = 46;
|
||||
string privateInfo = 47;
|
||||
}
|
||||
|
||||
message RoomExtra{
|
||||
|
||||
}
|
||||
|
||||
message RoomStats{
|
||||
|
||||
}
|
||||
|
||||
message RoomUserAttr{
|
||||
|
||||
}
|
||||
|
||||
message StreamUrl{
|
||||
|
||||
}
|
||||
|
||||
message LinkMic {
|
||||
|
||||
}
|
||||
|
||||
message Decoration{
|
||||
|
||||
}
|
||||
|
||||
message TopFan {
|
||||
|
||||
}
|
||||
|
||||
message User{
|
||||
int64 id = 1;
|
||||
int64 shortId = 2;
|
||||
string nickname = 3;
|
||||
int32 gender = 4;
|
||||
string signature = 5;
|
||||
int32 level = 6;
|
||||
int64 birthday = 7;
|
||||
string telephone = 8;
|
||||
Image avatarThumb = 9;
|
||||
Image avatarMedium = 10;
|
||||
Image avatarLarge = 11;
|
||||
bool verified = 12;
|
||||
int32 experience = 13;
|
||||
string city = 14;
|
||||
int32 status = 15;
|
||||
int64 createTime = 16;
|
||||
int64 modifyTime = 17;
|
||||
int32 secret = 18;
|
||||
string shareQrcodeUri = 19;
|
||||
int32 incomeSharePercent = 20;
|
||||
Image badgeImageList = 21;
|
||||
FollowInfo followInfo = 22;
|
||||
PayGrade payGrade = 23;
|
||||
FansClub fansClub = 24;
|
||||
Border border = 25;
|
||||
string specialId = 26;
|
||||
Image avatarBorder = 27;
|
||||
Image medal = 28;
|
||||
repeated Image realTimeIcons = 29;
|
||||
repeated Image newRealTimeIcons = 30;
|
||||
int64 topVipNo = 31;
|
||||
UserAttr userAttr = 32;
|
||||
OwnRoom ownRoom = 33;
|
||||
int64 payScore = 34;
|
||||
int64 ticketCount = 35;
|
||||
AnchorInfo anchorInfo = 36;
|
||||
int32 linkMicStats = 37;
|
||||
string displayId = 38;
|
||||
|
||||
message UserAttr {
|
||||
|
||||
}
|
||||
|
||||
message OwnRoom {
|
||||
|
||||
}
|
||||
|
||||
message AnchorInfo {
|
||||
|
||||
}
|
||||
|
||||
message FollowInfo {
|
||||
int64 followingCount = 1;
|
||||
int64 followerCount = 2;
|
||||
int64 followStatus = 3;
|
||||
int64 pushStatus = 4;
|
||||
string remarkName = 5;
|
||||
}
|
||||
|
||||
message FansClub{
|
||||
FansClubData data = 1;
|
||||
map<int32, FansClubData> preferData = 2;
|
||||
|
||||
message FansClubData {
|
||||
string clubName = 1;
|
||||
int32 level = 2;
|
||||
int32 userFansClubStatus = 3;
|
||||
UserBadge badge = 4;
|
||||
repeated int64 availableGiftIds = 5;
|
||||
int64 anchorId = 6;
|
||||
|
||||
message UserBadge {
|
||||
map<int32, Image> icons = 1;
|
||||
string title = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message Border{
|
||||
|
||||
}
|
||||
|
||||
message GradeBuffInfo {
|
||||
int64 buffLevel = 1;
|
||||
int32 status = 2;
|
||||
int64 endTime = 3;
|
||||
map<int64, int64> statsInfo = 4;
|
||||
Image buffBadge = 5;
|
||||
}
|
||||
|
||||
message PayGrade {
|
||||
int64 totalDiamondCount = 1;
|
||||
Image diamondIcon = 2;
|
||||
string name = 3;
|
||||
Image icon = 4;
|
||||
string nextName = 5;
|
||||
int64 level = 6;
|
||||
Image nextIcon = 7;
|
||||
int64 nextDiamond = 8;
|
||||
int64 nowDiamond = 9;
|
||||
int64 thisGradeMinDiamond = 10;
|
||||
int64 thisGradeMaxDiamond = 11;
|
||||
int64 payDiamondBak = 12;
|
||||
string gradeDescribe = 13;
|
||||
repeated GradeIcon gradeIconList = 14;
|
||||
int64 screenChatType = 15;
|
||||
Image imIcon = 16;
|
||||
Image imIconWithLevel = 17;
|
||||
Image liveIcon = 18;
|
||||
Image newImIconWithLevel = 19;
|
||||
Image newLiveIcon = 20;
|
||||
int64 upgradeNeedConsume = 21;
|
||||
string nextPrivileges = 22;
|
||||
Image background = 23;
|
||||
Image backgroundBack = 24;
|
||||
int64 score = 25;
|
||||
GradeBuffInfo buffInfo = 26;
|
||||
string gradeBanner = 1001;
|
||||
Image profileDialogBg = 1002;
|
||||
Image profileDialogBgBack = 1003;
|
||||
|
||||
message GradeIcon{
|
||||
Image icon = 1;
|
||||
int64 iconDiamond = 2;
|
||||
int64 level = 3;
|
||||
string levelStr = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message TextFormat{
|
||||
string color = 1;
|
||||
bool bold = 2;
|
||||
bool italic = 3;
|
||||
int32 weight = 4;
|
||||
int32 italicAngle = 5;
|
||||
int32 fontSize = 6;
|
||||
bool userHeightLightColor = 7;
|
||||
bool useRemoteClor = 8;
|
||||
}
|
||||
|
||||
message TextPiece{
|
||||
int32 type = 1;
|
||||
TextFormat format = 2;
|
||||
string stringValue = 11;
|
||||
TextPieceUser userValue = 21;
|
||||
}
|
||||
|
||||
message Image{
|
||||
repeated string urlList = 1;
|
||||
string uri = 2;
|
||||
int64 height = 3;
|
||||
int64 width = 4;
|
||||
string avgColor = 5;
|
||||
int32 imageType = 6;
|
||||
string openWebUrl = 7;
|
||||
Content content = 8;
|
||||
bool isAnimated = 9;
|
||||
|
||||
message Content {
|
||||
string name = 1;
|
||||
string fontColor = 2;
|
||||
int64 level = 3;
|
||||
string alternativeText = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message TextPieceUser{
|
||||
User user = 1;
|
||||
bool withColon = 2;
|
||||
}
|
||||
|
||||
message PublicAreaCommon {
|
||||
Image userLabel = 1;
|
||||
int64 userConsumeInRoom = 2;
|
||||
int64 userSendGiftCntInRoom = 3;
|
||||
}
|
||||
|
||||
message GiftIMPriority {
|
||||
repeated int64 queueSizes = 1;
|
||||
int64 selfQueuePriority = 2;
|
||||
int64 priority = 3;
|
||||
}
|
||||
|
||||
message GiftTrayInfo{
|
||||
Text trayDisplayText = 1;
|
||||
Image trayBaseImg = 2;
|
||||
Image trayHeadImg = 3;
|
||||
Image trayRightImg = 4;
|
||||
int64 trayLevel = 5;
|
||||
Image trayDynamicImg = 6;
|
||||
}
|
||||
|
||||
message GiftStruct {
|
||||
Image image = 1;
|
||||
string describe = 2;
|
||||
bool notify = 3;
|
||||
int64 duration = 4;
|
||||
int64 id = 5;
|
||||
GiftStructFansClubInfo fansclubInfo = 6;
|
||||
bool forLinkmic = 7;
|
||||
bool doodle = 8;
|
||||
bool forFansclub = 9;
|
||||
bool combo = 10;
|
||||
int32 type = 11;
|
||||
int32 diamondCount = 12;
|
||||
int32 isDisplayedOnPanel = 13;
|
||||
int64 primaryEffectId = 14;
|
||||
Image giftLabelIcon = 15;
|
||||
string name = 16;
|
||||
string region = 17;
|
||||
string manual = 18;
|
||||
bool forCustom = 19;
|
||||
map<string, int64> specialEffects = 20;
|
||||
Image icon = 21;
|
||||
int32 actionType = 22;
|
||||
int32 watermelonSeeds = 23;
|
||||
string goldEffect = 24;
|
||||
repeated LuckyMoneyGiftMeta subs = 25;
|
||||
int64 goldenBeans = 26;
|
||||
int64 honorLevel = 27;
|
||||
int32 itemType = 28;
|
||||
string schemeUrl = 29;
|
||||
GiftPanelOperation giftOperation = 30;
|
||||
string eventName = 31;
|
||||
int64 nobleLevel = 32;
|
||||
string guideUrl = 33;
|
||||
bool punishMedicine = 34;
|
||||
bool forPortal = 35;
|
||||
string businessText = 36;
|
||||
bool cnyGift = 37;
|
||||
int64 appId = 38;
|
||||
int64 vipLevel = 39;
|
||||
bool isGray = 40;
|
||||
string graySchemeUrl = 41;
|
||||
int64 giftScene = 42;
|
||||
GiftBanner giftBanner = 43;
|
||||
repeated string triggerWords = 44;
|
||||
repeated GiftBuffInfo giftBuffInfos = 45;
|
||||
bool forFirstRecharge = 46;
|
||||
Image dynamicImgForSelected = 47;
|
||||
int32 afterSendAction = 48;
|
||||
int64 giftOfflineTime = 49;
|
||||
string topBarText = 50;
|
||||
Image topRightAvatar = 51;
|
||||
string bannerSchemeUrl = 52;
|
||||
bool isLocked = 53;
|
||||
int64 reqExtraType = 54;
|
||||
repeated int64 assetIds = 55;
|
||||
GiftPreviewInfo giftPreviewInfo = 56;
|
||||
GiftTip giftTip = 57;
|
||||
int32 needSweepLightCount = 58;
|
||||
repeated GiftGroupInfo groupInfo = 59;
|
||||
|
||||
message GiftStructFansClubInfo {
|
||||
int32 minLevel = 1;
|
||||
int32 insertPos = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message AssetEffectMixInfo{
|
||||
|
||||
}
|
||||
|
||||
message LuckyMoneyGiftMeta {
|
||||
|
||||
}
|
||||
|
||||
message GiftPanelOperation {
|
||||
|
||||
}
|
||||
|
||||
message GiftBanner {
|
||||
|
||||
}
|
||||
|
||||
message GiftBuffInfo{
|
||||
|
||||
}
|
||||
|
||||
message GiftPreviewInfo{
|
||||
|
||||
}
|
||||
|
||||
message GiftTip {
|
||||
|
||||
}
|
||||
|
||||
message GiftGroupInfo {
|
||||
|
||||
}
|
||||
|
||||
message EffectMixImageInfo {
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message WssResponse{
|
||||
uint64 seqid = 1;
|
||||
uint64 logid = 2;
|
||||
uint64 service = 3;
|
||||
uint64 method = 4;
|
||||
map<string,string> headers = 5;
|
||||
string payloadEncoding = 6;
|
||||
string payloadType = 7;
|
||||
bytes payload = 8;
|
||||
}
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<!--过滤Websocket数据源进程,可用','进行分隔,程序将会监听以下进程的弹幕信息-->
|
||||
<add key="filterProcess" value="直播伴侣,chrome,msedge" />
|
||||
<!--Websocket监听端口-->
|
||||
<add key="wsListenPort" value="8888" />
|
||||
<!--在控制台输出弹幕-->
|
||||
<add key="printBarrage" value="on" />
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
</appSettings>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
<providers>
|
||||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
|
||||
</providers>
|
||||
</membership>
|
||||
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
|
||||
<providers>
|
||||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
|
||||
</providers>
|
||||
</roleManager>
|
||||
</system.web>
|
||||
</configuration>
|
Binary file not shown.
@ -50,11 +50,11 @@ class Content_Db:
|
||||
conn = sqlite3.connect("fay.db")
|
||||
cur = conn.cursor()
|
||||
if(way == 'all'):
|
||||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg order by createtime "+order+" limit ?",(limit,))
|
||||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg order by id "+order+" limit ?",(limit,))
|
||||
elif(way == 'notappended'):
|
||||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way != 'appended' order by createtime "+order+" limit ?",(limit,))
|
||||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way != 'appended' order by id "+order+" limit ?",(limit,))
|
||||
else:
|
||||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way = ? order by createtime "+order+" limit ?",(way,limit,))
|
||||
cur.execute("select type,way,content,createtime,datetime(createtime, 'unixepoch', 'localtime') as timetext from T_Msg where way = ? order by id "+order+" limit ?",(way,limit,))
|
||||
|
||||
list = cur.fetchall()
|
||||
conn.close()
|
||||
|
@ -237,6 +237,9 @@ class FeiFei:
|
||||
# self.__isExecute = True #!!!!
|
||||
|
||||
if index == 1:
|
||||
contentdb = Content_Db()
|
||||
contentdb.add_content('member','speak',self.q_msg)
|
||||
wsa_server.get_web_instance().add_cmd({"panelReply": {"type":"member","content":self.q_msg}})
|
||||
answer = self.__get_answer(interact.interleaver, self.q_msg)
|
||||
if self.muting:
|
||||
continue
|
||||
@ -276,8 +279,7 @@ class FeiFei:
|
||||
self.a_msg = text
|
||||
else:
|
||||
self.a_msg = user_name + ',' + text
|
||||
contentdb = Content_Db()
|
||||
contentdb.add_content('member','speak',self.q_msg)
|
||||
|
||||
contentdb.add_content('fay','speak',self.a_msg)
|
||||
wsa_server.get_web_instance().add_cmd({"panelReply": {"type":"fay","content":self.a_msg}})
|
||||
if len(textlist) > 1:
|
||||
|
@ -4,9 +4,11 @@ import time
|
||||
from abc import abstractmethod
|
||||
|
||||
from ai_module.ali_nls import ALiNls
|
||||
from ai_module.funasr import FunASR
|
||||
from core import wsa_server
|
||||
from scheduler.thread_manager import MyThread
|
||||
from utils import util
|
||||
from utils import config_util as cfg
|
||||
|
||||
|
||||
# 启动时间 (秒)
|
||||
@ -32,7 +34,17 @@ class Recorder:
|
||||
self.__MAX_LEVEL = 25000
|
||||
self.__MAX_BLOCK = 100
|
||||
|
||||
self.__aLiNls = ALiNls()
|
||||
#Edit by xszyou in 20230516:增加本地asr
|
||||
self.ASRMode = cfg.ASR_mode
|
||||
self.__aLiNls = self.asrclient()
|
||||
|
||||
|
||||
def asrclient(self):
|
||||
if self.ASRMode == "ali":
|
||||
asrcli = ALiNls()
|
||||
elif self.ASRMode == "funasr":
|
||||
asrcli = FunASR()
|
||||
return asrcli
|
||||
|
||||
|
||||
|
||||
@ -62,7 +74,7 @@ class Recorder:
|
||||
text += "-"
|
||||
print(text + " [" + str(int(per * 100)) + "%]")
|
||||
|
||||
def __waitingResult(self, iat: ALiNls):
|
||||
def __waitingResult(self, iat):
|
||||
if self.__fay.playing:
|
||||
return
|
||||
self.processing = True
|
||||
@ -117,7 +129,7 @@ class Recorder:
|
||||
soon = True #
|
||||
isSpeaking = True #用户正在说话
|
||||
util.log(3, "聆听中...")
|
||||
self.__aLiNls = ALiNls()
|
||||
self.__aLiNls = self.asrclient()
|
||||
try:
|
||||
self.__aLiNls.start()
|
||||
except Exception as e:
|
||||
@ -158,4 +170,3 @@ class Recorder:
|
||||
@abstractmethod
|
||||
def get_stream(self):
|
||||
pass
|
||||
|
||||
|
3
main.py
3
main.py
@ -43,7 +43,8 @@ if __name__ == '__main__':
|
||||
ws_server.start_server()
|
||||
web_ws_server = wsa_server.new_web_instance(port=10003)
|
||||
web_ws_server.start_server()
|
||||
|
||||
#Edit by xszyou in 20230516:增加本地asr
|
||||
if config_util.ASR_mode == "ali" and config_util.config['source']['record']:
|
||||
ali_nls.start()
|
||||
flask_server.start()
|
||||
app = QApplication(sys.argv)
|
||||
|
@ -18,3 +18,4 @@ simhash
|
||||
pytz
|
||||
gevent~=22.10.1
|
||||
edge_tts~=6.1.3
|
||||
eyed3
|
18
system.conf
18
system.conf
@ -1,10 +1,18 @@
|
||||
|
||||
[key]
|
||||
# 阿里云 实时语音识别 服务密钥(必须)https://ai.aliyun.com/nls/trans
|
||||
#funasr / ali
|
||||
ASR_mode = ali
|
||||
#ASR二选一(需要运行fay/test/funasr服务)集成达摩院asr项目、感谢中科大脑算法工程师张聪聪提供集成代码
|
||||
local_asr_ip=127.0.0.1
|
||||
local_asr_port=10197
|
||||
|
||||
# ASR二选一(第1次运行建议用这个,免费3个月), 阿里云 实时语音识别 服务密钥(必须)https://ai.aliyun.com/nls/trans
|
||||
ali_nls_key_id=
|
||||
ali_nls_key_secret=
|
||||
ali_nls_app_key=
|
||||
|
||||
|
||||
|
||||
# 微软 文字转语音 服务密钥(非必须,使用可产生不同情绪的音频)https://azure.microsoft.com/zh-cn/services/cognitive-services/text-to-speech/
|
||||
ms_tts_key=
|
||||
ms_tts_region=
|
||||
@ -14,17 +22,17 @@ xf_ltp_app_id=
|
||||
xf_ltp_api_key=
|
||||
|
||||
#NLP四选一:xfaiui、yuan、chatgpt、rasa(需启动chatglm及rasa,https://m.bilibili.com/video/BV1D14y1f7pr)
|
||||
chat_module=
|
||||
chat_module=xfaiui
|
||||
|
||||
# 讯飞 自然语言处理 服务密钥(NLP4选1) https://aiui.xfyun.cn/solution/webapi/
|
||||
# 讯飞 自然语言处理 服务密钥(NLP3选1) https://aiui.xfyun.cn/solution/webapi/
|
||||
xf_aiui_app_id=
|
||||
xf_aiui_api_key=
|
||||
|
||||
#浪.潮源大模型 服务密钥(NLP4选1) https://air.inspur.com/
|
||||
#浪.潮源大模型 服务密钥(NLP3选1) https://air.inspur.com/
|
||||
yuan_1_0_account=
|
||||
yuan_1_0_phone=
|
||||
|
||||
#gpt 服务密钥(NLP4选1) https://openai.com/
|
||||
#gpt 服务密钥(NLP3选1) https://openai.com/
|
||||
chatgpt_api_key=
|
||||
|
||||
#ngrok内网穿透id,远程设备可以通过互联网连接Fay(非必须)http://ngrok.cc
|
||||
|
94
test/funasr/ASR_client.py
Normal file
94
test/funasr/ASR_client.py
Normal file
@ -0,0 +1,94 @@
|
||||
import pyaudio
|
||||
import websockets
|
||||
import asyncio
|
||||
from queue import Queue
|
||||
import argparse
|
||||
import json
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--host",
|
||||
type=str,
|
||||
default="172.16.77.144",
|
||||
required=False,
|
||||
help="host ip, localhost, 0.0.0.0")
|
||||
parser.add_argument("--port",
|
||||
type=int,
|
||||
default=10194,
|
||||
required=False,
|
||||
help="grpc server port")
|
||||
parser.add_argument("--chunk_size",
|
||||
type=int,
|
||||
default=160,
|
||||
help="ms")
|
||||
parser.add_argument("--vad_needed",
|
||||
type=bool,
|
||||
default=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
voices = Queue()
|
||||
|
||||
async def record():
|
||||
global voices
|
||||
FORMAT = pyaudio.paInt16
|
||||
CHANNELS = 1
|
||||
RATE = 16000
|
||||
CHUNK = int(RATE / 1000 * args.chunk_size)
|
||||
|
||||
p = pyaudio.PyAudio()
|
||||
|
||||
stream = p.open(format=FORMAT,
|
||||
channels=CHANNELS,
|
||||
rate=RATE,
|
||||
input=True,
|
||||
frames_per_buffer=CHUNK)
|
||||
|
||||
while True:
|
||||
data = stream.read(CHUNK)
|
||||
voices.put(data)
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
async def ws_send():
|
||||
global voices
|
||||
global websocket
|
||||
print("started to sending data!")
|
||||
#设置传入参数,是否需要vad
|
||||
data_head = {
|
||||
'vad_need': args.vad_needed,
|
||||
'state': ''
|
||||
}
|
||||
if type(data_head) == dict:
|
||||
await websocket.send(json.dumps(data_head))
|
||||
|
||||
while True:
|
||||
while not voices.empty():
|
||||
data = voices.get()
|
||||
voices.task_done()
|
||||
try:
|
||||
|
||||
if type(data) == bytes:
|
||||
await websocket.send(data) # 通过ws对象发送数据
|
||||
except Exception as e:
|
||||
print('Exception occurred:', e)
|
||||
await asyncio.sleep(0.01)
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
async def message():
|
||||
global websocket
|
||||
while True:
|
||||
try:
|
||||
print(await websocket.recv())
|
||||
except Exception as e:
|
||||
print("Exception:", e)
|
||||
|
||||
async def ws_client():
|
||||
global websocket # 定义一个全局变量ws,用于保存websocket连接对象
|
||||
# uri = "ws://11.167.134.197:8899"
|
||||
uri = "ws://{}:{}".format(args.host, args.port)
|
||||
async for websocket in websockets.connect(uri, subprotocols=["binary"], ping_interval=None):
|
||||
task1 = asyncio.create_task(record()) # 创建一个后台任务录音
|
||||
task2 = asyncio.create_task(ws_send()) # 创建一个后台任务发送
|
||||
task3 = asyncio.create_task(message()) # 创建一个后台接收消息的任务
|
||||
await asyncio.gather(task1, task2, task3)
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(ws_client()) # 启动协程
|
||||
asyncio.get_event_loop().run_forever()
|
199
test/funasr/ASR_server.py
Normal file
199
test/funasr/ASR_server.py
Normal file
@ -0,0 +1,199 @@
|
||||
import asyncio
|
||||
import websockets
|
||||
import time
|
||||
from queue import Queue
|
||||
import threading
|
||||
import argparse
|
||||
import json
|
||||
from modelscope.pipelines import pipeline
|
||||
from modelscope.utils.constant import Tasks
|
||||
from modelscope.utils.logger import get_logger
|
||||
import logging
|
||||
import tracemalloc
|
||||
import functools
|
||||
tracemalloc.start()
|
||||
|
||||
logger = get_logger(log_level=logging.CRITICAL)
|
||||
logger.setLevel(logging.CRITICAL)
|
||||
|
||||
|
||||
websocket_users = set() #维护客户端列表
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--host",
|
||||
type=str,
|
||||
default="0.0.0.0",
|
||||
required=False,
|
||||
help="host ip, localhost, 0.0.0.0")
|
||||
parser.add_argument("--port",
|
||||
type=int,
|
||||
default=10197,
|
||||
required=False,
|
||||
help="grpc server port")
|
||||
parser.add_argument("--model",
|
||||
type=str,
|
||||
default="./data/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404",
|
||||
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("--ngpu",
|
||||
type=int,
|
||||
default=1,
|
||||
help="0 for cpu, 1 for gpu")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print("model loading")
|
||||
# asr
|
||||
param_dict_asr = {}
|
||||
param_dict_asr['hotword']="data/hotword.txt"
|
||||
inference_pipeline_asr = pipeline(
|
||||
task=Tasks.auto_speech_recognition,
|
||||
model=args.model,
|
||||
param_dict=param_dict_asr,
|
||||
ngpu=args.ngpu
|
||||
)
|
||||
if args.punc_model != "":
|
||||
# param_dict_punc = {'cache': list()}
|
||||
inference_pipeline_punc = pipeline(
|
||||
task=Tasks.punctuation,
|
||||
model=args.punc_model,
|
||||
model_revision=None,
|
||||
ngpu=args.ngpu,
|
||||
)
|
||||
else:
|
||||
inference_pipeline_punc = None
|
||||
|
||||
|
||||
# vad
|
||||
inference_pipeline_vad = pipeline(
|
||||
task=Tasks.voice_activity_detection,
|
||||
model=args.vad_model,
|
||||
model_revision='v1.2.0',
|
||||
output_dir=None,
|
||||
batch_size=1,
|
||||
mode='online',
|
||||
ngpu=args.ngpu,
|
||||
)
|
||||
print("model loaded")
|
||||
|
||||
|
||||
def vad(data, websocket): # VAD推理
|
||||
global inference_pipeline_vad
|
||||
segments_result = inference_pipeline_vad(audio_in=data, param_dict=websocket.param_dict_vad)
|
||||
speech_start = False
|
||||
speech_end = False
|
||||
|
||||
if len(segments_result) == 0 or len(segments_result["text"]) > 1:
|
||||
return speech_start, speech_end
|
||||
if segments_result["text"][0][0] != -1:
|
||||
speech_start = True
|
||||
if segments_result["text"][0][1] != -1:
|
||||
speech_end = True
|
||||
return speech_start, speech_end
|
||||
|
||||
|
||||
async def ws_serve(websocket,path):
|
||||
|
||||
frames = [] # 存储所有的帧数据
|
||||
buffer = [] # 存储缓存中的帧数据(最多两个片段)
|
||||
RECORD_NUM = 0
|
||||
global websocket_users
|
||||
speech_start, speech_end = False, False
|
||||
# 调用asr函数
|
||||
websocket.param_dict_vad = {'in_cache': dict(), "is_final": False}
|
||||
websocket.param_dict_punc = {'cache': list()}
|
||||
websocket.speek = Queue() # websocket 添加进队列对象 让asr读取语音数据包
|
||||
websocket.send_msg = Queue() # websocket 添加个队列对象 让ws发送消息到客户端
|
||||
websocket_users.add(websocket)
|
||||
ss = threading.Thread(target=asr, args=(websocket,))
|
||||
ss.start()
|
||||
try:
|
||||
async for message in websocket:
|
||||
if (type(message) == str):
|
||||
dict_message = json.loads(message)
|
||||
if dict_message['vad_need'] == True:
|
||||
vad_method = True
|
||||
else:
|
||||
vad_method = False
|
||||
if vad_method == True:
|
||||
if type(message) != str:
|
||||
buffer.append(message)
|
||||
if len(buffer) > 2:
|
||||
buffer.pop(0) # 如果缓存超过两个片段,则删除最早的一个
|
||||
|
||||
if speech_start:
|
||||
frames.append(message)
|
||||
RECORD_NUM += 1
|
||||
if type(message) != str:
|
||||
speech_start_i, speech_end_i = vad(message, websocket)
|
||||
# print(speech_start_i, speech_end_i)
|
||||
if speech_start_i:
|
||||
speech_start = speech_start_i
|
||||
frames = []
|
||||
frames.extend(buffer) # 把之前2个语音数据快加入
|
||||
if speech_end_i or RECORD_NUM > 300:
|
||||
speech_start = False
|
||||
audio_in = b"".join(frames)
|
||||
websocket.speek.put(audio_in)
|
||||
frames = [] # 清空所有的帧数据
|
||||
buffer = [] # 清空缓存中的帧数据(最多两个片段)
|
||||
RECORD_NUM = 0
|
||||
if not websocket.send_msg.empty():
|
||||
await websocket.send(websocket.send_msg.get())
|
||||
websocket.send_msg.task_done()
|
||||
else:
|
||||
if speech_start :
|
||||
frames.append(message)
|
||||
RECORD_NUM += 1
|
||||
if (type(message) == str):
|
||||
dict_message = json.loads(message)
|
||||
if dict_message['vad_need'] == False and dict_message['state'] == 'StartTranscription':
|
||||
speech_start = True
|
||||
elif dict_message['vad_need'] == False and dict_message['state'] == 'StopTranscription':
|
||||
speech_start = False
|
||||
speech_end = True
|
||||
if len(frames) != 0:
|
||||
frames.pop()
|
||||
if speech_end or RECORD_NUM > 1024:
|
||||
speech_start = False
|
||||
speech_end = False
|
||||
audio_in = b"".join(frames)
|
||||
websocket.speek.put(audio_in)
|
||||
frames = [] # 清空所有的帧数据
|
||||
RECORD_NUM = 0
|
||||
await websocket.send(websocket.send_msg.get())
|
||||
websocket.send_msg.task_done()
|
||||
except websockets.ConnectionClosed:
|
||||
print("ConnectionClosed...", websocket_users) # 链接断开
|
||||
websocket_users.remove(websocket)
|
||||
except websockets.InvalidState:
|
||||
print("InvalidState...") # 无效状态
|
||||
except Exception as e:
|
||||
print("Exception:", e)
|
||||
|
||||
|
||||
|
||||
def asr(websocket): # ASR推理
|
||||
global inference_pipeline_asr, inference_pipeline_punc
|
||||
# global param_dict_punc
|
||||
global websocket_users
|
||||
while websocket in websocket_users:
|
||||
# if not websocket.speek.empty():
|
||||
audio_in = websocket.speek.get()
|
||||
websocket.speek.task_done()
|
||||
if len(audio_in) > 0:
|
||||
rec_result = inference_pipeline_asr(audio_in=audio_in)
|
||||
if "text" in rec_result:
|
||||
websocket.send_msg.put(rec_result["text"]) # 存入发送队列 直接调用send发送不了
|
||||
time.sleep(0.1)
|
||||
|
||||
start_server = websockets.serve(ws_serve, args.host, args.port, subprotocols=["binary"], ping_interval=None)
|
||||
asyncio.get_event_loop().run_until_complete(start_server)
|
||||
asyncio.get_event_loop().run_forever()
|
36
test/funasr/README.md
Normal file
36
test/funasr/README.md
Normal file
@ -0,0 +1,36 @@
|
||||
## 语音服务介绍
|
||||
|
||||
该服务以modelscope funasr语音识别为基础
|
||||
|
||||
|
||||
## Install
|
||||
pip install torch
|
||||
pip install modelscope
|
||||
pip install testresources
|
||||
pip install websockets
|
||||
pip install torchaudio
|
||||
git clone https://github.com/alibaba-damo-academy/FunASR.git
|
||||
pip install ./FunASR(若editdistance编译不通过,请手动安装 pip install editdistance,在FunASR/setup.py也注释掉,再执行)
|
||||
|
||||
|
||||
|
||||
## Start server
|
||||
1、从百度网盘下载并解压模型文件到fay/test/funasr/data目录
|
||||
链接:https://pan.baidu.com/s/17SJqWIo9zeGAZxPCMIsHJA?pwd=5fzr
|
||||
提取码:5fzr
|
||||
|
||||
2、python -u ASR_server.py --host "0.0.0.0" --port 10197 --ngpu 0 --model ./data/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404
|
||||
|
||||
## Fay connect
|
||||
更改fay/system.conf配置项,并重新启动fay.
|
||||
|
||||
https://www.bilibili.com/video/BV1qs4y1g74e/?share_source=copy_web&vd_source=64cd9062f5046acba398177b62bea9ad
|
||||
|
||||
|
||||
## Acknowledge
|
||||
感谢
|
||||
1. 中科大脑算法工程师张聪聪
|
||||
2. [cgisky1980](https://github.com/cgisky1980/FunASR)
|
||||
3. [modelscope](https://github.com/modelscope/modelscope)
|
||||
4. [FunASR](https://github.com/alibaba-damo-academy/FunASR)
|
||||
5. [Fay数字人助理](https://github.com/TheRamU/Fay).
|
0
test/funasr/data/hotword.txt
Normal file
0
test/funasr/data/hotword.txt
Normal file
BIN
test/rasa/models/20230424-153214-bisque-customer.tar.gz
Normal file
BIN
test/rasa/models/20230424-153214-bisque-customer.tar.gz
Normal file
Binary file not shown.
@ -22,6 +22,10 @@ key_yuan_1_0_phone = None
|
||||
key_chatgpt_api_key = None
|
||||
key_chat_module = None
|
||||
|
||||
ASR_mode = None
|
||||
local_asr_ip = None
|
||||
local_asr_port = None
|
||||
|
||||
def load_config():
|
||||
global config
|
||||
global system_config
|
||||
@ -40,6 +44,10 @@ def load_config():
|
||||
global key_chatgpt_api_key
|
||||
global key_chat_module
|
||||
|
||||
global ASR_mode
|
||||
global local_asr_ip
|
||||
global local_asr_port
|
||||
|
||||
system_config = ConfigParser()
|
||||
system_config.read('system.conf', encoding='UTF-8')
|
||||
key_ali_nls_key_id = system_config.get('key', 'ali_nls_key_id')
|
||||
@ -57,6 +65,10 @@ def load_config():
|
||||
key_chatgpt_api_key = system_config.get('key', 'chatgpt_api_key')
|
||||
key_chat_module = system_config.get('key', 'chat_module')
|
||||
|
||||
ASR_mode = system_config.get('key', 'ASR_mode')
|
||||
local_asr_ip = system_config.get('key', 'local_asr_ip')
|
||||
local_asr_port = system_config.get('key', 'local_asr_port')
|
||||
|
||||
config = json.load(codecs.open('config.json', encoding='utf-8'))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user