ChiBenevisamPas commited on
Commit
9d51018
1 Parent(s): bbb69cc
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -105,20 +105,18 @@ def reverse_text_for_rtl(text):
105
  return ' '.join([word[::-1] for word in text.split()])
106
 
107
  # Helper function to write PDF documents
108
- # Helper function to write PDF documents (fixed RTL text handling)
109
  def write_pdf(transcription, output_file, tokenizer=None, translation_model=None):
110
  pdf = FPDF()
111
  pdf.add_page()
112
- font_path = "/home/user/app/Dirooz.ttf" # Ensure this is the correct path to the Persian font
113
- pdf.add_font('Dirooz', '', font_path, uni=True)
114
- pdf.set_font('Dirooz', size=12)
115
-
116
  for i, segment in enumerate(transcription['segments']):
117
  text = segment['text']
118
  if translation_model:
119
  text = translate_text(text, tokenizer, translation_model)
120
- # The text should be handled correctly for RTL without reversing
121
- pdf.multi_cell(0, 10, f"{i + 1}. {text.strip()}", align='R')
122
  pdf.output(output_file)
123
 
124
  # Helper function to write PowerPoint slides
 
105
  return ' '.join([word[::-1] for word in text.split()])
106
 
107
  # Helper function to write PDF documents
 
108
  def write_pdf(transcription, output_file, tokenizer=None, translation_model=None):
109
  pdf = FPDF()
110
  pdf.add_page()
111
+ font_path = "/home/user/app/B-NAZANIN.TTF"
112
+ pdf.add_font('B-NAZANIN', '', font_path, uni=True)
113
+ pdf.set_font('B-NAZANIN', size=12)
 
114
  for i, segment in enumerate(transcription['segments']):
115
  text = segment['text']
116
  if translation_model:
117
  text = translate_text(text, tokenizer, translation_model)
118
+ reversed_text = reverse_text_for_rtl(text)
119
+ pdf.multi_cell(0, 10, f"{i + 1}. {reversed_text.strip()}", align='L')
120
  pdf.output(output_file)
121
 
122
  # Helper function to write PowerPoint slides