feat(mytoolkit): add voice command and improve docx post-processing
- Add voice/TTS CLI command via Volcengine WebSocket API - Inject suppressAutoHyphens into all docx paragraphs in post-process - Apply post-process fixes to all templates (not just default) - Update review template: Cambria+SimSun fonts, 11pt for headings - Sync default/review docx template formatting
This commit is contained in:
+11
-3
@@ -113,8 +113,7 @@ def convert_cmd(inputs, output, template, quality, density, reference_doc, bookm
|
||||
if ref_doc:
|
||||
cmd.extend(["--reference-doc", ref_doc])
|
||||
run_command(cmd, check=True)
|
||||
if template == "default":
|
||||
_fix_docx_postprocess(out_path)
|
||||
_fix_docx_postprocess(out_path)
|
||||
click.secho(f"Word document generated: {output}", fg="green")
|
||||
return
|
||||
|
||||
@@ -352,9 +351,18 @@ def _fix_docx_postprocess(docx_path: Path) -> None:
|
||||
spacing.set(wtag("before"), "120")
|
||||
break
|
||||
|
||||
# --- 5. Inject suppressAutoHyphens into all paragraphs ---
|
||||
for p in body.findall(wtag("p")):
|
||||
pPr = p.find(wtag("pPr"))
|
||||
if pPr is None:
|
||||
pPr = ET.SubElement(p, wtag("pPr"))
|
||||
p.insert(0, pPr)
|
||||
if pPr.find(wtag("suppressAutoHyphens")) is None:
|
||||
ET.SubElement(pPr, wtag("suppressAutoHyphens"))
|
||||
|
||||
tree.write(doc_xml, xml_declaration=True, encoding="UTF-8", pretty_print=False)
|
||||
|
||||
# --- 5. Inject HorizontalRule style ---
|
||||
# --- 6. Inject HorizontalRule style ---
|
||||
styles_xml = os.path.join(workdir, "word", "styles.xml")
|
||||
styles_tree = ET.parse(styles_xml)
|
||||
styles_root = styles_tree.getroot()
|
||||
|
||||
Reference in New Issue
Block a user