That talking in your sleep is called somniloquy? It can be brought on by stress, depression, fever and alcohol. It can occur during any stage of sleep.
I’ve woken myself up several times by talking in my sleep and have been known to hold conversations. Unfortunately, I also sometimes sing in my sleep.