Spaces:
Sleeping
Sleeping
Update utilities/transcripts.py
Browse files- utilities/transcripts.py +18 -1
utilities/transcripts.py
CHANGED
@@ -114,7 +114,7 @@ class VTTTranscriptLoader:
|
|
114 |
|
115 |
return self.manual_document(output, metadata)
|
116 |
|
117 |
-
def
|
118 |
"""Processes all VTT files in the directory or the single file and returns a list of results."""
|
119 |
results = []
|
120 |
if os.path.isdir(self.fp):
|
@@ -129,6 +129,23 @@ class VTTTranscriptLoader:
|
|
129 |
results.append(transcript)
|
130 |
return results
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
class DocumentEmbedder:
|
134 |
"""
|
|
|
114 |
|
115 |
return self.manual_document(output, metadata)
|
116 |
|
117 |
+
def directory_load(self):
|
118 |
"""Processes all VTT files in the directory or the single file and returns a list of results."""
|
119 |
results = []
|
120 |
if os.path.isdir(self.fp):
|
|
|
129 |
results.append(transcript)
|
130 |
return results
|
131 |
|
132 |
+
def load(self):
|
133 |
+
"""Processes all VTT files in the given list of directories or files and returns a list of results."""
|
134 |
+
results = []
|
135 |
+
for path in self.fp:
|
136 |
+
if os.path.isdir(path):
|
137 |
+
for root, _, files in os.walk(path):
|
138 |
+
for file in files:
|
139 |
+
if file.endswith('.vtt'):
|
140 |
+
file_path = os.path.join(root, file)
|
141 |
+
transcript = self.process_file(file_path)
|
142 |
+
results.append(transcript)
|
143 |
+
else:
|
144 |
+
if path.endswith('.vtt'):
|
145 |
+
transcript = self.process_file(path)
|
146 |
+
results.append(transcript)
|
147 |
+
return results
|
148 |
+
|
149 |
|
150 |
class DocumentEmbedder:
|
151 |
"""
|