Project translates english language to hindi language in devanagari script. same script can be used for translating any one language to subsequent another language.
actual eng text : ['the holy dip is on november']
actual hindi text : ['मुख्य स्नान नवंबर को है']
translated hindi text : ['नवंबर को अंतिम रूप से ये संशोधित श्रृंखला शुरू होती है।']
well it's not perfect since it is trained on just 69201 pairs of english-hindi parallel dataset. To train good encoder-decoder translation model it requires millions of parallel corpus of dataset and good amout of training time.
def translate(eng_sent):
_, eh, ec = inf_enc_model.predict(eng_sent.reshape(1, len(eng_sent)))
translated = []
dec_inp_seq = np.array([2]).reshape(1,1) #2 for start token and 1 for end
stop = False
while not stop:
d, [eh, ec] = dec_model_final.predict([dec_inp_seq, [eh, ec]])
dec_inp_seq[:,] = np.argmax(d[0][0])
translated.append(np.argmax(d[0][0]))
if dec_inp_seq[0][0] == 1 or len(translated)>16:
stop = True
return translated
MIT