Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

appleSpeech.ts

37 lines1.4 KB

1import {
2 DesktopAppleSpeechResultSchema,
3 DesktopAppleSpeechTranscribeInputSchema,
4} from "@t3tools/contracts";
5import * as Effect from "effect/Effect";
6import * as Schema from "effect/Schema";
7​
8import * as AppleSpeech from "../../speech/AppleSpeech.ts";
9import * as IpcChannels from "../channels.ts";
10import * as DesktopIpc from "../DesktopIpc.ts";
11​
12export const appleSpeechAvailable = DesktopIpc.makeIpcMethod({
13 channel: IpcChannels.APPLE_SPEECH_AVAILABLE_CHANNEL,
14 payload: Schema.Void,
15 result: Schema.Array(Schema.String),
16 handler: Effect.fn("desktop.ipc.appleSpeech.available")(function* () {
17 return yield* (yield* AppleSpeech.AppleSpeech).supportedLocales;
18 }),
19});
20​
21export const appleSpeechPrepare = DesktopIpc.makeIpcMethod({
22 channel: IpcChannels.APPLE_SPEECH_PREPARE_CHANNEL,
23 payload: Schema.String.check(Schema.isMaxLength(64)),
24 result: DesktopAppleSpeechResultSchema,
25 handler: Effect.fn("desktop.ipc.appleSpeech.prepare")(function* (locale) {
26 return yield* (yield* AppleSpeech.AppleSpeech).prepare(locale);
27 }),
28});
29​
30export const appleSpeechTranscribe = DesktopIpc.makeIpcMethod({
31 channel: IpcChannels.APPLE_SPEECH_TRANSCRIBE_CHANNEL,
32 payload: DesktopAppleSpeechTranscribeInputSchema,
33 result: DesktopAppleSpeechResultSchema,
34 handler: Effect.fn("desktop.ipc.appleSpeech.transcribe")(function* ({ locale, pcm }) {
35 return yield* (yield* AppleSpeech.AppleSpeech).transcribe(locale, pcm);
36 }),
37});