The Gemara in Masechet Berachot (24) establishes that one may not recite Shema or any Beracha in the presence of "Erva" parts of the body that are normally covered. If, for example, a person is in the presence of a woman who is immodestly dressed even his own wife he may not recite Shema or Berachot. This Halacha is codified in the Shulhan Aruch (Orah Haim 75:1-2; listen to audio recording for precise citation). The Shulhan Aruch adds that this applies even to the exposed hair of a married woman. Unmarried women customarily do not cover their hair, and it is therefore permissible to read Shema or recite Berachot in the presence of an unmarried woman whose hair is uncovered.
It occasionally happens that a Rabbi is officiating at a Hupa ceremony at a wedding, and some of the women standing under the Hupa are, unfortunately, dressed immodestly. Can the Rabbi recite the Berachot under the Hupa in this situation?
The Ben Ish Hai (Rabbi Yosef Haim of Baghdad, 1833-1909) rules that the Rabbi in such a case must turn around so that he is not facing the woman (or women) in question, and only then may he recite the Berachot. Hacham Ovadia Yosef, however, disagrees, and, based on the Shulhan Aruch, rules that it suffices for the Rabbi to close his eyes and recite the Berachot from memory. If he cannot recite the Berachot from memory, then Hacham Ovadia allows him to recite the Beracha if his eyes are directed toward the Siddur. So long as his eyes are either closed or turned away from the immodestly dressed women, he may recite the Berachot.
Hacham Ovadia Yosef extends this ruling to any situation where a person wishes to recite a Beracha or Tehilim, study Torah or pray in a place where women are present and not dressed according to the Halachic standards of Seniut (modesty). It is permissible to learn, pray or recite Berachot under such circumstances provided that one either closes his eyes or keeps his eyes turned toward the text. Thus, a person traveling on a bus, plane or train where immodestly dressed women are present may learn, recite Berachot or pray if he either closes his eyes or keeps his eyes focused on the book. Of course, if he turns around so he is not facing the women he may certainly study, pray or recite Berachot, even if he keeps his eyes open and does not read from a book.
Summary: It is forbidden to pray, recite Berachot or study Torah in the presence of a woman who is not dressed in accordance with the Halachic standards of modesty (even if she is his wife), unless he either turns the other way, closes his eyes or keeps his eyes focused on the text in front of him.