Whenever any person shall be taken into custody by any law enforcement officer to be held as a material witness in any criminal investigation or proceeding, he shall, if not sooner released, be taken before a judge of the district court without unnecessary delay and said judge of the district court shall immediately inform him of his constitutional rights including the reason he is being held in custody, his right to the aid of counsel in every stage of the proceedings, and of his right to be released from custody upon entering into a written undertaking in the manner provided by law. A witness who is held in custody pursuant to the provisions hereof shall be kept separately and apart from any person, or persons, being held in custody because of being accused of committing a crime. A witness who desires aid of counsel and is unable to obtain aid of counsel by reason of poverty shall be by the court provided counsel at the expense of the court fund of the county. During the time a witness is in custody he shall receive the witness fee provided by law for witnesses in criminal cases.
Okla. Stat. tit. 22, § 719