Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SAGIRI-kawaii committed Mar 31, 2022
1 parent b537020 commit dc70783
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sagiri_bot/handler/handlers/pica/Pica.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, account, password):
self.password = password
self.header = header.copy()
self.header["nonce"] = uuid_s
loop.run_until_complete(self.check())
asyncio.run_coroutine_threadsafe(self.check(), loop)

async def check(self):
try:
Expand Down
9 changes: 5 additions & 4 deletions sagiri_bot/handler/handlers/speak.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import json
import uuid
import base64
Expand All @@ -17,7 +18,7 @@
from graia.ariadne.message.parser.twilight import Twilight
from graia.ariadne.event.message import Group, GroupMessage
from graia.saya.builtins.broadcast.schema import ListenerSchema
from graia.ariadne.message.parser.twilight import FullMatch, RegexMatch, RegexResult
from graia.ariadne.message.parser.twilight import FullMatch, WildcardMatch, RegexResult

from tencentcloud.common import credential
from tencentcloud.tts.v20190823 import tts_client, models
Expand Down Expand Up @@ -45,7 +46,7 @@
@channel.use(
ListenerSchema(
listening_events=[GroupMessage],
inline_dispatchers=[Twilight([FullMatch("说"), RegexMatch(r"[^\s]+") @ "content"])],
inline_dispatchers=[Twilight([FullMatch("说"), WildcardMatch().flags(re.DOTALL) @ "content"])],
decorators=[
FrequencyLimit.require("speak", 1),
Function.require(channel.module),
Expand All @@ -60,7 +61,7 @@ async def speak(app: Ariadne, message: MessageChain, group: Group, content: Rege
if isinstance(voice, str):
await app.sendGroupMessage(group, MessageChain(voice), quote=message.getFirst(Source))
elif isinstance(voice, bytes):
await app.sendGroupMessage(group, MessageChain([Voice(data_bytes=await silkcoder.encode(voice))]))
await app.sendGroupMessage(group, MessageChain([Voice(data_bytes=await silkcoder.async_encode(voice))]))


class Speak(object):
Expand Down Expand Up @@ -116,7 +117,7 @@ async def get_long_voice(voice_type: Union[int, str], text: str):
"ModelType": 1,
"VoiceType": int(voice_type),
"Volume": 10,
"Codec": "wav"
# "Codec": "wav"
}
req.from_json_string(json.dumps(params))
resp = client.CreateTtsTask(req)
Expand Down

0 comments on commit dc70783

Please sign in to comment.