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,
|
||||
};
|
||||
use google_authz::{Credentials, GoogleAuthz};
|
||||
use log::debug;
|
||||
use log::{debug, info};
|
||||
use tokio::io::AsyncReadExt;
|
||||
use tonic::transport::Channel;
|
||||
|
||||
|
@ -80,8 +80,29 @@ async fn main() -> eyre::Result<()> {
|
|||
.await?;
|
||||
let mut inbound = response.into_inner();
|
||||
|
||||
while let Some(msg) = inbound.message().await? {
|
||||
debug!("Got a message: {:?}", msg);
|
||||
while let Some(response) = inbound.message().await? {
|
||||
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(())
|
||||
|
|
Loading…
Reference in a new issue