1import type * as polly from "@distilled.cloud/aws/polly";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5/**
6 * Runtime binding for `polly:StartSpeechSynthesisTask` — start an
7 * asynchronous synthesis task that writes the audio (or speech marks) to an
8 * S3 bucket, for texts too long for the synchronous `SynthesizeSpeech`.
9 *
10 * The binding grants `polly:StartSpeechSynthesisTask`. Polly writes the
11 * output with the **caller's** credentials, so the function also needs
12 * `s3:PutObject` on the output bucket — compose with
13 * `AWS.S3.PutObject(bucket)`. Provide the implementation with
14 * `Effect.provide(AWS.Polly.StartSpeechSynthesisTaskHttp)`.
15 *
16 * ### Asynchronous Synthesis
17 * **Example:** Start a synthesis task writing MP3 to S3
18 * ```typescript
19 * // init — the S3 PutObject binding grants Polly's output write
20 * yield* AWS.S3.PutObject(bucket);
21 * const startSpeechSynthesisTask = yield* AWS.Polly.StartSpeechSynthesisTask();
22 *
23 * // runtime
24 * const started = yield* startSpeechSynthesisTask({
25 * OutputFormat: "mp3",
26 * OutputS3BucketName: "my-audio-bucket",
27 * VoiceId: "Joanna",
28 * Text: longArticleText,
29 * });
30 * const taskId = started.SynthesisTask?.TaskId;
31 * ```
32 *
33 * @binding
34 */
35export interface StartSpeechSynthesisTask extends Binding.Service<
36 StartSpeechSynthesisTask,
37 "AWS.Polly.StartSpeechSynthesisTask",
38 () => Effect.Effect<
39 (
40 request: polly.StartSpeechSynthesisTaskInput,
41 ) => Effect.Effect<
42 polly.StartSpeechSynthesisTaskOutput,
43 polly.StartSpeechSynthesisTaskError
44 >
45 >
46> {}
47export const StartSpeechSynthesisTask =
48 Binding.Service<StartSpeechSynthesisTask>(
49 "AWS.Polly.StartSpeechSynthesisTask",
50 );