AWS Translate | Translating documents with Amazon Translate, AWS Lambda |

  Рет қаралды 1,869

Cloud4DevOps

Cloud4DevOps

Күн бұрын

Video will help us to understand the concept of AWS Translate with one of the production use case. Below pointers covered:-
- Concept
- Demo:- Translating documents with Amazon Translate, AWS Lambda
Lambda Function:-
=================
import json
import boto3
s3_client = boto3.client(service_name='s3')
translate = boto3.client('translate')
def translate_text(text, lang_code):
result = translate.translate_text(
Text=text,
SourceLanguageCode='auto',
TargetLanguageCode=lang_code
)
return result['TranslatedText']
def lambda_handler(event, context):
file_name = event['Records'][0]['s3']['object']['key']
bucketName=event['Records'][0]['s3']['bucket']['name']
outfile="s3://outtransbucket/{}".format(file_name)
print("Event details : ",event)
print("Input File Name : ",file_name)
print("Input Bucket Name : ",bucketName)
print("Output File Name : ",outfile)
get S3 object
result = s3_client.get_object(Bucket=bucketName, Key=file_name)
#Read a text file line by line using splitlines object
final_document_array = ""
for line in result["Body"].read().splitlines():
each_line = line.decode('utf-8')
print("Input Line : ",each_line)
if(each_line!=''):
translated=translate_text(each_line, 'hi')
print("After translation : ",translated)
final_document_array+=translated
final_document_array+='

'
s3_client.put_object(Body=final_document_array, Bucket='outtransbucket', Key=file_name)
print("Done")
=========
Supported languages and language codes:-
docs.aws.amazo...
If you like the video please like, comment, share and subscribe to the channel to get more updates on technical videos.
Channel Link:- www.youtube.co...
Join Me on the LinkedIn Group for More updates:- / 13859292
Happy Learning !!!

Пікірлер: 1
@MyFun-ty1kr
@MyFun-ty1kr 14 күн бұрын
you forgot to edit the video!!
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН
Win This Dodgeball Game or DIE…
00:36
Alan Chikin Chow
Рет қаралды 38 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 99 МЛН
Amazon Translate Service with AWS API Gateway and Python Lambda Function
15:09
Knowledge Amplifier
Рет қаралды 2,4 М.
AWS Landing Zone - Best Practices | Concepts | @Cloud4DevOps
13:30
Cloud4DevOps
Рет қаралды 10 М.
AWS Tutorials - Custom Text Classification using Amazon Comprehend
31:14
AWS Architecture - Disaster Recovery Strategies walkthrough
19:24
AWS Cloud Bytes
Рет қаралды 24 М.
How to Query Your DynamoDB Table with SQL using Athena
26:13
Be A Better Dev
Рет қаралды 15 М.
How to finally Git Good
9:43
Code Persist
Рет қаралды 19 М.
Build a Chatbot Using Amazon Lex
32:17
AWS User Group India
Рет қаралды 35 М.
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН