def score2voice(score):
    """ Generates a sequence of voice numbers from a score.

    Args:
        score (music21.Score): the input score

    Returns:
        list[int]: a list of voice numbers corresponding to each note in the score
    """
    return [
        int(str(n.getContextByClass("Voice"))[-2])
        if not n.getContextByClass("Voice") is None
        else 1
        for n in score.flat.notes
        for p in n.pitches
    ]