{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/comments/88561085","pull_request_review_id":9132281,"id":88561085,"diff_hunk":"@@ -0,0 +1,93 @@\n+// Copyright 2016 Google Inc. All rights reserved.\n+// Use of this source code is governed by the Apache 2.0\n+// license that can be found in the LICENSE file.\n+\n+// Command livecaption pipes the stdin audio data to\n+// Google Speech API and outputs the transcript.\n+//\n+// As an example, gst-launch can be used to capture the mic input:\n+//\n+//    $ gst-launch-1.0 -v pulsesrc ! audioconvert ! audioresample ! audio/x-raw,channels=1,rate=16000 ! filesink location=/dev/stdout | livecaption\n+package main\n+\n+import (\n+\t\"fmt\"\n+\t\"io\"\n+\t\"log\"\n+\t\"os\"\n+\n+\t\"golang.org/x/net/context\"\n+\t\"google.golang.org/api/option\"\n+\t\"google.golang.org/api/transport\"\n+\tspeech \"google.golang.org/genproto/googleapis/cloud/speech/v1beta1\"\n+)\n+\n+func main() {\n+\tctx := context.Background()\n+\tconn, err := transport.DialGRPC(ctx,\n+\t\toption.WithEndpoint(\"speech.googleapis.com:443\"),\n+\t\toption.WithScopes(\"https://www.googleapis.com/auth/cloud-platform\"),\n+\t)\n+\tif err != nil {\n+\t\tlog.Fatal(err)\n+\t}\n+\tdefer conn.Close()\n+\n+\t// [START speech_streaming_mic_recognize]\n+\tstream, err := speech.NewSpeechClient(conn).StreamingRecognize(ctx)\n+\tif err != nil {\n+\t\tlog.Fatal(err)\n+\t}\n+\t// send the initial configuration message.\n+\tif err := stream.Send(&speech.StreamingRecognizeRequest{\n+\t\tStreamingRequest: &speech.StreamingRecognizeRequest_StreamingConfig{\n+\t\t\tStreamingConfig: &speech.StreamingRecognitionConfig{\n+\t\t\t\tConfig: &speech.RecognitionConfig{\n+\t\t\t\t\tEncoding:   speech.RecognitionConfig_LINEAR16,\n+\t\t\t\t\tSampleRate: 16000,\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\t}); err != nil {\n+\t\tlog.Fatal(err)\n+\t}\n+\n+\tgo func() {\n+\t\t// pipe stdin to the API\n+\t\tbuf := make([]byte, 1024)\n+\t\tfor {\n+\t\t\tn, err := os.Stdin.Read(buf)\n+\t\t\tif err == io.EOF {\n+\t\t\t\treturn // nothing else to pipe, kill this goroutine\n+\t\t\t}\n+\t\t\tif err != nil {\n+\t\t\t\tlog.Printf(\"Reading stdin error: %v\", err)\n+\t\t\t\tcontinue\n+\t\t\t}\n+\t\t\tif err = stream.Send(&speech.StreamingRecognizeRequest{\n+\t\t\t\tStreamingRequest: &speech.StreamingRecognizeRequest_AudioContent{\n+\t\t\t\t\tAudioContent: buf[:n],\n+\t\t\t\t},\n+\t\t\t}); err != nil {\n+\t\t\t\tlog.Printf(\"Sending audio error: %v\", err)","path":"speech/livecaption/livecaption.go","position":72,"original_position":72,"commit_id":"e06dda4d3d40b0c3b2ca70a833833cc5f3702868","original_commit_id":"e06dda4d3d40b0c3b2ca70a833833cc5f3702868","user":{"login":"broady","id":24982,"avatar_url":"https://avatars.githubusercontent.com/u/24982?v=3","gravatar_id":"","url":"https://api.github.com/users/broady","html_url":"https://github.com/broady","followers_url":"https://api.github.com/users/broady/followers","following_url":"https://api.github.com/users/broady/following{/other_user}","gists_url":"https://api.github.com/users/broady/gists{/gist_id}","starred_url":"https://api.github.com/users/broady/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broady/subscriptions","organizations_url":"https://api.github.com/users/broady/orgs","repos_url":"https://api.github.com/users/broady/repos","events_url":"https://api.github.com/users/broady/events{/privacy}","received_events_url":"https://api.github.com/users/broady/received_events","type":"User","site_admin":false},"body":"\"Could not send audio:\"","created_at":"2016-11-17T22:24:56Z","updated_at":"2016-11-17T22:25:52Z","html_url":"https://github.com/GoogleCloudPlatform/golang-samples/pull/169#discussion_r88561085","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/comments/88561085"},"html":{"href":"https://github.com/GoogleCloudPlatform/golang-samples/pull/169#discussion_r88561085"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169","id":94263025,"html_url":"https://github.com/GoogleCloudPlatform/golang-samples/pull/169","diff_url":"https://github.com/GoogleCloudPlatform/golang-samples/pull/169.diff","patch_url":"https://github.com/GoogleCloudPlatform/golang-samples/pull/169.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/169","number":169,"state":"open","locked":false,"title":"speech: add livecaption","user":{"login":"rakyll","id":108380,"avatar_url":"https://avatars.githubusercontent.com/u/108380?v=3","gravatar_id":"","url":"https://api.github.com/users/rakyll","html_url":"https://github.com/rakyll","followers_url":"https://api.github.com/users/rakyll/followers","following_url":"https://api.github.com/users/rakyll/following{/other_user}","gists_url":"https://api.github.com/users/rakyll/gists{/gist_id}","starred_url":"https://api.github.com/users/rakyll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rakyll/subscriptions","organizations_url":"https://api.github.com/users/rakyll/orgs","repos_url":"https://api.github.com/users/rakyll/repos","events_url":"https://api.github.com/users/rakyll/events{/privacy}","received_events_url":"https://api.github.com/users/rakyll/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-17T22:18:48Z","updated_at":"2016-11-17T22:25:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c0b950994274c84fb64de23bfee15947f8ebe10","assignee":{"login":"broady","id":24982,"avatar_url":"https://avatars.githubusercontent.com/u/24982?v=3","gravatar_id":"","url":"https://api.github.com/users/broady","html_url":"https://github.com/broady","followers_url":"https://api.github.com/users/broady/followers","following_url":"https://api.github.com/users/broady/following{/other_user}","gists_url":"https://api.github.com/users/broady/gists{/gist_id}","starred_url":"https://api.github.com/users/broady/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broady/subscriptions","organizations_url":"https://api.github.com/users/broady/orgs","repos_url":"https://api.github.com/users/broady/repos","events_url":"https://api.github.com/users/broady/events{/privacy}","received_events_url":"https://api.github.com/users/broady/received_events","type":"User","site_admin":false},"assignees":[{"login":"broady","id":24982,"avatar_url":"https://avatars.githubusercontent.com/u/24982?v=3","gravatar_id":"","url":"https://api.github.com/users/broady","html_url":"https://github.com/broady","followers_url":"https://api.github.com/users/broady/followers","following_url":"https://api.github.com/users/broady/following{/other_user}","gists_url":"https://api.github.com/users/broady/gists{/gist_id}","starred_url":"https://api.github.com/users/broady/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broady/subscriptions","organizations_url":"https://api.github.com/users/broady/orgs","repos_url":"https://api.github.com/users/broady/repos","events_url":"https://api.github.com/users/broady/events{/privacy}","received_events_url":"https://api.github.com/users/broady/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/169/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/statuses/e06dda4d3d40b0c3b2ca70a833833cc5f3702868","head":{"label":"GoogleCloudPlatform:livecaption","ref":"livecaption","sha":"e06dda4d3d40b0c3b2ca70a833833cc5f3702868","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":43332504,"name":"golang-samples","full_name":"GoogleCloudPlatform/golang-samples","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/golang-samples","description":"Sample apps and code written in the Go programming language.","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/deployments","created_at":"2015-09-28T23:20:08Z","updated_at":"2016-11-12T00:18:20Z","pushed_at":"2016-11-17T22:20:55Z","git_url":"git://github.com/GoogleCloudPlatform/golang-samples.git","ssh_url":"git@github.com:GoogleCloudPlatform/golang-samples.git","clone_url":"https://github.com/GoogleCloudPlatform/golang-samples.git","svn_url":"https://github.com/GoogleCloudPlatform/golang-samples","homepage":null,"size":806,"stargazers_count":140,"watchers_count":140,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":51,"mirror_url":null,"open_issues_count":20,"forks":51,"open_issues":20,"watchers":140,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"6b441dbf6368af16f7649581ef40b985919b09d4","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":43332504,"name":"golang-samples","full_name":"GoogleCloudPlatform/golang-samples","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/golang-samples","description":"Sample apps and code written in the Go programming language.","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/deployments","created_at":"2015-09-28T23:20:08Z","updated_at":"2016-11-12T00:18:20Z","pushed_at":"2016-11-17T22:20:55Z","git_url":"git://github.com/GoogleCloudPlatform/golang-samples.git","ssh_url":"git@github.com:GoogleCloudPlatform/golang-samples.git","clone_url":"https://github.com/GoogleCloudPlatform/golang-samples.git","svn_url":"https://github.com/GoogleCloudPlatform/golang-samples","homepage":null,"size":806,"stargazers_count":140,"watchers_count":140,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":51,"mirror_url":null,"open_issues_count":20,"forks":51,"open_issues":20,"watchers":140,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169"},"html":{"href":"https://github.com/GoogleCloudPlatform/golang-samples/pull/169"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/169"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/issues/169/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/pulls/169/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/golang-samples/statuses/e06dda4d3d40b0c3b2ca70a833833cc5f3702868"}}}}
{"actor":{"display_login":"broady"}}