Amplify Gen 2 Predictions transcribe set up

0

Hi everyone,

I am trying to set up amplify Predictions transcribe in my react native app and I keep getting a Transcription error: [NoRegion: Missing region.] but i can't seem to find where to add that info. I looked a lot in the documentation for gen 2 and no luck

This is my set up so far:

backend.ts

import { defineBackend } from "@aws-amplify/backend";
import { auth } from "./auth/resource";
import { data } from "./data/resource";
import { Stack } from "aws-cdk-lib";
import { PolicyStatement } from "aws-cdk-lib/aws-iam";

const backend = defineBackend({
  auth,
  data,
});

// Configure a policy for the required use case.
// The actions included below cover all supported ML capabilities
backend.auth.resources.unauthenticatedUserIamRole.addToPrincipalPolicy(
  new PolicyStatement({
    actions: [
      "translate:TranslateText",
      "polly:SynthesizeSpeech",
      "transcribe:StartStreamTranscriptionWebSocket",
    ],
    resources: ["*"],
  })
);

backend.addOutput({
  custom: {
    Predictions: {
      convert: {
        translateText: {
          defaults: {
            sourceLanguage: "en",
            targetLanguage: "es",
          },
          proxy: false,
          region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
            .region,
        },
        transcription: {
          defaults: {
            language: "en-US",
          },
          proxy: false,
          region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
            .region,
        },
      },
    },
  },
});

How I am using it:

  const transcribeAudio = async (audioBytes) => {
    try {
      const { transcription } = await Predictions.convert({
        region: "us-east-1",
        transcription: {
          source: {
            bytes: audioBytes,
          },
        },
      });
      console.log("Transcription:", transcription);
      // Handle the transcription result (e.g., set it to state, display it, etc.)
    } catch (error) {
      console.error("Transcription error:", error);
    }
  };

Any help would be very much appreciated thank you so much

1 Risposta
0

Hi. I didn't test it with react native, but with React , this one worked for me

   const createTranscribeClient = () => {
        transcribeClient = new TranscribeStreamingClient({
            region: props.region,
            credentials: {
                accessKeyId: props.accessKeyId,
                secretAccessKey: props.secretAccessKey,
                sessionToken: props.sessionToken
            },
        });
    };
AWS
Mi_Sha
con risposta 2 mesi fa
  • Thank you MI Sha, I appropriate your answer, that could work. After many different failed tests I decided to revert back to Gen 1. Gen 2 documentation is Terrible. I fell like the amplify team is trying really hard to make amplify better but whoever is in charge of making the documentation is letting the team down big time.

    The Amplify Documentation 1 or 2 year ago was really good, then they changed the UI it got worse, and now gen 2 is even worse. Oh well I'll work with gen 1 until gen 2 is more established.

    Again thank you for you comment I appreciate it a lot

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande