Use final
This commit is contained in:
parent
2ae0fc21f9
commit
393661f197
1 changed files with 24 additions and 21 deletions
11
src/main.rs
11
src/main.rs
|
@ -18,7 +18,7 @@ async fn main() -> eyre::Result<()> {
|
|||
|
||||
debug!("starting...");
|
||||
|
||||
let channel = Channel::from_static("https://speech.googleapis.com")
|
||||
let speech_api_channel = Channel::from_static("https://speech.googleapis.com")
|
||||
.connect()
|
||||
.await?;
|
||||
|
||||
|
@ -26,14 +26,14 @@ async fn main() -> eyre::Result<()> {
|
|||
.json_file("i-centralvideo-dictate-dev-c184dd68967a.json".as_ref())
|
||||
.build()
|
||||
.await?;
|
||||
let channel = GoogleAuthz::builder(channel)
|
||||
let auth_channel = GoogleAuthz::builder(speech_api_channel)
|
||||
.credentials(credentials)
|
||||
.build()
|
||||
.await;
|
||||
|
||||
debug!("authenticated channel created!");
|
||||
|
||||
let mut client = SpeechClient::new(channel);
|
||||
let mut client = SpeechClient::new(auth_channel);
|
||||
|
||||
|
||||
let (sender, receiver) = tokio::sync::mpsc::unbounded_channel();
|
||||
|
@ -71,7 +71,7 @@ async fn main() -> eyre::Result<()> {
|
|||
BytesMut::from(&buffer.as_slice()[..n]).freeze(),
|
||||
)),
|
||||
};
|
||||
sender.send(request).unwrap();
|
||||
let result = sender.send(request);
|
||||
//debug!("added a buffer to the sender queue: {} bytes", n);
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
}
|
||||
|
@ -85,8 +85,10 @@ async fn main() -> eyre::Result<()> {
|
|||
while let Some(response) = inbound.message().instrument(tracing::info_span!("transcription-results")).await? {
|
||||
let mut num_results = 0;
|
||||
for res in &response.results {
|
||||
if res.is_final {
|
||||
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 {
|
||||
|
@ -106,6 +108,7 @@ async fn main() -> eyre::Result<()> {
|
|||
info!("}}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue