@@ -218,6 +218,7 @@ Amplify.configure(outputs);
218218
219219Example frontend code to create an audio buffer for playback using a text input.
220220
221+ <InlineFilter filters = { [" react" , " javascript" , " nextjs" , " react-native" ]} >
221222``` ts title="App.tsx"
222223import " ./App.css" ;
223224import { generateClient } from " aws-amplify/api" ;
@@ -267,4 +268,53 @@ function App() {
267268
268269export default App ;
269270```
271+ </InlineFilter >
270272
273+ <InlineFilter filters = { [" angular" ]} >
274+ ``` ts title="app.component.ts"
275+ import { Component } from ' @angular/core' ;
276+ import { generateClient } from ' aws-amplify/api' ;
277+ import type { Schema } from ' ../../../amplify/data/resource' ;
278+ import { getUrl } from ' aws-amplify/storage' ;
279+
280+ const client = generateClient <Schema >();
281+
282+ type PollyReturnType = Schema [' convertTextToSpeech' ][' returnType' ];
283+
284+ @Component ({
285+ selector: ' app-root' ,
286+ template: `
287+ <div class="flex flex-col">
288+ <button (click)="synthesize()">Synth</button>
289+ <button (click)="fetchAudio()">Fetch audio</button>
290+ <a [href]="src">Get audio file</a>
291+ </div>
292+ ` ,
293+ styleUrls: [' ./app.component.css' ],
294+ })
295+ export class App {
296+ src: string = ' ' ;
297+ file: PollyReturnType = ' ' ;
298+
299+ async synthesize() {
300+ const { data, errors } = await client .mutations .convertTextToSpeech ({
301+ text: ' Hello World!' ,
302+ });
303+
304+ if (! errors && data ) {
305+ this .file = data ;
306+ } else {
307+ console .log (errors );
308+ }
309+ }
310+
311+ async fetchAudio() {
312+ const res = await getUrl ({
313+ path: ' public/' + this .file ,
314+ });
315+
316+ this .src = res .url .toString ();
317+ }
318+ }
319+ ```
320+ </InlineFilter >
0 commit comments