From e03614a67442b2714bd85de5fcb049e94d4bbbbd Mon Sep 17 00:00:00 2001 From: ":NoBody:" Date: Mon, 18 May 2026 16:47:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0tts=E5=88=9D=E6=AD=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=EF=BC=8C=E5=A4=A7=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E6=94=B9=E7=94=A8lfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/fonts/.gitattributes | 6 + tools/discourse2md/.gitignore | 1 + tools/gp/.gitignore | 3 +- tools/gp/deno.json | 1 + tools/gp/deno.lock | 5 + tools/gp/main_test.ts | 44 ++- .../工农解放报RSF续刊第一期-适å�ˆæ‰‹æœºé˜…读.md | 2 +- .../工农解放报RSF续刊第一期-适å�ˆç”µè„‘阅读.md | 2 +- .../工农解放报RSF续刊第一期-适å�ˆçº¸è´¨æ‰“å�°.md | 2 +- tools/gp/pdf_builder/builder.ts | 11 +- tools/gp/pdf_builder/tts.ts | 63 +++++ tools/index.html | 255 ------------------ 12 files changed, 121 insertions(+), 274 deletions(-) create mode 100644 assets/fonts/.gitattributes create mode 100644 tools/discourse2md/.gitignore create mode 100644 tools/gp/pdf_builder/tts.ts delete mode 100644 tools/index.html diff --git a/assets/fonts/.gitattributes b/assets/fonts/.gitattributes new file mode 100644 index 0000000..c5fe78b --- /dev/null +++ b/assets/fonts/.gitattributes @@ -0,0 +1,6 @@ +HongLei.otf filter=lfs diff=lfs merge=lfs -text +R-PMingLiU.ttf filter=lfs diff=lfs merge=lfs -text +YangRenDongZhuShiTi-Regular.ttf filter=lfs diff=lfs merge=lfs -text +ZCOOLKuaiLe-Regular.ttf filter=lfs diff=lfs merge=lfs -text +ZCOOLQingKeHuangYou-Regular.ttf filter=lfs diff=lfs merge=lfs -text +AlimamaFangYuanTiVF-Thin.woff2 filter=lfs diff=lfs merge=lfs -text diff --git a/tools/discourse2md/.gitignore b/tools/discourse2md/.gitignore new file mode 100644 index 0000000..1d17dae --- /dev/null +++ b/tools/discourse2md/.gitignore @@ -0,0 +1 @@ +.venv diff --git a/tools/gp/.gitignore b/tools/gp/.gitignore index 6dcc7d5..f6c77c4 100644 --- a/tools/gp/.gitignore +++ b/tools/gp/.gitignore @@ -1,2 +1,3 @@ -./outputs/ + +outputs/* private_key.asc \ No newline at end of file diff --git a/tools/gp/deno.json b/tools/gp/deno.json index db21f5c..50386d5 100644 --- a/tools/gp/deno.json +++ b/tools/gp/deno.json @@ -5,6 +5,7 @@ "imports": { "@std/assert": "jsr:@std/assert@1", "@std/toml": "jsr:@std/toml@^1.0.11", + "fs": "npm:fs@^0.0.1-security", "markdown-it": "npm:markdown-it@^14.1.1", "openpgp": "npm:openpgp@^6.3.0", "pdf-lib": "npm:pdf-lib@^1.17.1", diff --git a/tools/gp/deno.lock b/tools/gp/deno.lock index 895a66f..12d21c1 100644 --- a/tools/gp/deno.lock +++ b/tools/gp/deno.lock @@ -5,6 +5,7 @@ "jsr:@std/collections@^1.1.3": "1.1.6", "jsr:@std/internal@^1.0.12": "1.0.12", "jsr:@std/toml@^1.0.11": "1.0.11", + "npm:fs@^0.0.1-security": "0.0.1-security", "npm:markdown-it@^14.1.1": "14.1.1", "npm:openpgp@^6.3.0": "6.3.0", "npm:pdf-lib@^1.17.1": "1.17.1", @@ -119,6 +120,9 @@ "entities@4.5.0": { "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==" }, + "fs@0.0.1-security": { + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" + }, "fsevents@2.3.2": { "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "os": ["darwin"], @@ -244,6 +248,7 @@ "dependencies": [ "jsr:@std/assert@1", "jsr:@std/toml@^1.0.11", + "npm:fs@^0.0.1-security", "npm:markdown-it@^14.1.1", "npm:openpgp@^6.3.0", "npm:pdf-lib@^1.17.1", diff --git a/tools/gp/main_test.ts b/tools/gp/main_test.ts index b54311d..e8e746d 100644 --- a/tools/gp/main_test.ts +++ b/tools/gp/main_test.ts @@ -32,17 +32,35 @@ import { PDFParse } from "pdf-parse"; // }, // }); -Deno.test({ - name: "OpenPGPSigner test", - sanitizeOps: false, - sanitizeResources: false, - async fn() { - const { OpenPGPSigner } = await import("./pdf_builder/builder.ts"); - const signer = new OpenPGPSigner( - "./outputs/mobile.pdf", - "./private_key.asc", - "./outputs/mobile.pdf.sig", - ); - await signer.sign(); - }, +// Deno.test({ +// name: "OpenPGPSigner test", +// sanitizeOps: false, +// sanitizeResources: false, +// async fn() { +// const { OpenPGPSigner } = await import("./pdf_builder/builder.ts"); +// const signer = new OpenPGPSigner( +// "./outputs/mobile.pdf", +// "./private_key.asc", +// "./outputs/mobile.pdf.sig", +// ); +// await signer.sign(); +// }, +// }); +import { writeFileSync } from "node:fs"; +Deno.test("TTS test", async () => { + const { PiperCloudTTS } = await import("./pdf_builder/tts.ts"); + + const tts = new PiperCloudTTS("https://piper.cmlmuf.org/"); + const contents = Deno.readTextFileSync( + "./outputs/工农解放报RSF续刊第一期-适å�ˆæ‰‹æœºé˜…读.md", + ); + + await tts.stream_to_file( + contents, + "zh_CN-xiao_ya-medium", + "./outputs/test_audio.wav", + 1000, + ); + + console.log("Audio streaming completed to ./outputs/test_audio.wav"); }); diff --git a/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆæ‰‹æœºé˜…读.md b/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆæ‰‹æœºé˜…读.md index b3c08f7..7bbada6 100644 --- a/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆæ‰‹æœºé˜…读.md +++ b/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆæ‰‹æœºé˜…读.md @@ -6,7 +6,7 @@ RSF续刊第一期 工农解放社-原é�©å‘½ç¤¾ä¼šä¸»ä¹‰é˜µåœ°(RSF)- 2026.5.16å�‘布 -/\*基础格å¼�部分\*/ .global { font-family: "AlimamaFangYuanTiVF-Thin", sans-serif; font-size: var(--font-size); margin: 1rem 2rem 2rem 2rem; line-height: 2.5rem; /\* letter-spacing: -0.15rem; \*/ } .global h1 { line-height: 4rem; font-family: "HongLei", sans-serif; } html, body { margin: 0; padding: 0; --font-size: 2rem; } /\*控件美化部分\*/ .c\_title { font-size: 3.5rem; color: white; background-color: red; border: 0.18rem solid red; display: inline-flex; width: fit-content; line-height: 1.5; padding: 0.08em 0.24em; white-space: normal; word-break: break-all; font-family: "ZCOOL QingKe HuangYou", sans-serif; margin: 2rem 1rem 0rem 2rem; border-radius: 0.5rem; overflow-wrap: break-word; max-width: 21cm; } blockquote { background-color: #f0f0f0; border-left: 0.5rem solid #ccc; padding: 0.5rem 1rem; margin: 1rem 0; color: #666; } .global img { max-width: 100%; height: auto; border-radius: 12px; border: 4px solid linear-gradient(45deg, #e799b1, #44b144, #2f90ba); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); display: block; margin: 1rem auto; /\* color: transparent; \*/ overflow: hidden; } .global a\[href\] { color: rgb(0, 180, 120); text-decoration: none; } /\*目录美化部分\*/ index h1 { font-size: 3.5rem; color: white; background-color: red; border: 0.18rem solid red; display: inline-flex; width: fit-content; line-height: 1.5; padding: 0.08em 0.24em; white-space: normal; word-break: break-all; font-family: "ZCOOL QingKe HuangYou", sans-serif; margin: 2rem 1rem 0rem 2rem; border-radius: 0.5rem; overflow-wrap: break-word; max-width: 21cm; } index a { text-decoration: none; font-size: var(--font-size); display: flex; width: 100%; justify-content: space-between; align-items: flex-start; gap: 0.75rem; } index ul { margin: 1rem 2rem 3rem 2rem; /\* padding: 0.5rem 1rem; \*/ } index li { list-style: none; display: flex; width: 100%; justify-content: space-between; align-items: flex-start; word-break: break-all; word-wrap: normal; line-height: 1.5; } index li page\_title { color: black; font-size: var(--font-size); font-weight: thin; position: static; flex: 1 1 auto; min-width: 0; white-space: normal; word-break: break-word; overflow-wrap: anywhere; } index li page\_num { color: black; font-size: var(--font-size); position: static; flex: 0 0 auto; min-width: 4ch; margin-left: 1rem; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; } @font-face { font-family: "Liu Jian Mao Cao"; src: url("http://127.0.0.1:8963/fonts/LiuJianMaoCao-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "YangRenDongZhuShiTi"; src: url("http://127.0.0.1:8963/fonts/YangRenDongZhuShiTi-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "ZCOOL QingKe HuangYou"; src: url("http://127.0.0.1:8963/fonts/ZCOOLQingKeHuangYou-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "ZCOOLKuaiLe"; src: url("http://127.0.0.1:8963/fonts/ZCOOLKuaiLe-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "MaShanZheng"; src: url("http://127.0.0.1:8963/fonts/MaShanZheng-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "HongLei"; src: url("http://127.0.0.1:8963/fonts/HongLei.otf") format("opentype"); font-display: swap; } @font-face { font-family: "Kai"; src: url("http://127.0.0.1:8963/fonts/Kai.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "AlimamaFangYuanTiVF-Thin"; src: url("http://127.0.0.1:8963/fonts/AlimamaFangYuanTiVF-Thin.woff2") format("woff2"); font-display: swap; } .zcool-qingke-huangyou-regular { font-family: "ZCOOL QingKe HuangYou", sans-serif; font-weight: 400; font-style: normal; } .liu-jian-mao-cao-regular { font-family: "Liu Jian Mao Cao", cursive; font-weight: 400; font-style: normal; } .zcool-kuai-le-regular { font-family: "ZCOOLKuaiLe", cursive; font-weight: 400; font-style: normal; } .ma-shan-zheng-regular { font-family: "MaShanZheng", cursive; font-weight: 400; font-style: normal; } .hong-lei-regular { font-family: "HongLei", regular; font-weight: 400; font-style: normal; } .yang-ren-dong-zhu-shi-ti-regular { font-family: "YangRenDongZhuShiTi", regular; font-weight: 400; font-style: normal; } .kai-regular { font-family: "Kai", regular; font-weight: 400; font-style: normal; } .alimama-fang-yuan-ti-vf-thin-regular { font-family: "AlimamaFangYuanTiVF-Thin", regular; font-weight: 400; font-style: normal; } 关于我们 +关于我们 关于我们 ==== diff --git a/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆç”µè„‘阅读.md b/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆç”µè„‘阅读.md index 1bdaae4..7bbada6 100644 --- a/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆç”µè„‘阅读.md +++ b/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆç”µè„‘阅读.md @@ -6,7 +6,7 @@ RSF续刊第一期 工农解放社-原é�©å‘½ç¤¾ä¼šä¸»ä¹‰é˜µåœ°(RSF)- 2026.5.16å�‘布 -/\*基础格å¼�部分\*/ .global { font-family: "AlimamaFangYuanTiVF-Thin", sans-serif; font-size: var(--font-size); margin: 1rem 2rem 2rem 2rem; line-height: 1.5rem; /\* letter-spacing: -0.15rem; \*/ } .global h1 { line-height: 4rem; font-family: "HongLei", sans-serif; } html, body { margin: 0; padding: 0; --font-size: 1.25rem; } /\*控件美化部分\*/ .c\_title { font-size: 3.5rem; color: white; background-color: red; border: 0.18rem solid red; display: inline-flex; width: fit-content; line-height: 1.5; padding: 0.08em 0.24em; white-space: normal; word-break: break-all; font-family: "ZCOOL QingKe HuangYou", sans-serif; margin: 2rem 1rem 0rem 2rem; border-radius: 0.5rem; overflow-wrap: break-word; max-width: 21cm; } blockquote { background-color: #f0f0f0; border-left: 0.5rem solid #ccc; padding: 0.5rem 1rem; margin: 1rem 0; color: #666; } .global img { height: 100%; object-fit: scale-down; max-width: 100%; max-height: 25cm; border-radius: 12px; border: 4px solid linear-gradient(45deg, #e799b1, #44b144, #2f90ba); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); display: block; margin: 1rem auto; /\* color: transparent; \*/ /\* overflow: hidden; \*/ } .global a\[href\] { color: rgb(0, 180, 120); text-decoration: none; } /\*目录美化部分\*/ index h1 { font-size: 3.5rem; color: white; background-color: red; border: 0.18rem solid red; display: inline-flex; width: fit-content; line-height: 1.5; padding: 0.08em 0.24em; white-space: normal; word-break: break-all; font-family: "ZCOOL QingKe HuangYou", sans-serif; margin: 2rem 1rem 0rem 2rem; border-radius: 0.5rem; overflow-wrap: break-word; max-width: 21cm; } index a { text-decoration: none; font-size: var(--font-size); display: flex; width: 100%; justify-content: space-between; align-items: flex-start; gap: 0.75rem; } index ul { margin: 1rem 2rem 3rem 2rem; /\* padding: 0.5rem 1rem; \*/ } index li { list-style: none; display: flex; width: 100%; justify-content: space-between; align-items: flex-start; word-break: break-all; word-wrap: normal; line-height: 1.5; } index li page\_title { color: black; font-size: var(--font-size); font-weight: thin; position: static; flex: 1 1 auto; min-width: 0; white-space: normal; word-break: break-word; overflow-wrap: anywhere; } index li page\_num { color: black; font-size: var(--font-size); position: static; flex: 0 0 auto; min-width: 4ch; margin-left: 1rem; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; } @font-face { font-family: "Liu Jian Mao Cao"; src: url("http://127.0.0.1:8963/fonts/LiuJianMaoCao-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "YangRenDongZhuShiTi"; src: url("http://127.0.0.1:8963/fonts/YangRenDongZhuShiTi-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "ZCOOL QingKe HuangYou"; src: url("http://127.0.0.1:8963/fonts/ZCOOLQingKeHuangYou-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "ZCOOLKuaiLe"; src: url("http://127.0.0.1:8963/fonts/ZCOOLKuaiLe-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "MaShanZheng"; src: url("http://127.0.0.1:8963/fonts/MaShanZheng-Regular.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "HongLei"; src: url("http://127.0.0.1:8963/fonts/HongLei.otf") format("opentype"); font-display: swap; } @font-face { font-family: "Kai"; src: url("http://127.0.0.1:8963/fonts/Kai.ttf") format("truetype"); font-display: swap; } @font-face { font-family: "AlimamaFangYuanTiVF-Thin"; src: url("http://127.0.0.1:8963/fonts/AlimamaFangYuanTiVF-Thin.woff2") format("woff2"); font-display: swap; } .zcool-qingke-huangyou-regular { font-family: "ZCOOL QingKe HuangYou", sans-serif; font-weight: 400; font-style: normal; } .liu-jian-mao-cao-regular { font-family: "Liu Jian Mao Cao", cursive; font-weight: 400; font-style: normal; } .zcool-kuai-le-regular { font-family: "ZCOOLKuaiLe", cursive; font-weight: 400; font-style: normal; } .ma-shan-zheng-regular { font-family: "MaShanZheng", cursive; font-weight: 400; font-style: normal; } .hong-lei-regular { font-family: "HongLei", regular; font-weight: 400; font-style: normal; } .yang-ren-dong-zhu-shi-ti-regular { font-family: "YangRenDongZhuShiTi", regular; font-weight: 400; font-style: normal; } .kai-regular { font-family: "Kai", regular; font-weight: 400; font-style: normal; } .alimama-fang-yuan-ti-vf-thin-regular { font-family: "AlimamaFangYuanTiVF-Thin", regular; font-weight: 400; font-style: normal; } 关于我们 +关于我们 关于我们 ==== diff --git a/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆçº¸è´¨æ‰“å�°.md b/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆçº¸è´¨æ‰“å�°.md index 459b467..ca32a56 100644 --- a/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆçº¸è´¨æ‰“å�°.md +++ b/tools/gp/outputs/工农解放报RSF续刊第一期-适å�ˆçº¸è´¨æ‰“å�°.md @@ -4,7 +4,7 @@ RSF续刊第一期 工农解放社-原é�©å‘½ç¤¾ä¼šä¸»ä¹‰é˜µåœ°(RSF)- 2026.5.16å�‘布 -/\*基础格å¼�部分\*/ .global { font-family: "R-PMingLiU", sans-serif; font-size: var(--font-size); margin: 1rem 4rem 2rem 4rem; line-height: 20px; /\* letter-spacing: -0.15rem; \*/ } .global h1 { line-height: 2rem; font-family: "R-PMingLiU", sans-serif; } .global p { margin: 15px 0; } html, body { margin: 0; padding: 0; --font-size: 16px; } /\*控件美化部分\*/ .c\_title { font-size: 2rem; color: red; display: inline-flex; width: fit-content; line-height: 1.5; padding: 0.08em 0.24em; white-space: normal; word-break: break-all; font-family: "R-PMingLiU", sans-serif; margin: 2rem 1rem 0rem 2rem; overflow-wrap: break-word; max-width: 21cm; } blockquote { border-left: 0.5rem solid #ccc; padding: 0.5rem 1rem; margin: 1rem 0; border-radius: 22px; border-color: #666; } .global img { height: 100%; object-fit: scale-down; max-width: 45%; max-height: 10cm; border-radius: 12px; border: 4px solid linear-gradient(45deg, #e799b1, #44b144, #2f90ba); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); display: block; margin: 1rem auto; /\* color: transparent; \*/ /\* overflow: hidden; \*/ } .global a\[href\] { color: rgb(0, 180, 120); text-decoration: none; } /\*目录美化部分\*/ index h1 { font-size: 1rem; color: black; border: 0.18rem solid red; display: inline-flex; width: fit-content; line-height: 1.5; padding: 0.08em 0.24em; white-space: normal; word-break: break-all; font-family: "R-PMingLiU", sans-serif; margin: 2rem 1rem 0rem 2rem; border-radius: 0.5rem; overflow-wrap: break-word; max-width: 21cm; } index a { text-decoration: none; font-size: var(--font-size); display: flex; width: 100%; justify-content: space-between; align-items: flex-start; gap: 0.75rem; } index ul { margin: 1rem 2rem 3rem 2rem; /\* padding: 0.5rem 1rem; \*/ } index li { list-style: none; display: flex; width: 100%; justify-content: space-between; align-items: flex-start; word-break: break-all; word-wrap: normal; line-height: 1.5; } index li page\_title { color: black; font-size: var(--font-size); font-weight: thin; position: static; flex: 1 1 auto; min-width: 0; white-space: normal; word-break: break-word; overflow-wrap: anywhere; } index li page\_num { color: black; font-size: var(--font-size); position: static; flex: 0 0 auto; min-width: 4ch; margin-left: 1rem; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; } @font-face { font-family: "R-PMingLiU"; src: url("http://127.0.0.1:8963/fonts/R-PMingLiU.ttf") format("truetype"); font-display: swap; } .r-pmingliu-regular { font-family: "R-PMingLiU", serif; } 关于我们 +关于我们 关于我们 ==== diff --git a/tools/gp/pdf_builder/builder.ts b/tools/gp/pdf_builder/builder.ts index 88e48f9..db5a4dd 100644 --- a/tools/gp/pdf_builder/builder.ts +++ b/tools/gp/pdf_builder/builder.ts @@ -52,8 +52,15 @@ export class DocuBuilder { async as_markdown() { const turndownService = new TurndownService(); - const md_page = turndownService.turndown(await this.as_html_page()); - + const html_page = await this.as_html_page(); + const cleaned_html = html_page.replace( + `/<[^>]class="[^"]\bc_title\b[^"]"[^>]>([\s\S]*?)]+>/gi`, + "# $1", + ).replace( + /]*>[\s\S]*?<\/script>|]*>[\s\S]*?<\/style>/gi, + "", + ); + const md_page = turndownService.turndown(cleaned_html); this.pages = [md_page]; } diff --git a/tools/gp/pdf_builder/tts.ts b/tools/gp/pdf_builder/tts.ts new file mode 100644 index 0000000..913d498 --- /dev/null +++ b/tools/gp/pdf_builder/tts.ts @@ -0,0 +1,63 @@ +export interface TTS { + say_all(content: string, voice: string): Promise; +} + +export class PiperCloudTTS { + api_url: string; + + constructor(api_url: string) { + this.api_url = api_url; + } + + async say_all(content: string, voice: string): Promise { + const response = await fetch(this.api_url, { + method: "POST", + headers: { + "Content-Type": "application/json", + "User-Agent": "Mozilla/5.0", + }, + body: JSON.stringify({ text: content, voice: voice }), + }); + + if (!response.ok) { + const errorText = await response.text(); + throw new Error( + `Failed to fetch ${this.api_url}: ${response.status} ${response.statusText} - ${errorText}`, + ); + } + + return await response.arrayBuffer(); + } + + /** + * 将长文本分段并直接æµ�å¼�写入文件 + */ + async stream_to_file( + content: string, + voice: string, + outputPath: string, + chunkSize = 1000, + ): Promise { + const file = await Deno.open(outputPath, { + write: true, + create: true, + truncate: true, + }); + + try { + for (let i = 0; i < content.length; i += chunkSize) { + const chunk = content.slice(i, i + chunkSize); + console.log(`Processing chunk ${i / chunkSize + 1}...`); + + const audioData = await this.say_all(chunk, voice); + // WAV 文件通常包å�«å¤´ã€‚注æ„�:如果å�ªæ˜¯ç®€å�•å�ˆå¹¶ WAV, + // å�ªæœ‰ç¬¬ä¸€ä¸ª chunk 的头是有效的,å�Žç»­ chunk 的头会被视为数æ�®ï¼ˆå�¯èƒ½ä¼šæœ‰æ�‚音)。 + // 如果 API 返回的是原始 PCM,则没问题。 + // 这里我们先按照用户è¦�求的æµ�å¼�写入实现。 + await file.write(new Uint8Array(audioData)); + } + } finally { + file.close(); + } + } +} diff --git a/tools/index.html b/tools/index.html deleted file mode 100644 index ae8738e..0000000 --- a/tools/index.html +++ /dev/null @@ -1,255 +0,0 @@ - - -ºì¾üÆìÍøÕ¾ Ê×Ò³ -
- - - - - - - -
¾´¸æÍøÓÑ
-
- - - - - - - -
¹ú¼Ê¸è½â·Å¾ü¾ü¸è¹ú¸è
- - - - - -
- - - - - -
- - - - -
- -
- - - - - - - - - -
- - - -
¾´¸æÍøÓÑ
ÔĶÁ¡¶Ã«Ö÷ϯÓA· -
-

     Ê²Ã´ÈËÕ¾ÔÚ¸ïÃüÈËÃñ·½Ã棬Ëû¾ÍÊǸïÃüÅÉ£¬Ê²Ã´ÈËÕ¾ÔÚµÛ¹úÖ÷Òå·â½¨Ö÷Òå¹ÙÁÅ×ʱ¾Ö÷Òå·½Ãæ£¬Ëû¾ÍÊÇ·´¸ïÃüÅÉ¡£Ê²Ã´ÈËÖ»ÊÇ¿ÚÍ·ÉÏÕ¾ÔÚ¸ïÃüÈËÃñ·½Ãæ¶øÔÚÐж¯ÉÏÔòÁíÊÇÒ»Ñù£¬Ëû¾ÍÊÇÒ»¸ö¿ÚÍ·¸ïÃüÅÉ£¬Èç¹û²»µ«ÔÚ¿ÚÍ·É϶øÇÒÔÚÐж¯ÉÏÒ²Õ¾ÔÚ¸ïÃüÈËÃñ·½Ã棬Ëû¾ÍÊÇÒ»¸öÍêÈ«µÄ¸ïÃüÅÉ¡£

-
-

ÔÚÖйúÈËÃñÕþÖÎЭÉÌ»áÒé
- µÚÒ»½ìÈ«¹úίԱ»áµÚ¶þ´Î
- »áÒéÉϵıÕÄ»´Ê  

-
- - - - -
΢ÐÅ¡¶ºìÉ«Äê´ú¡· - ɨһɨ¶©ÔÄ
¡¶Ã«Ôó¶«²©ÀÀ¡·Î¢ÐÅ
- - - - - - - - - - - - - - -
²Î¿¼ÍøÕ¾
-
ÈËÃñÍøÇ¿¹úÂÛ̳
-
лªÍø·¢Õ¹ÂÛ̳
ëÖ÷Ï¯ÍøÕ¾
- -
- -
- - -

-

- - - -
- - - -
-

ѧϰÖй²µ³Ê·²Î¿¼×ÊÁÏ

-

Ïò³õѧÕßÍÆ¼ö£ºÂíÁÐÖø×÷Ñ¡¶Á

- -
-

 

-

Ìáʾ£ºµã»÷ÏÂÃæ¸÷¸ö»­Ãæ½øÈëÏà¹ØÀ¸Ä¿

-

 

-
- - - - - - -
ÔĶÁëÖ÷Ï¯Öø×÷¹Û¿´Ã«Ôó¶«Ïñ¼¯ÐÀÉÍëÖ÷ϯͼƬ
-

- - - - - - - - -
¹ØÓÚëÔ󶫵ĹÊÊÂÐÀÉÍÊ«´ÊÓëÊé·¨ÊÓÌý×ÊÁÏ
- - - - -
- - - -

 

-

ëÖ÷ϯÂÛÈËÃñ¾ü¶Ó£¨±¾Õ¾±à¼­£©

-

רÌâÆ¬¡¶¾Ó°²Ë¼Î£¡ª¡ªËÕ¹²Íöµ³µÄÀúÊ·½Ìѵ¡·

- - - - - - - -
ÓÑ Çé Á´ ½Ó
- - - - - - - -
ÌìÏÂÉØÉ½ÍøÉîÛÚºì¸è»áÄϽִåÖйú¾üÊÂÍø
- -

- - - - - - -
-

    Î°´óµÄÁìÐäºÍµ¼Ê¦Ã«Ôó¶«Ö÷ϯ£¬ÊÇÖйú¹²²úµ³µÄµÞÔìÕߣ¬Êǵ±´ú×îΰ´óµÄÂí¿Ë˼ÁÐÄþÖ÷ÒåÕß¡£Ã«Ö÷ϯ°ÑÂí¿Ë˼ÁÐÄþÖ÷ÒåµÄÆÕ±éÕæÀíºÍ¸ïÃüµÄ¾ßÌåʵ¼ùÏà½áºÏ£¬ÔÚ·´¶ÔµÛ¹úÖ÷ÒåºÍ¹úÄÚ·´¶¯½×¼¶µÄ¶·ÕùÖУ¬ÔÚ·´¶Ôµ³ÄÚÓҵĺ͡°×󡱵Ļú»áÖ÷Òå·ÏߵĶ·ÕùÖУ¬ÔÚ·´¶Ô¹ú¼ÊÏÖ´úÐÞÕýÖ÷ÒåµÄ¶·ÕùÖУ¬¼Ì³Ð¡¢º´ÎÀºÍ·¢Õ¹ÁËÂí¿Ë˼ÁÐÄþÖ÷Ò塣ëÖ÷ϯÁìµ¼ÎÒµ³ÎÒ¾üºÍÎÒ¹úÈËÃñ£¬¾­¹ý³¤ÆÚµÄ¸ïÃü¶·ÕùºÍ¸ïÃüÕ½Õù£¬È¡µÃÁËÐÂÃñÖ÷Ö÷Òå¸ïÃüµÄ³¹µ×ʤÀû£¬½¨Á¢ÁËÎÞ²ú½×¼¶×¨ÕþµÄÖлªÈËÃñ¹²ºÍ¹ú£¬½Ó×ÅÓÖ¾­¹ýÎÞ²ú½×¼¶ºÍ×ʲú½×¼¶¼¤Áҵĸ´ÔӵĶ·Õù£¬¾­¹ýÊ·ÎÞǰÀýµÄÎÞ²ú½×¼¶ÎÄ»¯´ó¸ïÃü£¬È¡µÃÁËÉç»áÖ÷Òå¸ïÃüºÍÉç»áÖ÷Ò彨ÉèµÄΰ´óʤÀû¡£Ã«Ö÷ϯµÄÆìÖÄ£¬ÊÇÎÒÃǵ³ÍŽáÕ½¶·¡¢ÕùȡʤÀûµÄΰ´óÆìÖÄ¡£ -

- Öйú¹²²úµ³Õ³̣¨1977Äê8ÔÂ18ÈÕÖйú¹²²úµ³µÚʮһ´ÎÈ«¹ú´ú±í´ó»áͨ¹ý£©

-
-

½»Á÷£º MSN guantb@163.com -

ÁÉICP±¸10003589ºÅ-1
-

-
- - -