ChiBenevisamPas commited on
Commit
d7e8845
·
verified ·
1 Parent(s): a5e2810

Update Font

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -117,20 +117,24 @@ def write_word(transcription, output_file, tokenizer=None, translation_model=Non
117
  def write_pdf(transcription, output_file, tokenizer=None, translation_model=None):
118
  """Creates a PDF document from the transcription without timestamps."""
119
  pdf = FPDF()
120
- pdf.set_auto_page_break(auto=True, margin=15)
121
  pdf.add_page()
122
- pdf.set_font("Arial", size=12)
123
 
 
 
 
 
 
124
  for i, segment in enumerate(transcription['segments']):
125
  text = segment['text']
126
 
127
  if translation_model:
128
  text = translate_text(text, tokenizer, translation_model)
129
 
130
- pdf.multi_cell(0, 10, f"{i + 1}. {text.strip()}") # No timestamps
131
-
132
  pdf.output(output_file)
133
 
 
134
  def write_ppt(transcription, output_file, tokenizer=None, translation_model=None):
135
  """Creates a PowerPoint presentation from the transcription without timestamps."""
136
  ppt = Presentation()
 
117
  def write_pdf(transcription, output_file, tokenizer=None, translation_model=None):
118
  """Creates a PDF document from the transcription without timestamps."""
119
  pdf = FPDF()
 
120
  pdf.add_page()
 
121
 
122
+ # Set up the font for Farsi (Unicode-compliant)
123
+ font_path = "B-NAZANIN.ttf" # Adjust this path as per your environment
124
+ pdf.add_font('B-NAZANIN', '', font_path, uni=True)
125
+ pdf.set_font('B-NAZANIN', size=12)
126
+
127
  for i, segment in enumerate(transcription['segments']):
128
  text = segment['text']
129
 
130
  if translation_model:
131
  text = translate_text(text, tokenizer, translation_model)
132
 
133
+ pdf.multi_cell(0, 10, f"{i + 1}. {text.strip()}", align='R') # Right-align for Farsi
134
+
135
  pdf.output(output_file)
136
 
137
+
138
  def write_ppt(transcription, output_file, tokenizer=None, translation_model=None):
139
  """Creates a PowerPoint presentation from the transcription without timestamps."""
140
  ppt = Presentation()