Skip to content

Commit

Permalink
tweak reaction to message without voice, also react on process start
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Apr 28, 2024
1 parent 1ff79b7 commit edd29da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion voice2text_deltabot/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def on_newmsg(bot: Bot, accid: int, event: NewMsgEvent) -> None:
return

if msg.view_type in (MessageViewtype.VOICE, MessageViewtype.AUDIO):
bot.rpc.send_reaction(accid, msg.id, ["⏳"])
start = time.time()
segments, info = MODEL.transcribe(msg.file)
lines = []
Expand All @@ -118,10 +119,11 @@ def on_newmsg(bot: Bot, accid: int, event: NewMsgEvent) -> None:
f" language={info.language} (probability={percent}%) took {took:.1f} seconds"
)
if lines:
bot.rpc.send_reaction(accid, msg.id, [])
reply = MsgData(text="\n".join(lines), quoted_message_id=msg.id)
bot.rpc.send_msg(accid, msg.chat_id, reply)
else:
bot.rpc.send_reaction(accid, msg.id, ["😶"])
bot.rpc.send_reaction(accid, msg.id, ["🎶"])
elif chat.chat_type == ChatType.SINGLE:
reply = MsgData(text=HELP)
bot.rpc.send_msg(accid, msg.chat_id, reply)

0 comments on commit edd29da

Please sign in to comment.