Help us understand the problem. What is going on with this article?

[Tips] TFRecordsのNoteSequenceの中身を確認する方法

備忘録も兼ねてTipsを共有します。掲題の通り、Tensorflowで楽曲データを取り扱うときのデータ形式である NoteSequence の中身を目視で確認する方法です。

動作環境

  • magentaがインストール済。
    • tensorflow/tensorflow:latest-devel のDocker内で pip install magenta を実行した状態。
  • Python 2.7
    • Cloud DataflowをPythonから使うために2系にする必要があったので...。

コード

from magenta.music import note_sequence_io


tfrecord_path = '/path/to/note_sequence.tfrecord'
for sequence in note_sequence_io.note_sequence_record_iterator(tfrecord_path):
    print sequence.id
    print sequence.collection_name
    print sequence.filename
    print sequence.notes

出力結果

以下のような出力が得られます。 私は 楽器Noって含まれてるんだっけ? 等の確認がしたくて見た感じです。

/id/midi/dir_name/xxxxxxxxxxxxxxxxxxxxxxx
dir_name
xxxxxxx.mid
[pitch: 75
velocity: 94
start_time: 74.5522065
end_time: 74.608176625
program: 12
, pitch: 87
velocity: 86
start_time: 29.552226
end_time: 29.88804675
instrument: 1
, pitch: 89
velocity: 93
start_time: 29.999987
end_time: 30.33580775
instrument: 1
, pitch: 91
...
]

midi -> NoteSequence化

magentaリポジトリのコンバートスクリプトで簡単にできます。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away