68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import { PFile, PFiles } from "./file.ts";
|
|
import { DocuBuilder } from "./pdf_builder/docu_builder.ts";
|
|
import { IndexBuilder } from "./pdf_builder/index_builder.ts";
|
|
import { PDFParse } from "pdf-parse";
|
|
|
|
// Deno.test("PFiles initialization", () => {
|
|
// const pfiles = new PFiles("./mobile_src");
|
|
// console.log(pfiles);
|
|
// });
|
|
|
|
// Deno.test("PDF generate", async () => {
|
|
// const builder = new DocuBuilder();
|
|
// try {
|
|
// await builder.with_browser();
|
|
|
|
// const cfg = JSON.parse(await Deno.readTextFile("config.json"));
|
|
// for (const config of cfg.settings) {
|
|
// console.debug(`Processing config: ${JSON.stringify(config)}`);
|
|
// builder.with_files_sync(config.journal.from_directory);
|
|
// builder.as_html_page();
|
|
// await builder.build_as_pdf(config.playwright);
|
|
// }
|
|
// } finally {
|
|
// await builder.close_browser();
|
|
// }
|
|
// });
|
|
|
|
// Deno.test({
|
|
// name: "IndexBuilder test",
|
|
// sanitizeOps: false,
|
|
// sanitizeResources: false,
|
|
// async fn() {
|
|
// },
|
|
// });
|
|
|
|
// 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");
|
|
});
|