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

Pedro-G
질문됨 2달 전58회 조회
1개 답변
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
답변함 2달 전
  • 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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠