ChiBenevisamPas commited on
Commit
0dbfe10
1 Parent(s): 3d2a173
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -82,45 +82,39 @@ def embed_hardsub_in_video(video_file, srt_file, output_video):
82
  raise RuntimeError(f"Error running ffmpeg: {e}")
83
 
84
  def write_word(transcription, output_file, tokenizer=None, translation_model=None):
85
- """Creates a Word document from the transcription."""
86
  doc = Document()
87
  for i, segment in enumerate(transcription['segments']):
88
- start = segment['start']
89
- end = segment['end']
90
  text = segment['text']
91
 
92
  if translation_model:
93
  text = translate_text(text, tokenizer, translation_model)
94
 
95
- doc.add_paragraph(f"{i + 1}. [{format_timestamp(start)} - {format_timestamp(end)}] {text.strip()}")
96
  doc.save(output_file)
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
  pdf.set_font("Arial", size=12)
104
 
105
  for i, segment in enumerate(transcription['segments']):
106
- start = segment['start']
107
- end = segment['end']
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}. [{format_timestamp(start)} - {format_timestamp(end)}] {text.strip()}")
114
 
115
  pdf.output(output_file)
116
 
117
  def write_ppt(transcription, output_file, tokenizer=None, translation_model=None):
118
- """Creates a PowerPoint presentation from the transcription."""
119
  ppt = Presentation()
120
 
121
  for i, segment in enumerate(transcription['segments']):
122
- start = segment['start']
123
- end = segment['end']
124
  text = segment['text']
125
 
126
  if translation_model:
@@ -128,7 +122,7 @@ def write_ppt(transcription, output_file, tokenizer=None, translation_model=None
128
 
129
  slide = ppt.slides.add_slide(ppt.slide_layouts[5]) # Blank slide
130
  title = slide.shapes.title
131
- title.text = f"{i + 1}. [{format_timestamp(start)} - {format_timestamp(end)}] {text.strip()}"
132
 
133
  ppt.save(output_file)
134
 
 
82
  raise RuntimeError(f"Error running ffmpeg: {e}")
83
 
84
  def write_word(transcription, output_file, tokenizer=None, translation_model=None):
85
+ """Creates a Word document from the transcription without timestamps."""
86
  doc = Document()
87
  for i, segment in enumerate(transcription['segments']):
 
 
88
  text = segment['text']
89
 
90
  if translation_model:
91
  text = translate_text(text, tokenizer, translation_model)
92
 
93
+ doc.add_paragraph(f"{i + 1}. {text.strip()}") # No timestamps
94
  doc.save(output_file)
95
 
96
  def write_pdf(transcription, output_file, tokenizer=None, translation_model=None):
97
+ """Creates a PDF document from the transcription without timestamps."""
98
  pdf = FPDF()
99
  pdf.set_auto_page_break(auto=True, margin=15)
100
  pdf.add_page()
101
  pdf.set_font("Arial", size=12)
102
 
103
  for i, segment in enumerate(transcription['segments']):
 
 
104
  text = segment['text']
105
 
106
  if translation_model:
107
  text = translate_text(text, tokenizer, translation_model)
108
 
109
+ pdf.multi_cell(0, 10, f"{i + 1}. {text.strip()}") # No timestamps
110
 
111
  pdf.output(output_file)
112
 
113
  def write_ppt(transcription, output_file, tokenizer=None, translation_model=None):
114
+ """Creates a PowerPoint presentation from the transcription without timestamps."""
115
  ppt = Presentation()
116
 
117
  for i, segment in enumerate(transcription['segments']):
 
 
118
  text = segment['text']
119
 
120
  if translation_model:
 
122
 
123
  slide = ppt.slides.add_slide(ppt.slide_layouts[5]) # Blank slide
124
  title = slide.shapes.title
125
+ title.text = f"{i + 1}. {text.strip()}" # No timestamps
126
 
127
  ppt.save(output_file)
128