def compose_from_transcript(files, search, searchtype):
    """Takes transcripts created by audiogrep/pocketsphinx, a search and search type
    and returns a list of timestamps for creating a supercut"""

    final_segments = []

    if searchtype in ['re', 'word', 'franken', 'fragment']:
        if searchtype == 're':
            searchtype = 'sentence'

        segments = audiogrep.search(search, files, mode=searchtype, regex=True)
        for seg in segments:
            seg['file'] = seg['file'].replace('.transcription.txt', '')
            seg['line'] = seg['words']
            final_segments.append(seg)

    elif searchtype in ['hyper', 'pos']:
        for s in audiogrep.convert_timestamps(files):
            for w in s['words']:
                if search_line(w[0], search, searchtype):
                    seg = {
                        'file': s['file'].replace('.transcription.txt',''),
                        'line': w[0],
                        'start': float(w[1]),
                        'end': float(w[2])
                    }
                    final_segments.append(seg)

    return final_segments
def compose_from_transcript ( files , search , searchtype ) : final_segments = [ ] if searchtype in [ 're' , 'word' , 'franken' , 'fragment' ] : if searchtype == 're' : searchtype = 'sentence' segments = audiogrep . search ( search , files , mode = searchtype , regex = True ) for seg in segments : seg [ 'file' ] = seg [ 'file' ] . replace ( '.transcription.txt' , '' ) seg [ 'line' ] = seg [ 'words' ] final_segments . append ( seg ) elif searchtype in [ 'hyper' , 'pos' ] : for s in audiogrep . convert_timestamps ( files ) : for w in s [ 'words' ] : if search_line ( w [ 0 ] , search , searchtype ) : seg = { 'file' : s [ 'file' ] . replace ( '.transcription.txt' , '' ) , 'line' : w [ 0 ] , 'start' : float ( w [ 1 ] ) , 'end' : float ( w [ 2 ] ) } final_segments . append ( seg ) return final_segments
Takes transcripts created by audiogrep/pocketsphinx, a search and search type
    and returns a list of timestamps for creating a supercut