action
All checks were successful
Deploy WebSocket Server / deploy (push) Successful in 18s

This commit is contained in:
jeremygan2021
2026-03-05 20:56:21 +08:00
parent 6a64c54cae
commit a784c88c60
5 changed files with 108 additions and 10 deletions

View File

@@ -57,9 +57,10 @@ def image_to_tspl_commands(image_path):
# 逻辑修正:
# 我们希望 黑色像素(0) -> 打印(1)
# 白色像素(255) -> 不打印(0)
# 使用 < 128 判定,增加容错性,防止像素值偏移
should_print = False
if pixel == 0: # Black
if pixel < 128: # Black or Dark Gray
should_print = True
if should_print:

View File

@@ -569,8 +569,8 @@ def optimize_prompt(asr_text, progress_callback=None):
1. 风格必须是:简单的黑白线稿、简笔画、图标风格 (Line art, Sketch, Icon style)。
2. 画面必须清晰、线条粗壮,适合低分辨率热敏打印机打印。
3. 绝对不要有复杂的阴影、渐变、黑白线条描述。
4. 背景必须是纯白 (White background)。
5. 提示词内容请使用英文描述,因为绘图模型对英文理解更好,但在描述中强调 "black and white line art", "simple lines", "vector style"
4. 背景必须是纯白 (White background),线条要粗方便打印
5. 提示词内容请使用英文描述,因为绘图模型对英文理解更好,但在描述中强调 "black and white line art", "bold simple lines", "vector style"
6. 尺寸比例遵循宽48mm:高30mm (约 1.6:1)。
7. 直接输出优化后的提示词,不要包含任何解释。"""
@@ -1025,4 +1025,5 @@ if __name__ == "__main__":
local_ip = socket.gethostbyname(hostname)
print(f"Server running on ws://{local_ip}:8000/ws/audio")
uvicorn.run(app, host="0.0.0.0", port=8000)
# 禁用自动Ping以避免并发写入冲突 (ws_ping_interval=None)
uvicorn.run(app, host="0.0.0.0", port=8000, ws_ping_interval=None, ws_ping_timeout=None)