Example #1
0
def view(request):
    repo = repos.repo_from_request(request)
    master = repo.tree('master')
    transcription_info = repos.transcription_info(master)
    raw_snippets = {}
    for obj in master:
        if isinstance(obj, git.Blob):
            name, ext = os.path.splitext(obj.name)
            if ext == '.txt':
                try:
                    starting_point = int(name)
                except ValueError:
                    pass
                else:
                    raw_snippets[starting_point] = obj.data_stream.read().decode('utf8')
    # Go through all snippets, whether they've been transcribed or not.
    snippets = []
    speakers_map = repos.speakers_map(master)
    for starting_point in range(0, transcription_info['duration'], _snippet_ms()):
        text = raw_snippets.get(starting_point, '').strip()
        lines = _split_lines_and_expand_abbreviations(text, speakers_map)
        snippets.append((starting_point, lines))
    return dict(
        _standard_response(repo, master),
        snippets=sorted(snippets),
    )
Example #2
0
def _standard_response(repo, tree):
    transcription_info = repos.transcription_info(tree)
    return dict(
        _progress_dicts(tree, transcription_info),
        custom_css_revision=repos.custom_css_revision(repo),
        speakers=repos.speakers_text(tree),
        transcription_info=transcription_info,
        transcription_info_json=json.dumps(transcription_info),
    )
Example #3
0
def progress(request):
    repo = repos.repo_from_request(request)
    master = repo.tree('master')
    info = repos.transcription_info(master)
    return Response(body=json.dumps(_progress_dicts(master, info)), content_type='application/json')
Example #4
0
def transcription_json(request):
    repo = repos.repo_from_request(request)
    master = repo.tree('master')
    info = repos.transcription_info(master)
    return Response(body=json.dumps(info), content_type='application/json')