Skip to content

Commit

Permalink
Add: Azure speech cognitive service - batch create transcription, get…
Browse files Browse the repository at this point in the history
… status, get result (v3.1)
  • Loading branch information
zhongdongy committed Mar 27, 2023
1 parent e588706 commit 978b0e1
Show file tree
Hide file tree
Showing 12 changed files with 1,204 additions and 123 deletions.
32 changes: 31 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion examples/azure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ log4rs = "1.2.0"

[[bin]]
name = "azure-text-to-speech"
path = "src/text-to-speech.rs"
path = "src/text-to-speech.rs"

[[bin]]
name = "azure-batch-create-transcription"
path = "src/batch-create-transcription.rs"
31 changes: 31 additions & 0 deletions examples/azure/src/batch-create-transcription.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use std::{error::Error, time::Duration};

use rust_ai::azure::{
types::speech::transcription::{Status, Transcription},
SpeechModel,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
std::env::set_var("RUST_LOG", "debug");
std::env::set_var("RUST_BACKTRACE", "1");
log4rs::init_file("log4rs.yml", Default::default()).unwrap();

let mut trans = Transcription::default();
trans.display_name = "Test".into();
trans.content_urls = Some(vec![String::from(
"https://crbn.us/whatstheweatherlike.wav",
)]);
let trans = SpeechModel::default()
.transcription(trans)
.create_transcription()
.await?;

std::thread::sleep(Duration::from_secs(5));
let trans = trans.status().await?;
if let Some(Status::Succeeded) = trans.status {
let results = trans.results().await?;
println!("{:?}", results.values);
}

Ok(())
}
1 change: 1 addition & 0 deletions rust-ai/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ serde_with = "2.3.1"
isolang = { version = "2.2.0", features = ["serde"] }
lazy_static = "1.4.0"
urlencoding = "2.1.2"
regex = "1.7.3"
Loading

0 comments on commit 978b0e1

Please sign in to comment.