1
+ import re
1
2
import json
2
3
import uuid
3
4
import base64
17
18
from graia .ariadne .message .parser .twilight import Twilight
18
19
from graia .ariadne .event .message import Group , GroupMessage
19
20
from graia .saya .builtins .broadcast .schema import ListenerSchema
20
- from graia .ariadne .message .parser .twilight import FullMatch , RegexMatch , RegexResult
21
+ from graia .ariadne .message .parser .twilight import FullMatch , WildcardMatch , RegexResult
21
22
22
23
from tencentcloud .common import credential
23
24
from tencentcloud .tts .v20190823 import tts_client , models
45
46
@channel .use (
46
47
ListenerSchema (
47
48
listening_events = [GroupMessage ],
48
- inline_dispatchers = [Twilight ([FullMatch ("说" ), RegexMatch ( r"[^\s]+" ) @ "content" ])],
49
+ inline_dispatchers = [Twilight ([FullMatch ("说" ), WildcardMatch (). flags ( re . DOTALL ) @ "content" ])],
49
50
decorators = [
50
51
FrequencyLimit .require ("speak" , 1 ),
51
52
Function .require (channel .module ),
@@ -60,7 +61,7 @@ async def speak(app: Ariadne, message: MessageChain, group: Group, content: Rege
60
61
if isinstance (voice , str ):
61
62
await app .sendGroupMessage (group , MessageChain (voice ), quote = message .getFirst (Source ))
62
63
elif isinstance (voice , bytes ):
63
- await app .sendGroupMessage (group , MessageChain ([Voice (data_bytes = await silkcoder .encode (voice ))]))
64
+ await app .sendGroupMessage (group , MessageChain ([Voice (data_bytes = await silkcoder .async_encode (voice ))]))
64
65
65
66
66
67
class Speak (object ):
@@ -116,7 +117,7 @@ async def get_long_voice(voice_type: Union[int, str], text: str):
116
117
"ModelType" : 1 ,
117
118
"VoiceType" : int (voice_type ),
118
119
"Volume" : 10 ,
119
- "Codec" : "wav"
120
+ # "Codec": "wav"
120
121
}
121
122
req .from_json_string (json .dumps (params ))
122
123
resp = client .CreateTtsTask (req )
0 commit comments