Spaces:
Sleeping
Sleeping
Update Def PDF 3
Browse files
app.py
CHANGED
@@ -96,23 +96,21 @@ def write_word(transcription, output_file, tokenizer=None, translation_model=Non
|
|
96 |
from fpdf import FPDF # This imports fpdf2, not the older FPDF
|
97 |
|
98 |
def write_pdf(transcription, output_file, tokenizer=None, translation_model=None):
|
99 |
-
"""Creates a PDF document from the transcription
|
100 |
pdf = FPDF()
|
101 |
pdf.set_auto_page_break(auto=True, margin=15)
|
102 |
pdf.add_page()
|
|
|
|
|
|
|
103 |
|
104 |
-
# Add a Unicode font that supports Persian, like 'DejaVuSans' or 'Vazir'
|
105 |
-
pdf.add_font("DejaVu", '', '/path/to/DejaVuSans.ttf', uni=True) # Ensure the path is correct
|
106 |
-
pdf.set_font("DejaVu", '', 12)
|
107 |
|
108 |
-
for i, segment in enumerate(transcription['segments']):
|
109 |
text = segment['text']
|
110 |
-
|
111 |
if translation_model:
|
112 |
text = translate_text(text, tokenizer, translation_model)
|
113 |
-
|
114 |
-
|
115 |
-
pdf.multi_cell(0, 10, f"{i + 1}. {text}")
|
116 |
|
117 |
pdf.output(output_file)
|
118 |
|
|
|
96 |
from fpdf import FPDF # This imports fpdf2, not the older FPDF
|
97 |
|
98 |
def write_pdf(transcription, output_file, tokenizer=None, translation_model=None):
|
99 |
+
"""Creates a PDF document from the transcription without timestamps."""
|
100 |
pdf = FPDF()
|
101 |
pdf.set_auto_page_break(auto=True, margin=15)
|
102 |
pdf.add_page()
|
103 |
+
pdf.set_font("Arial", size=12)
|
104 |
+
|
105 |
+
for i, segment in enumerate(transcription['segments']):
|
106 |
|
|
|
|
|
|
|
107 |
|
|
|
108 |
text = segment['text']
|
109 |
+
|
110 |
if translation_model:
|
111 |
text = translate_text(text, tokenizer, translation_model)
|
112 |
+
|
113 |
+
pdf.multi_cell(0, 10, f"{i + 1}. {text.strip()}")
|
|
|
114 |
|
115 |
pdf.output(output_file)
|
116 |
|