AlbertoFH98 commited on
Commit
eb07d82
·
1 Parent(s): ed3190f

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +8 -3
utils.py CHANGED
@@ -106,7 +106,7 @@ PREGUNTA:""", cleaned_prompt, re.DOTALL)
106
  )
107
  text = output['output']['choices'][0]['text']
108
  text = self.clean_duplicates(text)
109
- return text
110
 
111
  # -- Python function to setup basic features: translator, SpaCy pipeline and LLM model
112
  @st.cache_resource
@@ -216,11 +216,16 @@ def time_to_seconds(time_str):
216
  return int((hours * 3600) + (minutes * 60) + seconds)
217
 
218
  # -- Extract seconds from transcription
219
- def add_hyperlink_and_convert_to_seconds(text):
220
  time_pattern = r'(\d{2}:\d{2}:\d{2}(?:.\d{6})?)'
221
 
222
  def get_seconds(match):
223
- start_time_str, end_time_str = match[0], match[1]
 
 
 
 
 
224
  start_time_seconds = time_to_seconds(start_time_str)
225
  end_time_seconds = time_to_seconds(end_time_str)
226
  return start_time_str, start_time_seconds, end_time_str, end_time_seconds
 
106
  )
107
  text = output['output']['choices'][0]['text']
108
  text = self.clean_duplicates(text)
109
+ return text, new_cleaned_prompt
110
 
111
  # -- Python function to setup basic features: translator, SpaCy pipeline and LLM model
112
  @st.cache_resource
 
216
  return int((hours * 3600) + (minutes * 60) + seconds)
217
 
218
  # -- Extract seconds from transcription
219
+ def add_hyperlink_and_convert_to_seconds(text, original_prompt):
220
  time_pattern = r'(\d{2}:\d{2}:\d{2}(?:.\d{6})?)'
221
 
222
  def get_seconds(match):
223
+ if len(match) == 2:
224
+ start_time_str, end_time_str = match[0], match[1]
225
+ else:
226
+ start_time_str = match[0]
227
+ end_time_str = re.findall(r"Desde el instante {} hasta {}".format(start_time_str, time_pattern))[0].split('hasta ')[-1]
228
+
229
  start_time_seconds = time_to_seconds(start_time_str)
230
  end_time_seconds = time_to_seconds(end_time_str)
231
  return start_time_str, start_time_seconds, end_time_str, end_time_seconds