diff --git a/src/vocodes_api.rs b/src/vocodes_api.rs index 4cda4cd..442d670 100644 --- a/src/vocodes_api.rs +++ b/src/vocodes_api.rs @@ -1,14 +1,17 @@ +use anyhow::Result as AnyhowResult; +use anyhow::bail; use hyper::Body; use hyper::Client as HyperClient; use hyper::Request; use hyper_tls::HttpsConnector; +use log::{error, debug, info, warn}; const VOCODES_SPEAK_ENDPOINT : &'static str = "http://mumble.stream/speak"; -pub async fn fetch(text: &str, speaker: &str) -> Result, Box> { +pub async fn fetch(text: &str, speaker: &str) -> AnyhowResult> { let mut request = format!("{{\"speaker\": \"{}\", \"text\": \"{}\"}}", speaker, text); - println!("Req: {}", request); + debug!("Req: {}", request); let https = HttpsConnector::new(); let client = HyperClient::builder() @@ -25,12 +28,20 @@ pub async fn fetch(text: &str, speaker: &str) -> Result, Box