If
one is afflicted with melancholy, he should cure it by listening to
songs and various kinds of melodies, by walking in gardens and fine
buildings, by sitting before beautiful forms, and by things like this
which delight the soul and make the disturbance of melancholy disappear
from it. In all this he should aim at making his body healthy, the goal
of his body’s health being that he attain knowledge.
Rambam, introduction to commentary on Mishna Avot, "Eight Chapters on Ethics", chap. 5. 298