Microsoft said it would buy Nuance Communications, a provider of artificial-intelligence and speech-recognition software, for about…