Show results formatted
This commit is contained in:
parent
7262352247
commit
46e602ba36
1 changed files with 24 additions and 3 deletions
27
src/main.rs
27
src/main.rs
|
@ -5,7 +5,7 @@ use google_api_proto::google::cloud::speech::v1::{
|
||||||
StreamingRecognitionConfig, StreamingRecognizeRequest,
|
StreamingRecognitionConfig, StreamingRecognizeRequest,
|
||||||
};
|
};
|
||||||
use google_authz::{Credentials, GoogleAuthz};
|
use google_authz::{Credentials, GoogleAuthz};
|
||||||
use log::debug;
|
use log::{debug, info};
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tonic::transport::Channel;
|
use tonic::transport::Channel;
|
||||||
|
|
||||||
|
@ -80,8 +80,29 @@ async fn main() -> eyre::Result<()> {
|
||||||
.await?;
|
.await?;
|
||||||
let mut inbound = response.into_inner();
|
let mut inbound = response.into_inner();
|
||||||
|
|
||||||
while let Some(msg) = inbound.message().await? {
|
while let Some(response) = inbound.message().await? {
|
||||||
debug!("Got a message: {:?}", msg);
|
let mut num_results = 0;
|
||||||
|
for res in &response.results {
|
||||||
|
num_results = num_results + 1;
|
||||||
|
info!("Result {} {{", num_results);
|
||||||
|
if let Some(rec) = res.alternatives.first() {
|
||||||
|
info!("\tTranscription: {}", rec.transcript);
|
||||||
|
for word_info in &rec.words {
|
||||||
|
// let start_time: WordTimestamp = word_info.start_time.into();
|
||||||
|
let start_time = word_info.start_time.as_ref().unwrap();
|
||||||
|
let end_time = word_info.end_time.as_ref().unwrap();
|
||||||
|
info!(
|
||||||
|
"\t - {}: [{}.{} - {}.{}]",
|
||||||
|
word_info.word,
|
||||||
|
start_time.seconds,
|
||||||
|
start_time.nanos,
|
||||||
|
end_time.seconds,
|
||||||
|
end_time.nanos
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info!("}}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue