macroclaw 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/package.json +1 -1
- package/src/app.test.ts +14 -22
- package/src/app.ts +5 -4
- package/src/cli.test.ts +88 -128
- package/src/cli.ts +37 -76
- package/src/index.ts +9 -14
- package/src/logger.test.ts +7 -7
- package/src/logger.ts +1 -1
- package/src/settings.test.ts +65 -28
- package/src/settings.ts +81 -60
- package/src/setup.test.ts +63 -67
- package/src/setup.ts +159 -117
- package/src/speech-to-text.ts +28 -0
- package/src/stt.ts +0 -31
package/src/stt.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { basename } from "node:path";
|
|
3
|
-
import OpenAI from "openai";
|
|
4
|
-
import { createLogger } from "./logger";
|
|
5
|
-
|
|
6
|
-
const log = createLogger("stt");
|
|
7
|
-
|
|
8
|
-
let client: OpenAI | undefined;
|
|
9
|
-
|
|
10
|
-
function getClient(): OpenAI {
|
|
11
|
-
if (!client) client = new OpenAI();
|
|
12
|
-
return client;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function isAvailable(): boolean {
|
|
16
|
-
return !!process.env.OPENAI_API_KEY;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function transcribe(filePath: string): Promise<string> {
|
|
20
|
-
const buffer = await readFile(filePath);
|
|
21
|
-
const file = new File([buffer], basename(filePath), { type: "audio/ogg" });
|
|
22
|
-
|
|
23
|
-
log.debug({ filePath }, "Transcribing audio");
|
|
24
|
-
const result = await getClient().audio.transcriptions.create({
|
|
25
|
-
model: "whisper-1",
|
|
26
|
-
file,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
log.debug({ text: result.text }, "Transcription complete");
|
|
30
|
-
return result.text;
|
|
31
|
-
}
|