The short answer is probably not, but that it almost certainly had elements of Socrates’ speech (I’m going to assume that Socrates did actually exist; we have sources that directly mention him from Plato to Xenophon, to Aristotle to Aristophanes, and fragmentary sources)
First and foremost, we have another account of Socrates’ purported speech in Xenophon’s Apology, which is fairly similar, but has notable differences (the biggest one that comes to my mind is the difference in what the Oracle says about Socrates: in Plato, it says, “He [Chaerephon] asked whether there was anyone wiser than I. Now the Pythia replied that there was no one wiser” Plat. Apol. 21a. Xenophon says, “no one among men was more free, more just, or more prudent than I.” Xen. Apol. 14). This speech is similarly unlikely to be what Socrates actually said.
Secondly, it’s generally assumed that these Apologies were written as a reputation reclamation for Socrates many years after his death. Both were probably published between 393 (when another contemporary, Polycrates, produced the “Accusation of Socrates”) and the middle 380s, while the trial of Socrates took place in 399. Both were friends of the philosopher and it seems to be a response to potentially renewed criticism by people like Polycrates. Thus, modern scholars generally assume that they’re not technically accurate, but both portray different aspects depending on what the author wanted to claim about Socrates. A good source for this is G. Danzig “Apologizing for Socrates: Plato and Xenophon on Socrates’ behavior in Court” from the Transactions of the APA 133 (2003) (Sorry I don’t have a good link for this). He says, “Plato’s aim in the Apology was primarily to respond to specific charges of incompetence, arrogance, and failure in court.” Plato adapted the speech from the original to paint a picture of Socrates that responded to the contemporary criticism of the man. So the speech is not what Socrates actually spoke.
That being said, Plato was probably at the trial (as opposed to Xenophon, who was not; his source is a mutual friend, Hermogenes). Socrates calls Plato out in Plato’s version of the speech with language that implies that Plato witnessed the event. Also, high-profile trials like Socrates’ would have been attended by large numbers of the Athenian elite, so Plato couldn’t deviate too much from what Socrates actually said because members of his intended audience had witnessed the trial in person.
So ultimately, the speech is not the same as what Socrates said, written at least six years later and with a motive in mind, but it’s not a totally different speech.
A great starting point on this topic is the Oxford Bibliography page: http://www.oxfordbibliographies.com/view/document/obo-9780195389661/obo-9780195389661-0165.xml