I had experienced the same too when baby was of that age. She cried randomly when sleeping (whether at night or during afternoon naps).
And most of those times I was able to calm her by bringing her into my arms and swing her for few minutes until she stops crying. I also check if her tummy looks gassy so I put some oil on it and on her feet as well then eventually she stops crying afterwards.
Read more