Fetching details from the dictionary...

soliloquy; monologue; speaking to oneself
彼は一人ごとをつぶやく癖がある。
He has a habit of muttering to himself.
電車の中で一人ごとを言っている人がいた。
There was someone talking to themselves on the train.
考え事をしていると一人ごとが出てしまう。
When I am deep in thought, I end up talking to myself.