feat: add ttsc CLI tool for TTS streaming
This commit is contained in:
parent
4112295144
commit
6b75836647
2 changed files with 10 additions and 4 deletions
|
|
@ -4,16 +4,19 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"aicl": "out/index.js"
|
"lmc": "out/index.js",
|
||||||
|
"ttsc": "out/tts.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run index.ts",
|
"dev": "bun run index.ts",
|
||||||
"prod": "bun run out/index.js",
|
"prod": "bun run out/index.js",
|
||||||
"check": "bunx --bun @biomejs/biome check --write && bun run tc",
|
"check": "bunx --bun @biomejs/biome check --write && bun run tc",
|
||||||
"build:js": "bun run check && bun run build:bundle && bun run shebang",
|
"build:js": "bun run check && bun run --parallel build:bundle build:tts && bun run --parallel shebang shebang:tts",
|
||||||
"build:bundle": "bun build --target=bun --production --sourcemap --outdir=out index.ts",
|
"build:bundle": "bun build --target=bun --production --sourcemap --outdir=out index.ts",
|
||||||
|
"build:tts": "bun build --target=bun --production --sourcemap --outdir=out tts.ts",
|
||||||
"build:bin": "bun build --compile --outfile=out/aicl index.ts",
|
"build:bin": "bun build --compile --outfile=out/aicl index.ts",
|
||||||
"shebang": "sed -i '1i#!\\/usr\\/bin\\/env bun' out/index.js",
|
"shebang": "sed -i '1i#!\\/usr\\/bin\\/env bun' out/index.js",
|
||||||
|
"shebang:tts": "sed -i '1i#!\\/usr\\/bin\\/env bun' out/tts.js",
|
||||||
"tc": "tsc --noEmit --incremental"
|
"tc": "tsc --noEmit --incremental"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
7
tts.ts
7
tts.ts
|
|
@ -1,12 +1,15 @@
|
||||||
|
import os from "node:os";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
|
|
||||||
const text = await Bun.stdin.text();
|
const text = await Bun.stdin.text();
|
||||||
|
|
||||||
if (!text) process.exit(1);
|
if (!text) process.exit(1);
|
||||||
|
|
||||||
|
const home = os.homedir();
|
||||||
|
|
||||||
const koko = Bun.spawn({
|
const koko = Bun.spawn({
|
||||||
cmd: ["uv", "run", "--", "python", "-u", "main.py"],
|
cmd: ["uv", "run", "--", "python", "-u", "main.py"],
|
||||||
cwd: "./tts/",
|
cwd: `${home}/.ttsc/`,
|
||||||
stdin: Buffer.from(text),
|
stdin: Buffer.from(text),
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
stderr: "inherit",
|
stderr: "inherit",
|
||||||
|
|
@ -29,7 +32,7 @@ for await (const line of koko.stdout) {
|
||||||
|
|
||||||
await Bun.spawn({
|
await Bun.spawn({
|
||||||
cmd: ["mpv", `${info.file}.wav`],
|
cmd: ["mpv", `${info.file}.wav`],
|
||||||
cwd: "./tts/",
|
cwd: `${home}/.ttsc/`,
|
||||||
stdin: "ignore",
|
stdin: "ignore",
|
||||||
stdout: "inherit",
|
stdout: "inherit",
|
||||||
stderr: "inherit",
|
stderr: "inherit",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue