Depositions of witnesses may be taken by either the state or the defendant. When a party desires to take the deposition of a witness, the party shall file with the clerk of the court in which the case is pending an affidavit stating the facts necessary to constitute a good reason for taking the witness's deposition and an application to take the deposition. On the filing of the affidavit and application, and after notice to the opposing party, the court shall hear the application and determine if good reason exists for taking the deposition. The court shall base its determination and shall grant or deny the application on the facts made known at the hearing. This provision is limited to the purposes stated in Article 39.01.
Tex. Code Crim. Proc. § 39.02