Skip to content

Commit eee53aa

Browse files
committed
Add MIDI evaluation wrapper in example self actuated piano script.
1 parent 6aa2c51 commit eee53aa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/self_actuated_piano_env.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from robopianist import music, viewer
2525
from robopianist.suite.tasks import self_actuated_piano
26-
from robopianist.wrappers import PianoSoundVideoWrapper
26+
from robopianist.wrappers import MidiEvaluationWrapper, PianoSoundVideoWrapper
2727

2828
_FILE = flags.DEFINE_string("file", "TwinkleTwinkleRousseau", "")
2929
_RECORD = flags.DEFINE_bool("record", False, "")
@@ -54,6 +54,7 @@ def main(_) -> None:
5454
env = composer_utils.Environment(
5555
recompile_physics=False, task=task, strip_singleton_obs_buffer_dim=True
5656
)
57+
env = MidiEvaluationWrapper(env)
5758
if _RECORD.value:
5859
env = PianoSoundVideoWrapper(
5960
env,
@@ -104,6 +105,9 @@ def __call__(self, timestep: dm_env.TimeStep) -> np.ndarray:
104105
action = policy(timestep)
105106
timestep = env.step(action)
106107

108+
for k, v in env.get_musical_metrics().items():
109+
np.testing.assert_equal(v, 1.0)
110+
107111

108112
if __name__ == "__main__":
109113
app.run(main)

0 commit comments

Comments
 (0)