Created
December 19, 2019 13:30
-
-
Save selcukcihan/4ad4623f4d6e5c8bdc2fbc8c37f3b0ab to your computer and use it in GitHub Desktop.
Yapay zeka örneği için lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
import logging | |
import time | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
transcribe = boto3.client('transcribe') | |
def lambda_handler(event, context): | |
for record in event['Records']: | |
bucket = record['s3']['bucket']['name'] | |
key = record['s3']['object']['key'] | |
logger.info("%s bucket'ındaki %s objesi işleniyor.", bucket, key) | |
uri = "https://s3.%s.amazonaws.com/%s/%s" % (record["awsRegion"], bucket, key) | |
res = transcribe.start_transcription_job( | |
TranscriptionJobName=key + "_" + str(int(time.time())), | |
LanguageCode='tr-TR', | |
Media={ | |
"MediaFileUri": uri | |
}, | |
OutputBucketName="turkce-yazi" | |
) | |
logger.info("Transcribe durumu: %s", | |
json.dumps(res["TranscriptionJob"]["TranscriptionJobStatus"])) | |
return { | |
'statusCode': 200, | |
'body': json.dumps('Sesten yazıya çevirme işlemi başlatıldı.') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment