示例#1
0
 def from_dict_letters(cls, dictletter: Dict[str, List[LetterIdx]]):
     first_index = list(dictletter.values())[0][0].r_idx
     start = make_time(ms=round(1000 * first_index / TARGET_SAMPLE_RATE))
     last_index = list(dictletter.values())[0][-1].r_idx
     end = make_time(ms=round(1000 * last_index / TARGET_SAMPLE_RATE))
     return cls(
         start,
         end,
         [(name, "".join((l.letter for l in letters)))
          for name, letters in dictletter.items()],
     )
示例#2
0
def time(s):
    d = {}
    # all = re.findall(r"(\+?|-?|^$)(\d*\.?\d*)(ms|m|s|h)", s)
    sign = s[0] if s[0] == 'e' or s[0] == '+' else ''
    for v, k in re.findall(r"(\d*\.?\d*)(ms|m|s|h)", s):
        d[k] = float(v)
    return sign, make_time(**d)
示例#3
0
 def shiftFrom(self, startTime, h=0, m=0, s=0, ms=0, frames=None, fps=None):
     """Shifts all subtitles from startTime(in ms) by the given time/fps"""
     delta = make_time(h=h, m=m, s=s, ms=ms, frames=frames, fps=fps)
     for ev in self:
         if (ev.start >= startTime):
             ev.start += delta
             ev.end += delta
示例#4
0
def create_timestamp(index):
    return make_time(ms=round(1000 * index / TARGET_SAMPLE_RATE))