Skip to content

Instantly share code, notes, and snippets.

@selcukcihan
Created December 19, 2019 13:30
Show Gist options
  • Save selcukcihan/4ad4623f4d6e5c8bdc2fbc8c37f3b0ab to your computer and use it in GitHub Desktop.
Save selcukcihan/4ad4623f4d6e5c8bdc2fbc8c37f3b0ab to your computer and use it in GitHub Desktop.
Yapay zeka örneği için lambda
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