public static async Task Main()
        {
            // If the region you want to use is different from the region
            // defined for the default user, supply it as a parameter to the
            // Amazon Translate client object constructor.
            var client = new AmazonTranslateClient();

            // Set the source language to "auto" to request Amazon Translate to
            // automatically detect te language of the source text.

            // You can get a list of the languages supposed by Amazon Translate
            // in the Amazon Translate Developer's Guide here:
            //      https://docs.aws.amazon.com/translate/latest/dg/what-is.html
            string srcLang  = "en"; // English
            string destLang = "fr"; // Italian

            // The Amazon Simple Storage Service (Amazon S3) bucket where the
            // source text file is stored.
            string srcBucket   = "doc-example-bucket";
            string srcTextFile = "source.txt";

            var srcText = await GetSourceTextAsync(srcBucket, srcTextFile);

            var destText = await TranslatingTextAsync(client, srcLang, destLang, srcText);

            ShowText(srcText, destText);
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonTranslateConfig config = new AmazonTranslateConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonTranslateClient client = new AmazonTranslateClient(creds, config);

            ListTerminologiesResponse resp = new ListTerminologiesResponse();

            do
            {
                ListTerminologiesRequest req = new ListTerminologiesRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListTerminologies(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.TerminologyPropertiesList)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        static async Task Main(string[] args)
        {
            Console.WriteLine("Generate translation files using AWS Translate from Blazor I18nText JSON");

            Console.Write("Enter File Path to English JSON: ");
            var file = Console.ReadLine();

            Console.Write("Enter list of languages to translate (comma separated): ");
            var languages = Console.ReadLine().Split(',');

            var dir  = Path.GetDirectoryName(file);
            var data = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(file));

            using (var trans = new AmazonTranslateClient())
            {
                foreach (var lang in languages)
                {
                    var newData = new Dictionary <string, string>();
                    foreach (var item in data)
                    {
                        var translation = await trans.TranslateTextAsync(new Amazon.Translate.Model.TranslateTextRequest()
                        {
                            SourceLanguageCode = "en",
                            TargetLanguageCode = lang,
                            Text = item.Value
                        });

                        if (translation.HttpStatusCode == System.Net.HttpStatusCode.OK)
                        {
                            newData.Add(item.Key, translation.TranslatedText);
                        }
                        else
                        {
                            newData.Add(item.Key, "NO TRANSLATION");
                        }
                        //TODO: Error
                    }
                    var fn        = Path.GetFileName(file).Split('.');
                    var newFn     = $"{fn[0]}.{lang}.{fn[2]}";
                    var newFnPath = Path.Combine(dir, newFn);
                    Console.WriteLine(newFnPath);
                    if (!File.Exists(newFnPath))
                    {
                        File.Create(newFnPath).Dispose();
                    }
                    using (var fs = new FileStream(newFnPath, FileMode.Truncate))
                    {
                        var newJson = JsonConvert.SerializeObject(newData, new JsonSerializerSettings()
                        {
                            Formatting = Formatting.Indented,
                        });
                        using (var sr = new StreamWriter(fs, System.Text.Encoding.UTF8))
                            await sr.WriteAsync(newJson);
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// This method is called for every Lambda invocation. This method takes in an S3 event object and can be used
        /// to respond to S3 notifications.
        /// </summary>
        /// <param name="evnt"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <string> FunctionHandler(S3Event evnt, ILambdaContext context)
        {
            var s3Event = evnt.Records?[0].S3;

            if (s3Event == null)
            {
                return(null);
            }

            try
            {
                String content;

                using (var s3Client = new AmazonS3Client())
                {
                    GetObjectRequest request = new GetObjectRequest
                    {
                        BucketName = evnt.Records.First().S3.Bucket.Name,
                        Key        = evnt.Records.First().S3.Object.Key
                    };

                    GetObjectResponse response = await s3Client.GetObjectAsync(request);

                    StreamReader reader = new StreamReader(response.ResponseStream);
                    content = reader.ReadToEnd();

                    using (var translateClient = new AmazonTranslateClient(Amazon.RegionEndpoint.EUWest1))
                    {
                        foreach (string language in languages)
                        {
                            var translateTextResponse = await translateClient.TranslateTextAsync(
                                new TranslateTextRequest()
                            {
                                Text = content,
                                SourceLanguageCode = "EN",
                                TargetLanguageCode = language
                            });

                            await S3Client.PutObjectAsync(new PutObjectRequest()
                            {
                                ContentBody = translateTextResponse.TranslatedText,
                                BucketName  = evnt.Records.First().S3.Bucket.Name,
                                Key         = evnt.Records.First().S3.Object.Key.Replace("EN", language)
                            });
                        }
                    }
                    return("Complete");
                }
            }
            catch (Exception e)
            {
                context.Logger.LogLine(e.Message);
                context.Logger.LogLine(e.StackTrace);
                throw;
            }
        }
示例#5
0
        public static async Task Main()
        {
            var client = new AmazonTranslateClient();
            var jobId  = "sample-job-id";

            var request = new StopTextTranslationJobRequest
            {
                JobId = jobId,
            };
        }
示例#6
0
        /// <summary>
        /// Sends a request to stop a text translation job.
        /// </summary>
        /// <param name="client">Initialized AmazonTrnslateClient object.</param>
        /// <param name="request">The request object to be passed to the
        /// StopTextJobAsync method.</param>
        public static async Task StopTranslationJobAsync(
            AmazonTranslateClient client,
            StopTextTranslationJobRequest request)
        {
            var response = await client.StopTextTranslationJobAsync(request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"{response.JobId} as status: {response.JobStatus}");
            }
        }
        /// <summary>
        /// Use the Amazon Translate Service to translate the document from the
        /// source language to the specified destination language.
        /// </summary>
        /// <param name="client">The Amazon Translate Service client used to
        /// perform the translation.</param>
        /// <param name="srcLang">The language of the source text.</param>
        /// <param name="destLang">The destination language for the translated
        /// text.</param>
        /// <param name="text">A string representing the text to ranslate.</param>
        /// <returns>The text that has been translated to the destination
        /// language.</returns>
        public static async Task <string> TranslatingTextAsync(AmazonTranslateClient client, string srcLang, string destLang, string text)
        {
            var request = new TranslateTextRequest
            {
                SourceLanguageCode = srcLang,
                TargetLanguageCode = destLang,
                Text = text,
            };

            var response = await client.TranslateTextAsync(request);

            return(response.TranslatedText);
        }
示例#8
0
        protected IAmazonTranslate CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonTranslateConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonTranslateClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
示例#9
0
        private string TranslateBody(string msg, string lan)
        {
            var translateClient = new AmazonTranslateClient(RegionEndpoint.USEast2);
            var request         = new TranslateTextRequest
            {
                SourceLanguageCode = "en",
                TargetLanguageCode = lan,
                Text = msg,
            };

            var response = translateClient.TranslateTextAsync(request);

            return(response.Result.TranslatedText);
        }
 /// <summary>
 /// Retrieve information about an Amazon Translate text translation job.
 /// </summary>
 /// <param name="client">The initialized Amazon Translate client object.</param>
 /// <param name="request">The DescribeTextTranslationJobRequest object.</param>
 /// <returns>The TextTranslationJobProperties object containing
 /// information about the text translation job..</returns>
 public static async Task<TextTranslationJobProperties> DescribeTranslationJobAsync(
     AmazonTranslateClient client,
     DescribeTextTranslationJobRequest request)
 {
     var response = await client.DescribeTextTranslationJobAsync(request);
     if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
     {
         return response.TextTranslationJobProperties;
     }
     else
     {
         return null;
     }
 }
示例#11
0
        static void Main(string[] args)
        {
            AmazonTranslateClient client = new AmazonTranslateClient(Amazon.RegionEndpoint.USEast1);
            string userSentence          = sentenceToTranslate();

            while (!userSentence.Equals("q"))
            {
                translateText(userSentence, client);
                Console.WriteLine();
                userSentence = sentenceToTranslate();
            }
            Console.WriteLine("Program ended");
            Console.ReadLine();
        }
示例#12
0
        private void BtnTrans_Click(object sender, EventArgs e)
        {
            var client = new AmazonTranslateClient();

            var request = new TranslateTextRequest
            {
                Text = txtEn.Text,
                SourceLanguageCode = "en",
                TargetLanguageCode = "vi"
            };
            var result = client.TranslateText(request);

            txtVi.Text = result.TranslatedText;
        }
        /// <summary>
        /// List Amazon Translate text translation jobs.
        /// </summary>
        /// <param name="client">The initialized Amazon Translate client object.</param>
        /// <param name="request">An Amazon Translate
        /// ListTextTranslationJobsRequest object detailing which text
        /// translation jobs are of interest.</param>
        public static async Task ListJobsAsync(
            AmazonTranslateClient client,
            ListTextTranslationJobsRequest request)
        {
            ListTextTranslationJobsResponse response;

            do
            {
                response = await client.ListTextTranslationJobsAsync(request);

                ShowTranslationJobDetails(response.TextTranslationJobPropertiesList);

                request.NextToken = response.NextToken;
            }while (response.NextToken is not null);
        }
        public static async Task Main()
        {
            var client = new AmazonTranslateClient();
            var filter = new TextTranslationJobFilter
            {
                JobStatus = "COMPLETED",
            };

            var request = new ListTextTranslationJobsRequest
            {
                MaxResults = 10,
                Filter     = filter,
            };

            await ListJobsAsync(client, request);
        }
示例#15
0
        private void TranslateButton_Click(object sender, RoutedEventArgs e)
        {
            var accessKey = "AKIAUBMTEBYUP272NQGE";
            var secretKey = "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";

            var client  = new AmazonTranslateClient();
            var request = new TranslateTextRequest
            {
                Text = MyTextBox.Text,
                SourceLanguageCode = "en",
                TargetLanguageCode = "vi",
            };
            var respone = client.TranslateText(request);

            MyLable.Content = respone.TranslatedText;
        }
示例#16
0
        static async Task Main()
        {
            var region  = RegionEndpoint.APNortheast1;
            var client  = new AmazonTranslateClient(region);
            var request = new TranslateTextRequest
            {
                SourceLanguageCode = "ja",
                TargetLanguageCode = "en",
                Text = "おはようございます"
            };
            var resp = await client.TranslateTextAsync(request);

            var result = resp.TranslatedText;

            Console.WriteLine(result);
        }
示例#17
0
        public static async Task Translate(string text, string sourceLangaugeCode = "en",
                                           string targetLangaugeCode = "de")
        {
            //Generate the client, Note: The config is used from your initital CLI configuration
            var translate = new AmazonTranslateClient();
            //Build up request
            var request = new TranslateTextRequest
            {
                Text = text, SourceLanguageCode = sourceLangaugeCode, TargetLanguageCode = targetLangaugeCode
            };

            //Call translate service
            var translation = await translate.TranslateTextAsync(request);


            Console.WriteLine(translation.TranslatedText);
        }
示例#18
0
        private void btn_translate_Click(object sender, EventArgs e)
        {
            var accessKey = "AKIASASJUZ22KX7S2CPS";
            var secretKey = "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";

            var client = new AmazonTranslateClient(accessKey, secretKey, RegionEndpoint.APSoutheast1);

            var request = new TranslateTextRequest
            {
                Text = txt_langSource.Text,
                SourceLanguageCode = "en",
                TargetLanguageCode = "vi"
            };
            var result = client.TranslateText(request);

            txt_langTarget.Text = result.TranslatedText;
        }
        public ActionResult TranslateComment(TranslateCommentViewModel comment)
        {
            var translate = new AmazonTranslateClient("AWS-ACCESS-KEY", "AWS-SECRET-KEY", RegionEndpoint.USEast1);
            var request   = new TranslateTextRequest()
            {
                Text = comment.CommentText, SourceLanguageCode = "en", TargetLanguageCode = comment.TargetLanguage
            };
            var model = new TranslatedCommentViewModel()
            {
                CommentText       = comment.CommentText,
                SubmitterName     = comment.SubmitterName,
                TargetLangauge    = comment.TargetLanguage,
                TranslateResponse = translate.TranslateText(request) // Make the actual call to Amazon Translate
            };

            return(View(model));
        }
        public static async Task Main()
        {
            var client = new AmazonTranslateClient();

            // The Job Id is generated when the text translation job is started
            // with a call to the StartTextTranslationJob method.
            var jobId = "";

            var request = new DescribeTextTranslationJobRequest
            {
                JobId = jobId,
            };

            var jobProperties = await DescribeTranslationJobAsync(client, request);

            DisplayTranslationJobDetails(jobProperties);
        }
示例#21
0
        /// <summary>
        /// translates the text input
        /// </summary>
        /// <param name="sourceLang"></param>
        /// <param name="targetLang"></param>
        /// <param name="textToTranslate"></param>
        /// <param name="categoryId"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        internal string Translate(string sourceLang, string targetLang, string textToTranslate)
        {
            //convert our language codes
            var sourceLc = convertLangCode(sourceLang);
            var targetLc = convertLangCode(targetLang);


            var translatedText = string.Empty;


            Amazon.Runtime.AWSCredentials awsCreds  = null;
            Amazon.RegionEndpoint         awsRegion = null;


            if (_options.SelectedAuthType == MtTranslationOptions.AWSAuthType.Profile)
            {
                var credentialsFile = new SharedCredentialsFile();                                                        //TODO: always SharedCredentialsFile?
                var prof            = credentialsFile.TryGetProfile(_options.ProfileName, out CredentialProfile profile); //TODO: add in error-handling
                awsCreds  = profile.GetAWSCredentials(credentialsFile);
                awsRegion = profile.Region;
            }
            else
            {
                awsCreds  = new Amazon.Runtime.BasicAWSCredentials(_accessKey, _secretKey);
                awsRegion = Amazon.RegionEndpoint.GetBySystemName(_options.RegionName);
            }

            var tclient  = new AmazonTranslateClient(awsCreds, awsRegion);
            var trequest = new TranslateTextRequest();

            trequest.SourceLanguageCode = sourceLc;
            trequest.TargetLanguageCode = targetLc;
            trequest.Text = textToTranslate;
            try
            {
                var result = tclient.TranslateText(trequest);
                System.Diagnostics.Debug.WriteLine(result.TranslatedText);
                translatedText = result.TranslatedText;
            }
            catch (Amazon.Translate.AmazonTranslateException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                throw e;
            }
            return(translatedText);
        }
示例#22
0
        private void OnTranslate(object sender, RoutedEventArgs e)
        {
            string translateText = txtTextInput.Text.Trim();

            if (translateText != "")
            {
                var translate = new AmazonTranslateClient();
                var request   = new TranslateTextRequest()
                {
                    Text = translateText,
                    SourceLanguageCode = "en",
                    TargetLanguageCode = "vi"
                };
                TranslateTextResponse translateResponse = translate.TranslateText(request);
                txtTextResult.Text = translateResponse.TranslatedText;
            }
        }
示例#23
0
        private void txtEnglish_TextChanged(object sender, TextChangedEventArgs e)
        {
            var accessKey = "AKIASHKYRPNVFN5WYH4X";
            var secretKey = "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";

            var client = new AmazonTranslateClient(accessKey, secretKey, RegionEndpoint.APSoutheast1);

            var request = new TranslateTextRequest
            {
                Text = txtEnglish.Text,
                SourceLanguageCode = "en",
                TargetLanguageCode = "vi"
            };
            var result = client.TranslateText(request);

            txtVietnamese.Text = result.TranslatedText;
        }
示例#24
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var sourceText = txtSoure.Text;

            var client  = new AmazonTranslateClient();
            var request = new TranslateTextRequest()
            {
                Text = sourceText,
                SourceLanguageCode = "en",
                TargetLanguageCode = "vi"
            };

            try
            {
                var response = client.TranslateText(request);
                txtInfo.Text = string.Empty;
                txtInfo.Text = response.TranslatedText;
            }
            catch (Exception)
            {
            }
        }
示例#25
0
        public ActionResult TranslateComment(TranslateCommentViewModel comment)
        {
            var translate = new AmazonTranslateClient("AKIAX3JSZJ36DOCUNIJY", "vTKVVvQs01qY25LczK5uSdD3gev49cdXfKNr7LRT", RegionEndpoint.USEast1);
            var request   = new TranslateTextRequest()
            {
                Text = comment.CommentText, SourceLanguageCode = "en", TargetLanguageCode = comment.TargetLanguage
            };

            var task = translate.TranslateTextAsync(request); //.TranslateText(request) // Make the actual call to Amazon Translate

            task.Wait();

            var model = new TranslatedCommentViewModel()
            {
                CommentText       = comment.CommentText,
                SubmitterName     = comment.SubmitterName,
                TargetLangauge    = comment.TargetLanguage,
                TranslateResponse = task.Result
            };

            return(View(model));
        }
        public async Task <JsonResult> Post(string translateText, string inputLanguage, string outputLanguage)
        {
            try
            {
                using (var translateClient = new AmazonTranslateClient())
                {
                    var translateTextResponse = await translateClient.TranslateTextAsync(
                        new Amazon.Translate.Model.TranslateTextRequest()
                    {
                        Text = translateText,
                        SourceLanguageCode = inputLanguage,
                        TargetLanguageCode = outputLanguage
                    });

                    return(new JsonResult(translateTextResponse.HttpStatusCode == System.Net.HttpStatusCode.OK ?
                                          translateTextResponse.TranslatedText : "Error processing request"));
                }
            }
            catch (Exception ex)
            {
                return(new JsonResult(ex.Message));
            }
        }
示例#27
0
        public static async Task Main()
        {
            var contentType = "text/plain";
            var s3InputUri  = "http://doc-example-bucket.s3-website-us-west-2.amazonaws.com/";
            var s3OutputUri = "http://doc-example-bucket.s3-website-us-west-2.amazonaws.com/translated/";

            // This role must have permissions to read the source bucket and to read and
            // write to the destination bucket where the translated text will be stored.
            var dataAccessRoleArn = "arn:aws:iam::0123456789ab:role/S3TranslateRole";

            var client = new AmazonTranslateClient();

            var inputConfig = new InputDataConfig
            {
                ContentType = contentType,
                S3Uri       = s3InputUri,
            };

            var outputConfig = new OutputDataConfig
            {
                S3Uri = s3OutputUri,
            };

            var request = new StartTextTranslationJobRequest
            {
                DataAccessRoleArn = dataAccessRoleArn,
                InputDataConfig   = inputConfig,
                OutputDataConfig  = outputConfig,
            };

            var response = await StartTextTranslationAsync(client, request);

            if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
            {
                Console.WriteLine($"{response.JobId}: {response.JobStatus}");
            }
        }
示例#28
0
        private static void translateText(string userSentence, AmazonTranslateClient client)
        {
            // Danish
            // Italian
            // French
            // Spanish
            string[] languageCodes          = { "da", "it", "fr", "es" };
            string[] languages              = { "DANISH", "ITALIAN", "FRENCH", "SPANISH" };
            TranslateTextRequest[] requests = new TranslateTextRequest[4];

            // Create a list of request objects
            for (int i = 0; i < 4; i++)
            {
                TranslateTextRequest request = new TranslateTextRequest
                {
                    SourceLanguageCode = "en",
                    TargetLanguageCode = languageCodes[i],
                    Text = userSentence
                };

                requests[i] = request;
            }
            try
            {
                int i = 0;
                foreach (var r in requests)
                {
                    TranslateTextResponse response = client.TranslateText(r);
                    Console.WriteLine(languages[i] + ":  " + response.TranslatedText);
                    i++;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
示例#29
0
 public TranslationService(string id, string secret, string endpoint)
 {
     this.AWSTranslateClient = new AmazonTranslateClient(id, secret, Amazon.RegionEndpoint.GetBySystemName(endpoint));
 }
示例#30
0
        internal static async Task ProcessJobAssignmentAsync(AwsAiServiceWorkerRequest @event)
        {
            var resourceManager = @event.GetAwsV4ResourceManager();
            var table           = new DynamoDbTable(@event.StageVariables["TableName"]);
            var jobAssignmentId = @event.JobAssignmentId;

            try
            {
                // 1. Setting job assignment status to RUNNING
                await UpdateJobAssignmentStatusAsync(resourceManager, table, jobAssignmentId, "RUNNING", null);

                // 2. Retrieving WorkflowJob
                var job = await RetrieveJobAsync(resourceManager, table, jobAssignmentId);

                // 3. Retrieve JobProfile
                var jobProfile = await RetrieveJobProfileAsync(resourceManager, job);

                // 4. Retrieve job inputParameters
                var jobInput = job.JobInput;

                // 5. Check if we support jobProfile and if we have required parameters in jobInput
                ValidateJobProfile(jobProfile, jobInput);

                S3Locator inputFile;
                if (!jobInput.TryGet <S3Locator>(nameof(inputFile), out inputFile))
                {
                    throw new Exception("Invalid or missing input file.");
                }

                S3Locator outputLocation;
                if (!jobInput.TryGet <S3Locator>(nameof(outputLocation), out outputLocation))
                {
                    throw new Exception("Invalid or missing output location.");
                }

                switch (jobProfile.Name)
                {
                case JOB_PROFILE_TRANSCRIBE_AUDIO:
                    string mediaFileUrl;
                    if (!string.IsNullOrWhiteSpace(inputFile.HttpEndpoint))
                    {
                        mediaFileUrl = inputFile.HttpEndpoint;
                    }
                    else
                    {
                        var bucketLocation = await inputFile.GetBucketLocationAsync();

                        var s3SubDomain = !string.IsNullOrWhiteSpace(bucketLocation) ? $"s3-{bucketLocation}" : "s3";
                        mediaFileUrl = $"https://{s3SubDomain}.amazonaws.com/{inputFile.AwsS3Bucket}/{inputFile.AwsS3Key}";
                    }

                    string mediaFormat;
                    if (mediaFileUrl.EndsWith("mp3", StringComparison.OrdinalIgnoreCase))
                    {
                        mediaFormat = "mp3";
                    }
                    else if (mediaFileUrl.EndsWith("mp4", StringComparison.OrdinalIgnoreCase))
                    {
                        mediaFormat = "mp4";
                    }
                    else if (mediaFileUrl.EndsWith("wav", StringComparison.OrdinalIgnoreCase))
                    {
                        mediaFormat = "wav";
                    }
                    else if (mediaFileUrl.EndsWith("flac", StringComparison.OrdinalIgnoreCase))
                    {
                        mediaFormat = "flac";
                    }
                    else
                    {
                        throw new Exception($"Unable to determine media format from input file '{mediaFileUrl}'");
                    }

                    var transcribeParameters = new StartTranscriptionJobRequest
                    {
                        TranscriptionJobName = "TranscriptionJob-" + jobAssignmentId.Substring(jobAssignmentId.LastIndexOf("/") + 1),
                        LanguageCode         = "en-US",
                        Media = new Media {
                            MediaFileUri = mediaFileUrl
                        },
                        MediaFormat      = mediaFormat,
                        OutputBucketName = @event.StageVariables["ServiceOutputBucket"]
                    };

                    var transcribeService = new AmazonTranscribeServiceClient();

                    var startJobResponse = await transcribeService.StartTranscriptionJobAsync(transcribeParameters);

                    Logger.Debug(startJobResponse.ToMcmaJson().ToString());
                    break;

                case JOB_PROFILE_TRANSLATE_TEXT:
                    var s3Bucket = inputFile.AwsS3Bucket;
                    var s3Key    = inputFile.AwsS3Key;

                    GetObjectResponse s3Object;
                    try
                    {
                        s3Object = await inputFile.GetAsync();
                    }
                    catch (Exception error)
                    {
                        throw new Exception($"Unable to read file in bucket '{s3Bucket}' with key '{s3Key}'.", error);
                    }

                    var inputText = await new StreamReader(s3Object.ResponseStream).ReadToEndAsync();

                    var translateParameters = new TranslateTextRequest
                    {
                        SourceLanguageCode = jobInput.TryGet("sourceLanguageCode", out string srcLanguageCode) ? srcLanguageCode : "auto",
                        TargetLanguageCode = jobInput.Get <string>("targetLanguageCode"),
                        Text = inputText
                    };

                    var translateService  = new AmazonTranslateClient();
                    var translateResponse = await translateService.TranslateTextAsync(translateParameters);

                    var s3Params = new PutObjectRequest
                    {
                        BucketName  = outputLocation.AwsS3Bucket,
                        Key         = (!string.IsNullOrWhiteSpace(outputLocation.AwsS3KeyPrefix) ? outputLocation.AwsS3Key : string.Empty) + Guid.NewGuid() + ".txt",
                        ContentBody = translateResponse.TranslatedText
                    };

                    var outputS3 = await outputLocation.GetClientAsync();

                    await outputS3.PutObjectAsync(s3Params);

                    var jobOutput = new JobParameterBag();
                    jobOutput["outputFile"] = new S3Locator
                    {
                        AwsS3Bucket = s3Params.BucketName,
                        AwsS3Key    = s3Params.Key
                    };

                    Logger.Debug("Updating job assignment");
                    await UpdateJobAssignmentWithOutputAsync(table, jobAssignmentId, jobOutput);
                    await UpdateJobAssignmentStatusAsync(resourceManager, table, jobAssignmentId, "COMPLETED");

                    break;

                case JOB_PROFILE_DETECT_CELEBRITIES:
                    var randomBytes = new byte[16];
                    new Random().NextBytes(randomBytes);
                    var clientToken = randomBytes.HexEncode();

                    var base64JobId = Encoding.UTF8.GetBytes(jobAssignmentId).HexEncode();

                    var rekoParams = new StartCelebrityRecognitionRequest
                    {
                        Video = new Video
                        {
                            S3Object = new Amazon.Rekognition.Model.S3Object
                            {
                                Bucket = inputFile.AwsS3Bucket,
                                Name   = inputFile.AwsS3Key
                            }
                        },
                        ClientRequestToken  = clientToken,
                        JobTag              = base64JobId,
                        NotificationChannel = new NotificationChannel
                        {
                            RoleArn     = REKO_SNS_ROLE_ARN,
                            SNSTopicArn = SNS_TOPIC_ARN
                        }
                    };

                    var rekognitionClient             = new AmazonRekognitionClient();
                    var startCelebRecognitionResponse = await rekognitionClient.StartCelebrityRecognitionAsync(rekoParams);

                    Logger.Debug(startCelebRecognitionResponse.ToMcmaJson().ToString());
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);

                try
                {
                    await UpdateJobAssignmentStatusAsync(resourceManager, table, jobAssignmentId, "FAILED", ex.ToString());
                }
                catch (Exception innerEx)
                {
                    Logger.Exception(innerEx);
                }
            }
        }