here's part of sample in caption_file
[{'text': 'okay Wow', 'start': 0.03, 'duration': 6.499}, {'text': '[Music]', 'start': 8.3, 'duration': 5.919}]
i have a bunch of samples in CAPTIONS_DIR and i want to gather some item into another dictionary
import os
from .step import Step
from yt_concate.setting import CAPTIONS_DIR
class ReadCaption(Step):
def process(self, data, inputs, utils):
for caption_file in os.listdir(CAPTIONS_DIR):
with open(os.path.join(CAPTIONS_DIR, caption_file), "r") as f:
captions = {}
for line in f:
caption = line["text"]
time = str(line["start"]) + "-->" + str(line["start"])
captions[caption] = time
print(captions)
the result and where i've been trapped
caption = line["text"]
TypeError: string indices must be integers
but if i enter a integer 0 it'll come up "["
for line in f:
print(line[0])