Commit 356905a

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-05-09 13:47:50
style(asr): keep original caption
1 parent 1908bea
Changed files (1)
src/asr/voice_recognition.py
@@ -7,6 +7,7 @@ from pathlib import Path
 
 from loguru import logger
 from pyrogram.client import Client
+from pyrogram.enums import ParseMode
 from pyrogram.types import Message
 
 from asr.ali_asr import ali_asr
@@ -143,13 +144,20 @@ async def voice_to_text(
         elif length < TEXT_LENGTH:  # middle
             await client.send_message(to_int(target_chat), final, reply_parameters=reply_parameters)
         else:  # long
-            caption = ""
+            caption = trigger_info["html"]
             if to_telegraph:
                 html = "\n".join([f"<p>{s}</p>" for s in texts.split("\n")])
                 if telegraph_url := await publish_telegraph(title=trigger_info["text"] or "语音识别结果", html=html, author=trigger_info["full_name"], url=trigger_info["message_url"]):
-                    caption = f"⚡️[Telegraph即时预览]({telegraph_url})"
+                    caption += f"\n<a href={telegraph_url}>⚡️Telegraph即时预览</a>"
             with io.BytesIO(texts.encode("utf-8")) as f:
-                await client.send_document(to_int(target_chat), f, file_name="语音识别结果.txt", caption=caption, reply_parameters=reply_parameters)
+                await client.send_document(
+                    to_int(target_chat),
+                    f,
+                    parse_mode=ParseMode.HTML,
+                    file_name="语音识别结果.txt",
+                    caption=caption.strip(),
+                    reply_parameters=reply_parameters,
+                )
         await modify_progress(del_status=True, **kwargs)
 
     with contextlib.suppress(Exception):