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
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