File size: 668 Bytes
fabcff4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ba969e8
 
 
fabcff4
 
ba969e8
 
 
fabcff4
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
import streamlit_pianoroll
from fortepyan import MidiPiece

from datasets import load_dataset


def main():
    dataset = load_dataset("epr-labs/pijamia-midi-v1", split="train")

    record_idx = st.number_input(
        label="record id",
        min_value=0,
        max_value=len(dataset) - 1,
        value=0,
    )

    record = dataset[record_idx]
    piece = MidiPiece.from_huggingface(record)
    # TODO Improve fortepyan to make this cleaner
    piece.time_shift(-piece.df.start.min())

    streamlit_pianoroll.from_fortepyan(piece)

    st.write("#### Piece metadata")
    st.json(piece.source)


if __name__ == "__main__":
    main()