The best way to control Claude Code, Codex and more from any computer or phone

main
ts 44 lines 1.2 KB
Raw
1 import * as speech from "@distilled.cloud/gcp/speech_v1";
2 import * as Layer from "effect/Layer";
3 import { makePhraseSetHttpBinding } from "./BindingHttp.ts";
4 import { Recognize, type RecognizeRequest } from "./Recognize.ts";
5
6 /**
7 * HTTP implementation of {@link Recognize}.
8 *
9 * @layer
10 * @provides GCP.Speech.Recognize
11 */
12 export const RecognizeHttp = Layer.effect(
13 Recognize,
14 makePhraseSetHttpBinding<
15 speech.RecognizeSpeechRequest,
16 speech.RecognizeResponse,
17 speech.RecognizeSpeechError,
18 RecognizeRequest
19 >({
20 tag: "GCP.Speech.Recognize",
21 operation: speech.recognizeSpeech,
22 iam: { role: "roles/speech.client" },
23 toInput: (name, request) => {
24 const body = request?.body ?? {};
25 const config = body.config ?? {};
26 const adaptation = config.adaptation ?? {};
27 const references = [...(adaptation.phraseSetReferences ?? []), name].filter(
28 (value, index, all) => all.indexOf(value) === index,
29 );
30 return {
31 body: {
32 ...body,
33 config: {
34 ...config,
35 adaptation: {
36 ...adaptation,
37 phraseSetReferences: references,
38 },
39 },
40 },
41 };
42 },
43 }),
44 );