This is a Machloket Tannaim between Rabbi Yose bar Chalafta and the Sages. Rabbi Yose says the witnesses need to also be the ones who give warning (that is the passage you quote), while the Sages say that it is unnecessary.
As Rava says in the Gemara (same page) "Even the victim , or even a demon (i.e. a voice which no one knows the source of) can give warning." So it is clear that according to the Sages, there are no requirements on the identity of the entity giving the warning.
The only requirements are on the warning itself:
That the accused was told that his/her action was forbidden by the Torah and which prohibition forbade it.
That the accused was told what what the punishment for that action was (Rabbi Yehuda requires the kind of capital punishment to be stated as well, not just that it is chayav mitah).
That the accused accepted the warning explicitly (accepting that the action they were taking violated that particular prohibition, and that they could be punished for it in the specific way mentioned).
That the accused immediately did the forbidden act after accepting the warning.