At the end of the tragic tale of Túrin Turambar, as told in The Silmarillion, Túrin goes alone to the high point of Cabed-en-Aras above the river Teiglin, and there calls to his sword Gurthang.
There he drew forth his sword, that now alone remained to him of all his possessions, and he said, 'Hail Gurthang! No lord or loyalty dost thou know, save the hand that weildeth thee. From no blood wilt thou shrink. Wilt thou therefore take Túrin Turambar, wilt thou slay me swiftly?'
And from the blade rang a cold voice in answer: 'Yea, I will drink thy blood gladly, that so I may forget the blood of Beleg my master, and of Brandir slain unjustly. I will slay thee swiftly.'
Then Túrin set the hilts upon the ground, and cast himself upon the point of Gurthang, and the black blade took his life.
Then they lifted up Túrin, and found that Gurthang had broken asunder.
Nowhere else in the legendarium, as far as I know, does a sword speak, nor is any explanation offered for how Gurthang did so.