FrancoisHB commited on
Commit
f91d5ee
1 Parent(s): a8924ed

Commit Test SRT

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -1,10 +1,11 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
 
4
  # Function to extract text from SRT-formatted text
5
  def extract_text_from_srt_text(srt_text):
6
- lines = srt_text.strip().split("\n")
7
- texts = [line.split("\n")[2] for line in lines if not line.startswith("0")]
8
  return " ".join(texts)
9
 
10
  # Load summarization pipeline
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Function to extract text from SRT-formatted text
5
  # Function to extract text from SRT-formatted text
6
  def extract_text_from_srt_text(srt_text):
7
+ lines = srt_text.strip().split("\n\n") # Split by empty lines to separate subtitles
8
+ texts = [subtitle.split("\n")[2] for subtitle in lines if subtitle.strip()] # Extract text from the third line of each subtitle
9
  return " ".join(texts)
10
 
11
  # Load summarization pipeline