Fetching details from the dictionary...

soliloquy; monologue; speaking to oneself
独りごとが聞こえたので部屋をのぞいてみた。
I heard someone talking to themselves, so I peeked into the room.
仕事中に独りごとを言う癖が直らない。
I can't break my habit of talking to myself at work.
独りごとだと思ったら電話で話していた。
I thought he was talking to himself, but he was on the phone.