in translate_captions/captions_helper.py [0:0]
def srtToCaptions(self, vttObject):
captions = []
srt = ""
# Get metadata
s3 = boto3.client('s3')
try:
self.logger.debug("Getting data from s3://"+vttObject["Bucket"]+"/"+vttObject["Key"])
srt = S3Helper().readFromS3(vttObject["Bucket"], vttObject["Key"])
self.logger.debug(srt)
except Exception as e:
raise e
#buffer = StringIO(srt)
f = NamedTemporaryFile(mode='w+', delete=False)
f.write(srt)
f.close()
for srtcaption in webvtt.from_srt(f.name):
caption = {}
self.logger.debug(srtcaption)
caption["start"] = self.formatTimeVTTtoSeconds(srtcaption.start)
caption["end"] = self.formatTimeVTTtoSeconds(srtcaption.end)
caption["caption"] = srtcaption.lines[0]
self.logger.debug("Caption Object:{}".format(caption))
captions.append(caption)
return captions