| 1 | import type * as polly from "@distilled.cloud/aws/polly"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Runtime binding for `polly:SynthesizeSpeech` — synthesize UTF-8 plain |
| 7 | * text or SSML into a stream of audio bytes. |
| 8 | * |
| 9 | * Polly is a pure pay-per-call service with no resource to manage: the |
| 10 | * binding takes no arguments and grants the function |
| 11 | * `polly:SynthesizeSpeech`. The response `AudioStream` is a byte `Stream` |
| 12 | * of the encoded audio (raw distilled types, no marshalling). Provide the |
| 13 | * implementation with `Effect.provide(AWS.Polly.SynthesizeSpeechHttp)`. |
| 14 | * |
| 15 | * ### Synthesizing Speech |
| 16 | * **Example:** Synthesize Text to MP3 Bytes |
| 17 | * ```typescript |
| 18 | * // init |
| 19 | * const synthesizeSpeech = yield* AWS.Polly.SynthesizeSpeech(); |
| 20 | * |
| 21 | * // runtime — AudioStream is a byte Stream of the encoded audio |
| 22 | * const result = yield* synthesizeSpeech({ |
| 23 | * Engine: "neural", |
| 24 | * OutputFormat: "mp3", |
| 25 | * VoiceId: "Joanna", |
| 26 | * Text: "Hello from Alchemy.", |
| 27 | * }); |
| 28 | * const chunks = yield* Stream.runCollect(result.AudioStream!); |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | */ |
| 33 | export interface SynthesizeSpeech extends Binding.Service< |
| 34 | SynthesizeSpeech, |
| 35 | "AWS.Polly.SynthesizeSpeech", |
| 36 | () => Effect.Effect< |
| 37 | ( |
| 38 | request: polly.SynthesizeSpeechInput, |
| 39 | ) => Effect.Effect< |
| 40 | polly.SynthesizeSpeechOutput, |
| 41 | polly.SynthesizeSpeechError |
| 42 | > |
| 43 | > |
| 44 | > {} |
| 45 | export const SynthesizeSpeech = Binding.Service<SynthesizeSpeech>( |
| 46 | "AWS.Polly.SynthesizeSpeech", |
| 47 | ); |