@krak-stack/registry 0.1.58 → 0.1.59
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/CHANGELOG.md +6 -0
- package/README.md +3 -0
- package/dist/services/speech/api.d.ts +13 -0
- package/dist/services/speech/api.js +60 -0
- package/dist/services/speech/index.d.ts +39 -0
- package/dist/services/speech/index.js +105 -0
- package/dist/services/speech/schema.d.ts +43 -0
- package/dist/services/speech/schema.js +54 -0
- package/package.json +13 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
- Merge the error component's homepage link classes with `cn` so its outline border is visible instead of being overridden by the base transparent border.
|
|
8
8
|
|
|
9
|
+
## 0.1.59
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Export reusable Cloudflare AI Gateway speech-to-text and text-to-speech services from `@krak-stack/registry/speech`, with schemas and an optional host-authenticated HTTP API contract.
|
|
14
|
+
|
|
9
15
|
## 0.1.58
|
|
10
16
|
|
|
11
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -18,8 +18,11 @@ Import from the specific package subpaths you need:
|
|
|
18
18
|
import { DataTable } from "@krak-stack/registry/data-table";
|
|
19
19
|
import { Otlp } from "@krak-stack/registry/opentelemetry";
|
|
20
20
|
import { BrowserOtlp } from "@krak-stack/registry/opentelemetry/browser";
|
|
21
|
+
import { Speech } from "@krak-stack/registry/speech";
|
|
21
22
|
```
|
|
22
23
|
|
|
24
|
+
Speech-to-text and text-to-speech use Cloudflare AI Gateway. See the [speech setup and API contract](https://krakstack.net/docs/speech); authentication and quotas stay application-owned. Schemas and the optional HTTP API contract are available from `@krak-stack/registry/speech/schema` and `@krak-stack/registry/speech/api`.
|
|
25
|
+
|
|
23
26
|
For packaged UI components, include the Tailwind source in your application stylesheet:
|
|
24
27
|
|
|
25
28
|
```css
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpApiEndpoint, HttpApiGroup } from "effect/http-api";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { SpeechUnavailable } from "./schema.js";
|
|
4
|
+
export declare const SpeechApiGroup: HttpApiGroup.HttpApiGroup<"speech", HttpApiEndpoint.HttpApiEndpoint<"synthesize", "POST", "/speech/synthesis", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
5
|
+
readonly text: Schema.String;
|
|
6
|
+
readonly language: Schema.Literals<readonly ["en", "fr", "es", "zh", "ja", "ko"]>;
|
|
7
|
+
}>>, never, Schema.toCodecJson<Schema.Uint8Array>, Schema.toCodecJson<typeof SpeechUnavailable>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"transcribe", "POST", "/speech/transcriptions", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
8
|
+
readonly audio: Schema.Uint8ArrayFromBase64;
|
|
9
|
+
readonly mimeType: Schema.Literals<readonly ["audio/webm", "audio/ogg", "audio/mp4", "audio/wav"]>;
|
|
10
|
+
readonly language: Schema.optionalKey<Schema.String>;
|
|
11
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
12
|
+
readonly text: Schema.String;
|
|
13
|
+
}>>, Schema.toCodecJson<typeof SpeechUnavailable>, never, never>, false>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// ../../src/services/speech/api.ts
|
|
2
|
+
import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
|
|
3
|
+
import { Schema as Schema2 } from "effect";
|
|
4
|
+
|
|
5
|
+
// ../../src/services/speech/schema.ts
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
var MAX_AUDIO_BYTES = 2 * 1024 * 1024;
|
|
8
|
+
var AudioMimeType = Schema.Literals([
|
|
9
|
+
"audio/webm",
|
|
10
|
+
"audio/ogg",
|
|
11
|
+
"audio/mp4",
|
|
12
|
+
"audio/wav"
|
|
13
|
+
]).annotate({ identifier: "SpeechAudioMimeType" });
|
|
14
|
+
var TranscribeAudio = Schema.Struct({
|
|
15
|
+
audio: Schema.Uint8ArrayFromBase64.check(Schema.isMinLength(1), Schema.isMaxLength(MAX_AUDIO_BYTES)),
|
|
16
|
+
mimeType: AudioMimeType,
|
|
17
|
+
language: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^[a-z]{2,3}$/)))
|
|
18
|
+
}).annotate({ identifier: "TranscribeAudio" });
|
|
19
|
+
var Transcription = Schema.Struct({
|
|
20
|
+
text: Schema.String.check(Schema.isMaxLength(12000))
|
|
21
|
+
}).annotate({ identifier: "SpeechTranscription" });
|
|
22
|
+
var WhisperRequest = Schema.Struct({
|
|
23
|
+
audio: TranscribeAudio.fields.audio,
|
|
24
|
+
language: TranscribeAudio.fields.language,
|
|
25
|
+
task: Schema.Literal("transcribe"),
|
|
26
|
+
vad_filter: Schema.Boolean
|
|
27
|
+
}).annotate({ identifier: "GatewayWhisperRequest" });
|
|
28
|
+
var WhisperResponse = Schema.Struct({
|
|
29
|
+
success: Schema.Literal(true),
|
|
30
|
+
result: Transcription
|
|
31
|
+
}).annotate({ identifier: "GatewayWhisperResponse" });
|
|
32
|
+
|
|
33
|
+
class SpeechUnavailable extends Schema.TaggedError()("SpeechUnavailable", {}, { httpApiStatus: 503 }) {
|
|
34
|
+
}
|
|
35
|
+
var SynthesizeSpeech = Schema.Struct({
|
|
36
|
+
text: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(4000), Schema.isPattern(/\S/)),
|
|
37
|
+
language: Schema.Literals(["en", "fr", "es", "zh", "ja", "ko"])
|
|
38
|
+
}).annotate({ identifier: "SynthesizeSpeech" });
|
|
39
|
+
var MeloRequest = Schema.Struct({
|
|
40
|
+
prompt: SynthesizeSpeech.fields.text,
|
|
41
|
+
lang: SynthesizeSpeech.fields.language
|
|
42
|
+
}).annotate({ identifier: "GatewayMeloRequest" });
|
|
43
|
+
var MeloResponse = Schema.Struct({
|
|
44
|
+
success: Schema.Literal(true),
|
|
45
|
+
result: Schema.Struct({ audio: Schema.Uint8ArrayFromBase64.check(Schema.isMinLength(1)) })
|
|
46
|
+
}).annotate({ identifier: "GatewayMeloResponse" });
|
|
47
|
+
|
|
48
|
+
// ../../src/services/speech/api.ts
|
|
49
|
+
var SpeechApiGroup = HttpApiGroup.make("speech").add(HttpApiEndpoint.post("transcribe", "/speech/transcriptions", {
|
|
50
|
+
payload: TranscribeAudio,
|
|
51
|
+
success: Transcription,
|
|
52
|
+
error: [SpeechUnavailable]
|
|
53
|
+
}), HttpApiEndpoint.post("synthesize", "/speech/synthesis", {
|
|
54
|
+
payload: SynthesizeSpeech,
|
|
55
|
+
success: Schema2.Uint8Array.pipe(HttpApiSchema.asUint8Array({ contentType: "audio/mpeg" })),
|
|
56
|
+
error: [SpeechUnavailable]
|
|
57
|
+
}));
|
|
58
|
+
export {
|
|
59
|
+
SpeechApiGroup
|
|
60
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Redacted } from "effect";
|
|
2
|
+
import { HttpClient } from "effect/http";
|
|
3
|
+
import { SpeechUnavailable } from "./schema.js";
|
|
4
|
+
export interface SpeechOptions {
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
7
|
+
readonly gatewayId: string;
|
|
8
|
+
}
|
|
9
|
+
declare const Speech_base: Context.ServiceClass<Speech, "@krak-stack/registry/speech/Speech", {
|
|
10
|
+
transcribe: (input: {
|
|
11
|
+
readonly audio: Uint8Array<ArrayBufferLike>;
|
|
12
|
+
readonly mimeType: "audio/mp4" | "audio/ogg" | "audio/wav" | "audio/webm";
|
|
13
|
+
readonly language?: string | undefined;
|
|
14
|
+
}) => Effect.Effect<{
|
|
15
|
+
text: string;
|
|
16
|
+
}, SpeechUnavailable, never>;
|
|
17
|
+
synthesize: (input: {
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly language: "en" | "es" | "fr" | "ja" | "ko" | "zh";
|
|
20
|
+
}) => Effect.Effect<Uint8Array<ArrayBufferLike>, SpeechUnavailable, never>;
|
|
21
|
+
}> & {
|
|
22
|
+
readonly make: (options: SpeechOptions) => Effect.Effect<{
|
|
23
|
+
transcribe: (input: {
|
|
24
|
+
readonly audio: Uint8Array<ArrayBufferLike>;
|
|
25
|
+
readonly mimeType: "audio/mp4" | "audio/ogg" | "audio/wav" | "audio/webm";
|
|
26
|
+
readonly language?: string | undefined;
|
|
27
|
+
}) => Effect.Effect<{
|
|
28
|
+
text: string;
|
|
29
|
+
}, SpeechUnavailable, never>;
|
|
30
|
+
synthesize: (input: {
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly language: "en" | "es" | "fr" | "ja" | "ko" | "zh";
|
|
33
|
+
}) => Effect.Effect<Uint8Array<ArrayBufferLike>, SpeechUnavailable, never>;
|
|
34
|
+
}, never, HttpClient.HttpClient>;
|
|
35
|
+
};
|
|
36
|
+
export declare class Speech extends Speech_base {
|
|
37
|
+
static readonly layer: (options: SpeechOptions) => Layer.Layer<Speech, never, never>;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// ../../src/services/speech/index.ts
|
|
2
|
+
import { Context, Effect, Layer, Schema as Schema2 } from "effect";
|
|
3
|
+
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
4
|
+
|
|
5
|
+
// ../../src/services/speech/schema.ts
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
var MAX_AUDIO_BYTES = 2 * 1024 * 1024;
|
|
8
|
+
var AudioMimeType = Schema.Literals([
|
|
9
|
+
"audio/webm",
|
|
10
|
+
"audio/ogg",
|
|
11
|
+
"audio/mp4",
|
|
12
|
+
"audio/wav"
|
|
13
|
+
]).annotate({ identifier: "SpeechAudioMimeType" });
|
|
14
|
+
var TranscribeAudio = Schema.Struct({
|
|
15
|
+
audio: Schema.Uint8ArrayFromBase64.check(Schema.isMinLength(1), Schema.isMaxLength(MAX_AUDIO_BYTES)),
|
|
16
|
+
mimeType: AudioMimeType,
|
|
17
|
+
language: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^[a-z]{2,3}$/)))
|
|
18
|
+
}).annotate({ identifier: "TranscribeAudio" });
|
|
19
|
+
var Transcription = Schema.Struct({
|
|
20
|
+
text: Schema.String.check(Schema.isMaxLength(12000))
|
|
21
|
+
}).annotate({ identifier: "SpeechTranscription" });
|
|
22
|
+
var WhisperRequest = Schema.Struct({
|
|
23
|
+
audio: TranscribeAudio.fields.audio,
|
|
24
|
+
language: TranscribeAudio.fields.language,
|
|
25
|
+
task: Schema.Literal("transcribe"),
|
|
26
|
+
vad_filter: Schema.Boolean
|
|
27
|
+
}).annotate({ identifier: "GatewayWhisperRequest" });
|
|
28
|
+
var WhisperResponse = Schema.Struct({
|
|
29
|
+
success: Schema.Literal(true),
|
|
30
|
+
result: Transcription
|
|
31
|
+
}).annotate({ identifier: "GatewayWhisperResponse" });
|
|
32
|
+
|
|
33
|
+
class SpeechUnavailable extends Schema.TaggedError()("SpeechUnavailable", {}, { httpApiStatus: 503 }) {
|
|
34
|
+
}
|
|
35
|
+
var SynthesizeSpeech = Schema.Struct({
|
|
36
|
+
text: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(4000), Schema.isPattern(/\S/)),
|
|
37
|
+
language: Schema.Literals(["en", "fr", "es", "zh", "ja", "ko"])
|
|
38
|
+
}).annotate({ identifier: "SynthesizeSpeech" });
|
|
39
|
+
var MeloRequest = Schema.Struct({
|
|
40
|
+
prompt: SynthesizeSpeech.fields.text,
|
|
41
|
+
lang: SynthesizeSpeech.fields.language
|
|
42
|
+
}).annotate({ identifier: "GatewayMeloRequest" });
|
|
43
|
+
var MeloResponse = Schema.Struct({
|
|
44
|
+
success: Schema.Literal(true),
|
|
45
|
+
result: Schema.Struct({ audio: Schema.Uint8ArrayFromBase64.check(Schema.isMinLength(1)) })
|
|
46
|
+
}).annotate({ identifier: "GatewayMeloResponse" });
|
|
47
|
+
|
|
48
|
+
// ../../src/services/speech/index.ts
|
|
49
|
+
class Speech extends Context.Service()("@krak-stack/registry/speech/Speech", {
|
|
50
|
+
make: (options) => Effect.gen(function* () {
|
|
51
|
+
const http = (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk);
|
|
52
|
+
const transcribe = Effect.fn("Speech.transcribe")(function* (input) {
|
|
53
|
+
const url = yield* Schema2.decodeUnknownEffect(Schema2.URLFromString)(options.baseUrl);
|
|
54
|
+
const path = yield* Schema2.decodeUnknownEffect(Schema2.String.check(Schema2.isPattern(/^\/.*accounts\/[^/]+\/ai\/(v1|run)\/?$/)))(url.pathname);
|
|
55
|
+
url.pathname = path.replace(/\/(v1|run)\/?$/, "/run/@cf/openai/whisper-large-v3-turbo");
|
|
56
|
+
url.search = "";
|
|
57
|
+
url.hash = "";
|
|
58
|
+
let payload = {
|
|
59
|
+
audio: input.audio,
|
|
60
|
+
task: "transcribe",
|
|
61
|
+
vad_filter: true
|
|
62
|
+
};
|
|
63
|
+
if (input.language)
|
|
64
|
+
payload = { ...payload, language: input.language };
|
|
65
|
+
const request = yield* HttpClientRequest.post(url.toString()).pipe(HttpClientRequest.bearerToken(options.apiKey), HttpClientRequest.setHeaders({
|
|
66
|
+
"cf-aig-gateway-id": options.gatewayId,
|
|
67
|
+
"cf-aig-skip-cache": "true",
|
|
68
|
+
"cf-aig-collect-log": "false"
|
|
69
|
+
}), HttpClientRequest.schemaBodyJson(WhisperRequest)(payload));
|
|
70
|
+
const response = yield* http.execute(request);
|
|
71
|
+
const body = yield* HttpClientResponse.schemaBodyJson(WhisperResponse)(response);
|
|
72
|
+
return { text: body.result.text.trim() };
|
|
73
|
+
}, Effect.timeout("60 seconds"), Effect.mapError(() => new SpeechUnavailable({})));
|
|
74
|
+
const synthesize = Effect.fn("Speech.synthesize")(function* (input) {
|
|
75
|
+
const payload = yield* Schema2.decodeUnknownEffect(SynthesizeSpeech)(input);
|
|
76
|
+
const url = yield* Schema2.decodeUnknownEffect(Schema2.URLFromString)(options.baseUrl);
|
|
77
|
+
const path = yield* Schema2.decodeUnknownEffect(Schema2.String.check(Schema2.isPattern(/^\/.*accounts\/[^/]+\/ai\/(v1|run)\/?$/)))(url.pathname);
|
|
78
|
+
url.pathname = path.replace(/\/(v1|run)\/?$/, "/run/@cf/myshell-ai/melotts");
|
|
79
|
+
url.search = "";
|
|
80
|
+
url.hash = "";
|
|
81
|
+
const request = yield* HttpClientRequest.post(url.toString()).pipe(HttpClientRequest.bearerToken(options.apiKey), HttpClientRequest.setHeaders({
|
|
82
|
+
"cf-aig-gateway-id": options.gatewayId,
|
|
83
|
+
"cf-aig-skip-cache": "true",
|
|
84
|
+
"cf-aig-collect-log": "false",
|
|
85
|
+
accept: "audio/mpeg"
|
|
86
|
+
}), HttpClientRequest.schemaBodyJson(MeloRequest)({
|
|
87
|
+
prompt: payload.text,
|
|
88
|
+
lang: payload.language
|
|
89
|
+
}));
|
|
90
|
+
const response = yield* http.execute(request);
|
|
91
|
+
if (response.headers["content-type"]?.split(";")[0]?.trim() === "audio/mpeg") {
|
|
92
|
+
const bytes = new Uint8Array(yield* response.arrayBuffer);
|
|
93
|
+
return yield* Schema2.decodeUnknownEffect(Schema2.Uint8Array.check(Schema2.isMinLength(1)))(bytes);
|
|
94
|
+
}
|
|
95
|
+
const body = yield* HttpClientResponse.schemaBodyJson(MeloResponse)(response);
|
|
96
|
+
return body.result.audio;
|
|
97
|
+
}, Effect.timeout("60 seconds"), Effect.mapError(() => new SpeechUnavailable({})));
|
|
98
|
+
return { transcribe, synthesize };
|
|
99
|
+
})
|
|
100
|
+
}) {
|
|
101
|
+
static layer = (options) => Layer.effect(this, this.make(options)).pipe(Layer.provide(FetchHttpClient.layer));
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
Speech
|
|
105
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const MAX_AUDIO_BYTES: number;
|
|
3
|
+
export declare const AudioMimeType: Schema.Literals<readonly ["audio/webm", "audio/ogg", "audio/mp4", "audio/wav"]>;
|
|
4
|
+
export declare const TranscribeAudio: Schema.Struct<{
|
|
5
|
+
readonly audio: Schema.Uint8ArrayFromBase64;
|
|
6
|
+
readonly mimeType: Schema.Literals<readonly ["audio/webm", "audio/ogg", "audio/mp4", "audio/wav"]>;
|
|
7
|
+
readonly language: Schema.optionalKey<Schema.String>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const Transcription: Schema.Struct<{
|
|
10
|
+
readonly text: Schema.String;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const WhisperRequest: Schema.Struct<{
|
|
13
|
+
readonly audio: Schema.Uint8ArrayFromBase64;
|
|
14
|
+
readonly language: Schema.optionalKey<Schema.String>;
|
|
15
|
+
readonly task: Schema.Literal<"transcribe">;
|
|
16
|
+
readonly vad_filter: Schema.Boolean;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const WhisperResponse: Schema.Struct<{
|
|
19
|
+
readonly success: Schema.Literal<true>;
|
|
20
|
+
readonly result: Schema.Struct<{
|
|
21
|
+
readonly text: Schema.String;
|
|
22
|
+
}>;
|
|
23
|
+
}>;
|
|
24
|
+
declare const SpeechUnavailable_base: Schema.Class<SpeechUnavailable, Schema.TaggedStruct<"SpeechUnavailable", {}>, import("effect/Cause").YieldableError>;
|
|
25
|
+
export declare class SpeechUnavailable extends SpeechUnavailable_base {
|
|
26
|
+
}
|
|
27
|
+
export type TranscribeAudio = typeof TranscribeAudio.Type;
|
|
28
|
+
export declare const SynthesizeSpeech: Schema.Struct<{
|
|
29
|
+
readonly text: Schema.String;
|
|
30
|
+
readonly language: Schema.Literals<readonly ["en", "fr", "es", "zh", "ja", "ko"]>;
|
|
31
|
+
}>;
|
|
32
|
+
export type SynthesizeSpeech = typeof SynthesizeSpeech.Type;
|
|
33
|
+
export declare const MeloRequest: Schema.Struct<{
|
|
34
|
+
readonly prompt: Schema.String;
|
|
35
|
+
readonly lang: Schema.Literals<readonly ["en", "fr", "es", "zh", "ja", "ko"]>;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const MeloResponse: Schema.Struct<{
|
|
38
|
+
readonly success: Schema.Literal<true>;
|
|
39
|
+
readonly result: Schema.Struct<{
|
|
40
|
+
readonly audio: Schema.Uint8ArrayFromBase64;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// ../../src/services/speech/schema.ts
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
var MAX_AUDIO_BYTES = 2 * 1024 * 1024;
|
|
4
|
+
var AudioMimeType = Schema.Literals([
|
|
5
|
+
"audio/webm",
|
|
6
|
+
"audio/ogg",
|
|
7
|
+
"audio/mp4",
|
|
8
|
+
"audio/wav"
|
|
9
|
+
]).annotate({ identifier: "SpeechAudioMimeType" });
|
|
10
|
+
var TranscribeAudio = Schema.Struct({
|
|
11
|
+
audio: Schema.Uint8ArrayFromBase64.check(Schema.isMinLength(1), Schema.isMaxLength(MAX_AUDIO_BYTES)),
|
|
12
|
+
mimeType: AudioMimeType,
|
|
13
|
+
language: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^[a-z]{2,3}$/)))
|
|
14
|
+
}).annotate({ identifier: "TranscribeAudio" });
|
|
15
|
+
var Transcription = Schema.Struct({
|
|
16
|
+
text: Schema.String.check(Schema.isMaxLength(12000))
|
|
17
|
+
}).annotate({ identifier: "SpeechTranscription" });
|
|
18
|
+
var WhisperRequest = Schema.Struct({
|
|
19
|
+
audio: TranscribeAudio.fields.audio,
|
|
20
|
+
language: TranscribeAudio.fields.language,
|
|
21
|
+
task: Schema.Literal("transcribe"),
|
|
22
|
+
vad_filter: Schema.Boolean
|
|
23
|
+
}).annotate({ identifier: "GatewayWhisperRequest" });
|
|
24
|
+
var WhisperResponse = Schema.Struct({
|
|
25
|
+
success: Schema.Literal(true),
|
|
26
|
+
result: Transcription
|
|
27
|
+
}).annotate({ identifier: "GatewayWhisperResponse" });
|
|
28
|
+
|
|
29
|
+
class SpeechUnavailable extends Schema.TaggedError()("SpeechUnavailable", {}, { httpApiStatus: 503 }) {
|
|
30
|
+
}
|
|
31
|
+
var SynthesizeSpeech = Schema.Struct({
|
|
32
|
+
text: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(4000), Schema.isPattern(/\S/)),
|
|
33
|
+
language: Schema.Literals(["en", "fr", "es", "zh", "ja", "ko"])
|
|
34
|
+
}).annotate({ identifier: "SynthesizeSpeech" });
|
|
35
|
+
var MeloRequest = Schema.Struct({
|
|
36
|
+
prompt: SynthesizeSpeech.fields.text,
|
|
37
|
+
lang: SynthesizeSpeech.fields.language
|
|
38
|
+
}).annotate({ identifier: "GatewayMeloRequest" });
|
|
39
|
+
var MeloResponse = Schema.Struct({
|
|
40
|
+
success: Schema.Literal(true),
|
|
41
|
+
result: Schema.Struct({ audio: Schema.Uint8ArrayFromBase64.check(Schema.isMinLength(1)) })
|
|
42
|
+
}).annotate({ identifier: "GatewayMeloResponse" });
|
|
43
|
+
export {
|
|
44
|
+
AudioMimeType,
|
|
45
|
+
MAX_AUDIO_BYTES,
|
|
46
|
+
MeloRequest,
|
|
47
|
+
MeloResponse,
|
|
48
|
+
SpeechUnavailable,
|
|
49
|
+
SynthesizeSpeech,
|
|
50
|
+
TranscribeAudio,
|
|
51
|
+
Transcription,
|
|
52
|
+
WhisperRequest,
|
|
53
|
+
WhisperResponse
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.59",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
19
|
"exports": {
|
|
20
|
+
"./speech": {
|
|
21
|
+
"types": "./dist/services/speech/index.d.ts",
|
|
22
|
+
"import": "./dist/services/speech/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./speech/schema": {
|
|
25
|
+
"types": "./dist/services/speech/schema.d.ts",
|
|
26
|
+
"import": "./dist/services/speech/schema.js"
|
|
27
|
+
},
|
|
28
|
+
"./speech/api": {
|
|
29
|
+
"types": "./dist/services/speech/api.d.ts",
|
|
30
|
+
"import": "./dist/services/speech/api.js"
|
|
31
|
+
},
|
|
20
32
|
"./events/tracking-notice": {
|
|
21
33
|
"types": "./dist/services/events/client/tracking-notice.d.ts",
|
|
22
34
|
"import": "./dist/services/events/client/tracking-notice.js"
|