This is a kind of personification. For those who don’t know, personification means breathing life into an object in literature. That’s what they learn in high school.
You learn many things from books, but not everything. Books can keep you awake, talking, when you need to be awake. For example, an adventurous book, where you turn page after page, to see what happened next.
Similarly, books can put you to sleep, for example a beautiful story with fairies and princesses…