Commit 0c658a5c authored by Pamal-Ranasinghe's avatar Pamal-Ranasinghe

final out put video uploaded to the aws s3

parent 98243cc2
...@@ -4,8 +4,8 @@ import numpy as np ...@@ -4,8 +4,8 @@ import numpy as np
class AwsOperation: class AwsOperation:
def __init__(self, bucket_name): def __init__(self):
self.bucket_name = bucket_name pass
def s3_connector(self): def s3_connector(self):
...@@ -13,5 +13,5 @@ class AwsOperation: ...@@ -13,5 +13,5 @@ class AwsOperation:
aws_access_key_id="AKIAWAP4EPNHCC6BXFXV", aws_access_key_id="AKIAWAP4EPNHCC6BXFXV",
aws_secret_access_key="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", aws_secret_access_key="zMj6vrgU8Bc2zcdUALhJ+8RspEbO7mholsZ2mxzZ",
) )
s3 = session.resource('s3') return session.resource('s3')
return s3.Bucket(self.bucket_name) # return s3.Bucket(self.bucket_name)
\ No newline at end of file \ No newline at end of file
from .awsOperation import AwsOperation
from moviepy.editor import *
from loguru import logger
import os
import json
import cv2
import numpy as np
import glob
# pamalcodex
class WordMapping:
def __init__(self, filtered_sentence):
self.filtered_sentence = filtered_sentence
def words_map_with_gestures(self):
try:
clip_arr = []
aws = AwsOperation()
s3_session = aws.s3_connector()
bucket = s3_session.Bucket('rpserverone')
extension = ".mp4"
for i in range(0, len(self.filtered_sentence)):
print(type(i))
print(str(self.filtered_sentence[i]) + extension)
bucket.download_file(str(self.filtered_sentence[i])+extension, 'D:/s3_tute/'+str(self.filtered_sentence[i])+extension)
for filename in glob.glob('D:/s3_tute/*.mp4'):
clip = VideoFileClip(filename)
clip_arr.append(clip)
final = concatenate_videoclips(clip_arr)
final.write_videofile("assets/final_video/final_out.mp4")
s3_session.meta.client.upload_file("assets/final_video/final_out.mp4","pamalcodex", "final_out.mp4")
os.remove(os.path.join("D:/rp_server_one/assets/final_video", "final_out.mp4"))
except Exception as e:
logger.error(str(e))
return json.loads(json.dumps({"message" : str(e)})), 500
\ No newline at end of file
from nltk.tokenize import word_tokenize from nltk.tokenize import word_tokenize
from loguru import logger from loguru import logger
from .awsOperation import AwsOperation from .awsOperation import AwsOperation
from .wordsMappingModel import WordMapping
from moviepy.editor import *
import os import os
import json import json
import cv2 import cv2
import numpy as np import numpy as np
import glob import glob
from moviepy.editor import *
class WordModel: class WordModel:
...@@ -39,24 +41,8 @@ class WordModel: ...@@ -39,24 +41,8 @@ class WordModel:
if w not in stop_words: if w not in stop_words:
filtered_sentence.append(w) filtered_sentence.append(w)
aws = AwsOperation('rpserverone') word_mapper = WordMapping(filtered_sentence)
bucket = aws.s3_connector() word_mapper.words_map_with_gestures()
extension = ".mp4"
# sign_names = ["this", "beautiful", "day"]
for i in range(0, len(filtered_sentence)):
print(type(i))
print(str(filtered_sentence[i]) + extension)
bucket.download_file(str(filtered_sentence[i])+extension, 'D:/s3_tute/'+str(filtered_sentence[i])+extension)
for filename in glob.glob('D:/s3_tute/*.mp4'):
clip = VideoFileClip(filename)
clip_arr.append(clip)
final = concatenate_videoclips(clip_arr)
final.write_videofile("final_out.mp4")
return json.loads(json.dumps({ return json.loads(json.dumps({
"filtered_words" : filtered_sentence, "filtered_words" : filtered_sentence,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment