Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -114,18 +114,18 @@ def write_pdf(transcription, output_file, tokenizer=None, translation_model=None
|
|
114 |
# Create PDF with A4 page size
|
115 |
c = canvas.Canvas(output_file, pagesize=A4)
|
116 |
# Get the directory where app.py is located
|
117 |
-
app_dir = os.path.dirname(os.path.abspath(__file__))
|
118 |
|
119 |
-
# Construct the full path to the font file
|
120 |
-
font_path = os.path.join(app_dir, 'B-NAZANIN.TTF')
|
121 |
|
122 |
-
if os.path.exists(font_path):
|
123 |
-
|
124 |
registerFont(TTFont('B-Nazanin', font_path))
|
125 |
-
|
126 |
-
|
127 |
-
else:
|
128 |
-
|
129 |
|
130 |
|
131 |
|
|
|
114 |
# Create PDF with A4 page size
|
115 |
c = canvas.Canvas(output_file, pagesize=A4)
|
116 |
# Get the directory where app.py is located
|
117 |
+
app_dir = os.path.dirname(os.path.abspath(__file__))
|
118 |
|
119 |
+
# Construct the full path to the font file
|
120 |
+
font_path = os.path.join(app_dir, 'B-NAZANIN.TTF')
|
121 |
|
122 |
+
if os.path.exists(font_path):
|
123 |
+
try:
|
124 |
registerFont(TTFont('B-Nazanin', font_path))
|
125 |
+
except TTFError as e:
|
126 |
+
raise RuntimeError(f"Error registering font: {e}.")
|
127 |
+
else:
|
128 |
+
raise FileNotFoundError(f"Font file not found at {font_path}. Please ensure it is available.")
|
129 |
|
130 |
|
131 |
|