How to use delete_transcription_job method in localstack

Best Python code snippet using localstack_python

transcribe.py

Source:transcribe.py Github

copy

Full Screen

...46 Transcribe.start_transcription_job(TranscriptionJobName=job_name, Media={'MediaFileUri': job_uri}, MediaFormat=filename.split('.')[-1], LanguageCode='ko-KR') #ko-KR en-US47 except:48 print(traceback.format_exc())49 try:50 Transcribe.delete_transcription_job(TranscriptionJobName=job_name)51 except:52 pass53 return HTTP_503_SERVICE_UNAVAILABLE, {}54 pass55 while True:56 status = Transcribe.get_transcription_job(TranscriptionJobName=job_name)57 print(status['TranscriptionJob']['TranscriptionJobStatus'])58 if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']:59 break60 time.sleep(1)61 if status['TranscriptionJob']['TranscriptionJobStatus'] == 'COMPLETED':62 response = urllib.request.urlopen(status['TranscriptionJob']['Transcript']['TranscriptFileUri'])63 data = json.loads(response.read())64 text = data['results']['transcripts'][0]['transcript']65 Transcribe.delete_transcription_job(TranscriptionJobName=job_name)66 self.dbClass.updateUserCumulativePredictCountByAppToken(user['appTokenCode'], 100)67 if self.dbClass.isUserHavingExceedPredictCountByAppToken(user['appTokenCode'], 100):68 return HTTP_503_SERVICE_UNAVAILABLE, {69 "statusCode": 503,70 "error": "Bad Request",71 "message": "예측 기능 사용량 초과입니다.",72 "message_en": "Prediction usage exceeded."73 }74 self.utilClass.sendSlackMessage(f"Transcribe 예측을 수행하였습니다. {user['email']}(ID :{user['id']})", appLog=True, userInfo=user)75 return HTTP_200_OK, {"transcrible-text":text}76 except:77 Transcribe.delete_transcription_job(TranscriptionJobName=job_name)78 print(traceback.format_exc())79 return HTTP_500_INTERNAL_SERVER_ERROR, {80 "statusCode": 500,81 "error": "Bad Request",82 "message": "잘못된 접근입니다."83 }...

Full Screen

Full Screen

LF4-audio-response.py

Source:LF4-audio-response.py Github

copy

Full Screen

...5 # logger = logging.getLogger()6 # logger.setLevel(logging.INFO)7 # logger.info(json.dumps(event))8 # client = boto3.client('transcribe')9 # responseCloseJob = client.delete_transcription_job(10 # TranscriptionJobName="transcription"11 # )12 bucketname = 'photo-book-b3'13 p = event['fname']14 response = ''15 try:16 #acces transcibed file and find message17 s3 = boto3.resource('s3')18 obj = s3.Object(bucketname, p)19 body = obj.get()['Body'].read()20 result = json.loads(body.decode('utf-8'))21 response = result['results']['transcripts'][0]['transcript'][:-1]22 except:23 #if no transcription.json file return special character24 response = '&'25 #clean up transcribe job and delete transcription.json from bucket26 if response != '&':27 client = boto3.client('transcribe')28 responseCloseJob = client.delete_transcription_job(29 TranscriptionJobName="transcription"30 )31 s3_client = boto3.client('s3')32 responseDelete = s3_client.delete_object(33 Bucket=bucketname,34 Key=p35 )36 return {37 'statusCode': 200,38 'body': json.dumps(response)...

Full Screen

Full Screen

update_transcribe_status.py

Source:update_transcribe_status.py Github

copy

Full Screen

...21 job = client.get_transcription_job(TranscriptionJobName=job_name)22 if job.get('TranscriptionJob', {}).get('TranscriptionJobStatus') == 'COMPLETED':23 call.is_transcribed = True24 call.save()25 client.delete_transcription_job(TranscriptionJobName=job_name)26 if job.get('TranscriptionJob', {}).get('TranscriptionJobStatus') == 'FAILED':27 call.transcription = None28 call.save()29 client.delete_transcription_job(TranscriptionJobName=job_name)30 except Exception as e:31 logging.error(e)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful