Update modules/whisper/whisper_base.py
Browse files
modules/whisper/whisper_base.py
CHANGED
|
@@ -251,7 +251,7 @@ class WhisperBase(ABC):
|
|
| 251 |
#
|
| 252 |
# files_info[file_name] = {"subtitle": subtitle, "time_for_task": time_for_task, "path": file_path, "lang": file_language}
|
| 253 |
|
| 254 |
-
## Add
|
| 255 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
| 256 |
subtitle, file_path = self.generate_and_write_file(
|
| 257 |
file_name=file_name,
|
|
@@ -260,10 +260,9 @@ class WhisperBase(ABC):
|
|
| 260 |
file_format="txt",
|
| 261 |
output_dir=self.output_dir
|
| 262 |
)
|
|
|
|
| 263 |
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
## Add 2nd file as srt
|
| 267 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
| 268 |
subtitle, file_path = self.generate_and_write_file(
|
| 269 |
file_name=file_name,
|
|
@@ -272,8 +271,9 @@ class WhisperBase(ABC):
|
|
| 272 |
file_format="srt",
|
| 273 |
output_dir=self.output_dir
|
| 274 |
)
|
| 275 |
-
|
| 276 |
-
|
|
|
|
| 277 |
|
| 278 |
total_result = ''
|
| 279 |
total_info = ''
|
|
@@ -282,14 +282,14 @@ class WhisperBase(ABC):
|
|
| 282 |
total_result += f'{info["subtitle"]}'
|
| 283 |
total_time += info["time_for_task"]
|
| 284 |
#total_info += f'{info["lang"]}'
|
| 285 |
-
total_info += f"Language {info['lang']} detected for file '{file_name}{file_ext}'"
|
|
|
|
| 286 |
|
| 287 |
#result_str = f"Processing of file '{file_name}{file_ext}' done in {self.format_time(total_time)}:\n\n{total_result}"
|
| 288 |
total_info += f"\nTranscription process done in {self.format_time(total_time)}"
|
| 289 |
result_str = total_result
|
| 290 |
result_file_path = [info['path'] for info in files_info.values()]
|
| 291 |
|
| 292 |
-
total_info +=str(len(files_info))
|
| 293 |
return [result_str, result_file_path, total_info]
|
| 294 |
|
| 295 |
except Exception as e:
|
|
|
|
| 251 |
#
|
| 252 |
# files_info[file_name] = {"subtitle": subtitle, "time_for_task": time_for_task, "path": file_path, "lang": file_language}
|
| 253 |
|
| 254 |
+
## Add output file as txt
|
| 255 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
| 256 |
subtitle, file_path = self.generate_and_write_file(
|
| 257 |
file_name=file_name,
|
|
|
|
| 260 |
file_format="txt",
|
| 261 |
output_dir=self.output_dir
|
| 262 |
)
|
| 263 |
+
files_info[file_name+"_txt"] = {"subtitle": subtitle, "time_for_task": time_for_task, "path": file_path, "lang": file_language}
|
| 264 |
|
| 265 |
+
## Add output file as srt
|
|
|
|
|
|
|
| 266 |
file_name, file_ext = os.path.splitext(os.path.basename(file))
|
| 267 |
subtitle, file_path = self.generate_and_write_file(
|
| 268 |
file_name=file_name,
|
|
|
|
| 271 |
file_format="srt",
|
| 272 |
output_dir=self.output_dir
|
| 273 |
)
|
| 274 |
+
files_info[file_name+"_srt"] = {"subtitle": subtitle, "time_for_task": time_for_task, "path": file_path, "lang": file_language}
|
| 275 |
+
|
| 276 |
+
break ## Processing of 1 line
|
| 277 |
|
| 278 |
total_result = ''
|
| 279 |
total_info = ''
|
|
|
|
| 282 |
total_result += f'{info["subtitle"]}'
|
| 283 |
total_time += info["time_for_task"]
|
| 284 |
#total_info += f'{info["lang"]}'
|
| 285 |
+
total_info += f"Language {info['lang']} detected for file '{file_name}{file_ext}'"
|
| 286 |
+
break ## Processing of 1 line
|
| 287 |
|
| 288 |
#result_str = f"Processing of file '{file_name}{file_ext}' done in {self.format_time(total_time)}:\n\n{total_result}"
|
| 289 |
total_info += f"\nTranscription process done in {self.format_time(total_time)}"
|
| 290 |
result_str = total_result
|
| 291 |
result_file_path = [info['path'] for info in files_info.values()]
|
| 292 |
|
|
|
|
| 293 |
return [result_str, result_file_path, total_info]
|
| 294 |
|
| 295 |
except Exception as e:
|