I have no intention of bustin' a gut to get hold of exact details that you will forget... but:
When a baby is developing during pregnancy the process is not as was once thought simply a little humuculous, sorry:
homunculus - a tiny fully formed individual that (according to the discredited theory of pre formation) is supposed to be present in the sperm cell
Yeah. That's wot I was trying to say...
They used to think that women had no eggs and only a womb and that people were all fully formed bits of nanotechnology squeezed into the head of each sperm and that they just used to womb - Superman in his meteor stylee - to simply get bigger - not develop.
IN FACT there are many gruesome stages of development and before some the gender of the baby is not clear.
The problem is, if it's a problem, that women - even, laugh even! pregnant women - have hormones and they are both male and female hormones and if a pregnant woman's testosterone levels get elevated etc etc said I wasn't gonna bust a gut over this - Hormonal imbalances din the mother during pregnancy can affect how male of female the baby turns out.
However, genetics is the key. I had a lad came to me with a problem. He was one of triplets and the other two were 'fashion designers' and he was straight as a rail. In this case his mother had shed his egg and also another one at the same cycle and it being either not ready to be shed or having - I don't believe it - hung around unfertilised in the womb or tubes since the previous month - it split and we got dizygotic triplets. There babies in one pregnancy from two eggs.
I digress. A lot. Often.
So although lots of things affect where the baby comes out on the male female axis the problem - as I say if it is a problem - is that the genitalia and glands get their gender set at a different time from the brain - to be honest the brain may have it's gender set by the mother's hormone levels and the body by the baby's chromosomes but terrible difficult to prove.