rosyvs commited on
Commit
21f97b6
·
1 Parent(s): 8ce3d10

Replace logging with print statements for error handling in transcript sorting and video conversion functions

Browse files
Files changed (1) hide show
  1. utils.py +6 -5
utils.py CHANGED
@@ -52,11 +52,11 @@ def sort_transcript(file_path: str, save_path: str) -> str:
52
  logging.info(f"Processed the file into a DataFrame with {table.shape[0]} rows and {table.shape[1]} columns.")
53
 
54
  except Exception as e:
55
- logging.error(f"Error processing the file: {e}")
56
  raise e
57
  else:
58
  error_msg = f"Unsupported file format: {file_ext}. Must be '.txt' or '.tsv'."
59
- logging.error(error_msg)
60
  raise ValueError(error_msg)
61
 
62
  try:
@@ -70,7 +70,7 @@ def sort_transcript(file_path: str, save_path: str) -> str:
70
  sorted_table.to_csv(save_path, sep='\t', index=False, header=False)
71
  logging.info(f"Saved sorted transcript to {save_path}")
72
  except Exception as e:
73
- logging.error(f"Error sorting and saving the transcript: {e}")
74
  raise e
75
 
76
  return save_path
@@ -207,7 +207,7 @@ def convert_and_trim_video(media_in, media_out, start=None, end=None):
207
 
208
  in_ext = Path(media_in).suffix.lower()
209
  out_ext = Path(media_out).suffix.lower()
210
- logging.info(f'...detected extensions from filename: input={in_ext} output={out_ext}')
211
  if in_ext == out_ext:
212
  logging.info(f'...No media conversion needed...')
213
  else:
@@ -257,11 +257,12 @@ def convert_and_trim_video(media_in, media_out, start=None, end=None):
257
  process = subprocess.run(command, capture_output=True, text=True)
258
  if process.returncode != 0:
259
  logging.info(f"FFMPEG error: {process.stderr}")
 
260
  gr.Error(f"FFMPEG error: {process.stderr}")
261
  else:
262
  logging.info(process.stdout)
263
  return media_out
264
 
265
  except Exception as e:
266
- logging.error(f"Error converting video format: {e}")
267
  gr.Error(f"Error converting video format: {e}")
 
52
  logging.info(f"Processed the file into a DataFrame with {table.shape[0]} rows and {table.shape[1]} columns.")
53
 
54
  except Exception as e:
55
+ print(f"Error processing the file: {e}")
56
  raise e
57
  else:
58
  error_msg = f"Unsupported file format: {file_ext}. Must be '.txt' or '.tsv'."
59
+ print(error_msg)
60
  raise ValueError(error_msg)
61
 
62
  try:
 
70
  sorted_table.to_csv(save_path, sep='\t', index=False, header=False)
71
  logging.info(f"Saved sorted transcript to {save_path}")
72
  except Exception as e:
73
+ print(f"Error sorting and saving the transcript: {e}")
74
  raise e
75
 
76
  return save_path
 
207
 
208
  in_ext = Path(media_in).suffix.lower()
209
  out_ext = Path(media_out).suffix.lower()
210
+ print(f'...detected extensions from filename: input={in_ext} output={out_ext}')
211
  if in_ext == out_ext:
212
  logging.info(f'...No media conversion needed...')
213
  else:
 
257
  process = subprocess.run(command, capture_output=True, text=True)
258
  if process.returncode != 0:
259
  logging.info(f"FFMPEG error: {process.stderr}")
260
+ print(f"FFMPEG error: {process.stderr}")
261
  gr.Error(f"FFMPEG error: {process.stderr}")
262
  else:
263
  logging.info(process.stdout)
264
  return media_out
265
 
266
  except Exception as e:
267
+ print(f"Error converting video format: {e}")
268
  gr.Error(f"Error converting video format: {e}")