mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 08:41:29 +00:00
Add voice recognition
This commit is contained in:
12
commands/natural_language.py
Normal file
12
commands/natural_language.py
Normal file
@ -0,0 +1,12 @@
|
||||
import jieba
|
||||
|
||||
from command import CommandRegistry
|
||||
|
||||
__registry__ = cr = CommandRegistry()
|
||||
|
||||
|
||||
@cr.register('process')
|
||||
@cr.restrict(full_command_only=True)
|
||||
def process(args_text, ctx_msg, internal=False):
|
||||
print('自然语言消息处理', args_text)
|
||||
print(list(jieba.cut_for_search(args_text)))
|
@ -97,6 +97,6 @@ def translate_to(args_text, ctx_msg):
|
||||
data = resp.json()
|
||||
print(data)
|
||||
if 'trans_result' in data:
|
||||
core.echo('翻译结果:\n' + '\n'.join([x['dst'] for x in data['trans_result']]), ctx_msg)
|
||||
core.echo('翻译结果(百度翻译):\n' + '\n'.join([x['dst'] for x in data['trans_result']]), ctx_msg)
|
||||
return
|
||||
core.echo('翻译失败,可能因为后台接口的频率限制或服务器连接不上', ctx_msg)
|
||||
|
Reference in New Issue
Block a user