Spaces:
Sleeping
Sleeping
ChiBenevisamPas
commited on
Commit
•
9d51018
1
Parent(s):
bbb69cc
PDF 2
Browse files
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/
|
113 |
-
pdf.add_font('
|
114 |
-
pdf.set_font('
|
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 |
-
|
121 |
-
pdf.multi_cell(0, 10, f"{i + 1}. {
|
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
|