Our Gemara on Amud Beis contrasts two situations where a pregnant woman became endangered due to cravings on Yom Kippur.  Because of the severity of Yom Kippur, the rabbis attempted to calm the fetus, whom they believed was the source of the cravings.  They said to the woman, “Today is Yom Kippur”, hoping the fetus will be reminded of how important a day it was, and restore itself without eating.  In the case where the fetus relented and the cravings disappeared, the rabbis noted that this child grew up to become the great Rabbi Yochanan.

Which leads us to a question about what fetuses are capable of thinking and knowing while in utero. In truth, I was not expecting to find any research on this because there is a tremendous disincentive by our culture that advocates abortion to notice or care about whether a fetus could think or feel. However, I was surprised to find a convincing study that shows that fetuses can recognize songs and words heard while in utero, and this can be reliably measured after birth. 

According to research done by Eino Partanen of the University of Helsinki, newborns already familiarized themselves with sounds of their parent’s native language; the research showed that American newborns seem to perceive Swedish vowel sounds as unfamiliar, sucking on a high-tech pacifier to hear more of the new sounds. Swedish infants showed the same response to English vowels. Partanen and his team also outfitted babies with EEG sensors to look for neural traces of memories from the womb, so as to not merely prove that some behavior was being reinforced, but it actually represented the parts of the brain that were in charge of language recognition and speech. The results were conclusive, 

See this fascinating study:

https://www.sciencemag.org/news/2013/08/babies-learn-recognize-words-womb