-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
speech: add livecaption #169
Conversation
defer conn.Close() | ||
|
||
// [START speech_streaming_mic_recognize] | ||
stream, err := speech.NewSpeechClient(conn).StreamingRecognize(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err != nil { | ||
log.Fatal(err) | ||
} | ||
// send the initial configuration message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sentence casing, please (and in the two comments below)
// Send the initial configuration message.
return // nothing else to pipe, kill this goroutine | ||
} | ||
if err != nil { | ||
log.Printf("Reading stdin error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Could not read from stdin"
AudioContent: buf[:n], | ||
}, | ||
}); err != nil { | ||
log.Printf("Sending audio error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Could not send audio:"
break | ||
} | ||
if err != nil { | ||
log.Fatalf("stream.Recv error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"stream.Recv: %v"
unless there's a better way to describe what might have happened
log.Fatalf("stream.Recv error: %v", err) | ||
} | ||
if err := resp.Error; err != nil { | ||
log.Fatalf("Recieved error resp: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Could not recognize"?
…amples into livecaption
buf := make([]byte, 1024) | ||
for { | ||
n, err := os.Stdin.Read(buf) | ||
if err == io.EOF { | ||
return // nothing else to pipe, kill this goroutine | ||
return // Nothing else to pipe, returns from this goroutine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just return
, not returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
LGTM, one nit |
👍 |
No description provided.