Saving Urdu (RTL) in a text file from API to preserve the format

212 views Asked by At

I am transcribing a few chunks of Urdu audio using an API - when I open in notepad - the order of text is messed up. Specifically the sentence that comes AFTER a period/punctuation is looped around the line.

For e.g if the text is "ABCDE.FGH" it becomes "FGH.ABCDE" (just an english example)

When saving the text file I use this snippet

if res['status'] == 'OK':
    wf = codecs.open(os.path.join(saveTo,file.split('/')[-1][:-4] + '.txt'), "w", encoding="utf-8")
    transcribed_text = res['text'].strip()
    wf.write(transcribed_text)
    wf.close()

Do I need to change the encoding or something? Any better way for Python?

0

There are 0 answers