Commit
·
3e8f6f8
1
Parent(s):
9d452e1
Update handler.py
Browse files- handler.py +3 -16
handler.py
CHANGED
|
@@ -168,7 +168,8 @@ class EndpointHandler():
|
|
| 168 |
output_translations = []
|
| 169 |
if self.model is not None:
|
| 170 |
transcriptions = self.read_srt(transcript_path)
|
| 171 |
-
|
|
|
|
| 172 |
|
| 173 |
for i in tqdm(range(len(transcriptions))):
|
| 174 |
entry = transcriptions[i]
|
|
@@ -177,18 +178,4 @@ class EndpointHandler():
|
|
| 177 |
|
| 178 |
return output_translations
|
| 179 |
else:
|
| 180 |
-
return []
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
if __name__ == "__main__":
|
| 184 |
-
endpoint = EndpointHandler(quantization = "8-bit")
|
| 185 |
-
inputs = {}
|
| 186 |
-
inputs['src_lang'] = 'eng_Latn'
|
| 187 |
-
inputs['tgt_lang'] = 'tel_Telu'
|
| 188 |
-
inputs['transcript_path'] = './sample.srt'
|
| 189 |
-
|
| 190 |
-
outputs = endpoint.test(inputs)
|
| 191 |
-
|
| 192 |
-
print("Outputs: ")
|
| 193 |
-
for entry in outputs:
|
| 194 |
-
print(entry)
|
|
|
|
| 168 |
output_translations = []
|
| 169 |
if self.model is not None:
|
| 170 |
transcriptions = self.read_srt(transcript_path)
|
| 171 |
+
trans_sents = [entry['text'] for entry in transcriptions]
|
| 172 |
+
indic_translations = self.batch_translate(trans_sents, src_lang, tgt_lang)
|
| 173 |
|
| 174 |
for i in tqdm(range(len(transcriptions))):
|
| 175 |
entry = transcriptions[i]
|
|
|
|
| 178 |
|
| 179 |
return output_translations
|
| 180 |
else:
|
| 181 |
+
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|