def assembleLyrics(streamIn, lineNumber=1):
    """
    Concatenate text from a stream. The Stream is automatically flattened.

    The `lineNumber` parameter determines which line of text is assembled.


    >>> s = stream.Stream()
    >>> n1 = note.Note()
    >>> n1.lyric = 'Hi'
    >>> n2 = note.Note()
    >>> n2.lyric = 'there'
    >>> s.append(n1)
    >>> s.append(n2)
    >>> text.assembleLyrics(s)
    'Hi there'
    """
    word = []
    words = []
    noteStream = streamIn.flat.notesAndRests
    for n in noteStream:
        try:
            lyricObj = n.lyrics[lineNumber - 1]
        except IndexError:
            continue
        if lyricObj.text != '_':
            if lyricObj.syllabic in ['begin', 'middle']:
                if lyricObj.text is not None:
                    word.append(lyricObj.text)
            elif lyricObj.syllabic in ['end', 'single', None]:
                if lyricObj.text is not None:
                    word.append(lyricObj.text)
                words.append(''.join(word))
                word = []
            else:
                raise Exception('no known Text syllabic setting: %s' %
                    lyricObj.syllabic)
    return ' '.join(words)
