Spaces:
Running
Running
jhj0517
commited on
Commit
·
0036278
1
Parent(s):
9cf3b54
Fix format and add `add_timestamp`
Browse files
modules/utils/subtitle_manager.py
CHANGED
|
@@ -6,6 +6,7 @@ import re
|
|
| 6 |
import sys
|
| 7 |
import zlib
|
| 8 |
from typing import Callable, List, Optional, TextIO, Union, Dict
|
|
|
|
| 9 |
|
| 10 |
from modules.whisper.data_classes import Segment
|
| 11 |
|
|
@@ -52,10 +53,15 @@ class ResultWriter:
|
|
| 52 |
self.output_dir = output_dir
|
| 53 |
|
| 54 |
def __call__(
|
| 55 |
-
self, result: Union[dict, List[Segment]], output_file_name: str,
|
|
|
|
| 56 |
):
|
| 57 |
if isinstance(result, List) and result and isinstance(result[0], Segment):
|
| 58 |
-
result = [seg.dict() for seg in result]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
output_path = os.path.join(
|
| 61 |
self.output_dir, output_file_name + "." + self.extension
|
|
|
|
| 6 |
import sys
|
| 7 |
import zlib
|
| 8 |
from typing import Callable, List, Optional, TextIO, Union, Dict
|
| 9 |
+
from datetime import datetime
|
| 10 |
|
| 11 |
from modules.whisper.data_classes import Segment
|
| 12 |
|
|
|
|
| 53 |
self.output_dir = output_dir
|
| 54 |
|
| 55 |
def __call__(
|
| 56 |
+
self, result: Union[dict, List[Segment]], output_file_name: str, add_timestamp: bool = True,
|
| 57 |
+
options: Optional[dict] = None, **kwargs
|
| 58 |
):
|
| 59 |
if isinstance(result, List) and result and isinstance(result[0], Segment):
|
| 60 |
+
result = {"segments": [seg.dict() for seg in result]}
|
| 61 |
+
|
| 62 |
+
if add_timestamp:
|
| 63 |
+
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 64 |
+
output_file_name += timestamp
|
| 65 |
|
| 66 |
output_path = os.path.join(
|
| 67 |
self.output_dir, output_file_name + "." + self.extension
|