It is forbidden to recite a Davar Shebikdushah or listen to someone else reciting a Brachah with the intention to fulfill your own obligation, in the presence of someone whose private parts are exposed. Therefore, one may not recite a Davar Shebikdushah when one is undressed or in the presence of someone else who is undressed, even if the undressed person is not in one’s immediate presence, but can be seen from a distance.However, unspoken thoughts, reading with one’s eyes, or listening to a recording of Torah is permitted.
The above applies to boys over the age of nine and girls over the age of three.