"Soliloquy" is a fancy word for "talking to yourself".
It's usually used to mean a place in a movie or a play where
one of the characters is talking to himself, so that you get to
know what's on his mind without having other characters
around.
Hamlet's famous speech "To be or not to be, that is the question.",
and all the rest of it, is a soliloquy. He's struggling with himself,
trying to decide whether to kill his stepfather the king or not, and
we get to hear the agony he's going through, as different thoughts
on his mind pull him both ways.