Giter Club home page Giter Club logo

cpp-samples's Introduction

C++ Samples

A small collection of samples that demonstrate how to call Google Cloud services from C++.

style cloud build

The samples in this repo cover only a small fraction of the total APIs that you can call from C++. See the googleapis repo to see the full list of APIs callable from C++.

These samples will only build and run on Linux.

There is a growing collection of C++ client libraries for Google Cloud services. These include Cloud Bigtable, Cloud Pub/Sub, Cloud Spanner, and Google Cloud Storage. These libraries include examples of how to use most functions. The examples in this repository typically involve using a combination of services, or a more specific use-case.

Contributing changes

Licensing

cpp-samples's People

Contributors

alevenberg avatar averikitsch avatar cjcox17 avatar coryan avatar dbolduc avatar dependabot[bot] avatar devbww avatar frankyn avatar gbanis avatar gguuss avatar google-cloud-policy-bot[bot] avatar grayside avatar joeholley avatar ltouati avatar mbrukman avatar minherz avatar noerog avatar renovate-bot avatar renovate[bot] avatar surferjeffatgoogle avatar wangbill-google avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpp-samples's Issues

Complete the Getting Started example

This is a tracking bug, probably needs some breakdown.

  • Need to write some queries to show case the index
  • Add caching to the buildpack builds
  • Add a CI build using buildpacks
  • Consider adding more fields to the Cloud Spanner Table

make run_tests error - undefined reference to 'AssignDescriptors'

Hi, I am trying to run the tests as given in the documentation here.
On step 9 it is given make run_tests I am getting some linking problem.

g++ transcribe.o parse_arguments.o googleapis.ar -L/usr/local/lib 'pkg-config --libs grpc++ grpc' -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -lprotobuf -lpthread -ldl -o transcribe
/usr/local/lib/libgrpc++_reflection.so: undefined reference to 'google::protobuf::internal::AssignDescriptors(google::protobuf::internal::AssignDescriptorsTable*)'
/usr/local/lib/libgrpc++_reflection.so: undefined reference to 'google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable*, void (* const*)(), int)'
collect2: error: ld returned 1 exit status

Can anyone please help me understand this?

error while Generate googleapis gRPC source code

protoc --proto_path=.:/usr/local/include --cpp_out=./gens --grpc_out=./gens --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin google/maps/routes/v1/route_service.proto
[libprotobuf FATAL /home/maybe/grpc/third_party/protobuf/src/google/protobuf/io/printer.cc:142] Unclosed variable name.
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): Unclosed variable name.
--grpc_out: protoc-gen-grpc: Plugin killed by signal 6.
Makefile:44: recipe for target 'google/maps/routes/v1/route_service.pb.cc' failed

grpc version: v1.27.3
protoc version: 3.11.2
ubuntu: 18.04

Error while making file

Hi there, I tried to use make run_tests under cpp-docs-samples/speech/api

but after a while this error shows up.
collect2: error: ld returned 1 exit status Makefile:56: recipe for target 'transcribe' failed make: *** [transcribe] Error 1
Line 56 in Makefile is
55 transcribe: transcribe.o parse_arguments.o googleapis.ar 56 $(CXX) $^ $(LDFLAGS) -o $@
I wish to know whats going on, Thanks!!

C++ catching/finding connection and stream errors & continuous/infinite speech recognition

Hi,

I'm building an example (c++ based) in which I've a GRPC server which receives continuous audio 100 milli second chunks/bytes (using GRPC bidirectional streaming) from client (real time audio speaking from mic). My server code sends the audio to Google cloud speech to get text from speech. I'm using this example streaming_transcribe.cc. I've three questions:

  1. How do I handle errors like: when I can not connect to google speech or can not create a channel due to network connectivity issues or server is down, how to catch such exceptions ? Also the stream errors out in the middle of streaming audio (google closes streaming due to time exceeds or long pauses), where and how can I handle such errors.

  2. Client can keep sending audio for long duration ( may be like 1 hour). When the google speech stream is open for more than 5 mins, I'm getting the following error Exceeded maximum allowed stream duration of 305 seconds. The streamingrecognize requests have a limitation of 5 mins it seems as mentioned here. The same page mentions a few examples about endless streaming tutorials with some code in java and python. If I can get an example of how to implement this in c++ in https://github.com/GoogleCloudPlatform/cpp-samples/blob/master/speech/api/streaming_transcribe.cc, that would be very helpful, at least a peudo code.
    The examples mentioned in endless streaming tutorials closes current stream and reconnects new stream after about 290 seconds. But in the streaming_transcribe.cc, the stream is passed to a thread for writing audio bytes to the stream and the main thread reads responses from stream. How to close and create a new stream in the MicrophoneThreadMain (https://github.com/GoogleCloudPlatform/cpp-samples/blob/master/speech/api/streaming_transcribe.cc#L36) function ?
    A similar thread has been posted here but It was not that helpful for me.

  3. How do we implement backoff and reconnect to Google stream (speech server) in case of errors (https://cloud.google.com/speech-to-text/sla). If I know how to catch or find the connection has errors (asked in [1], then we can implement this but it would be great to provide an example.

Any help is much appreciated , Thank you very much.

Async_transcribe test fails due to in-progress write

[Issue]
Running make run_tests fails when running asynchronous transcribe on audio.raw. The error message is shown below with steps to reproduce.

[Error]

./async_transcribe -b 16000 resources/audio.raw
Waiting for operation 685671640417183807 to complete...Delayed close due to in-progress write
make: *** [run_tests] Error 255

[Steps to reproduce]

  1. Copy this into a Dockerfile (https://gist.github.com/frankyn/07e01336391affc06929cb0e58a9fdb5)
  2. Create a service account file and name is service-account.json where the Dockerfile is located.
  3. Run docker build -t cpp-speech . where the Dockerfile is located.
  4. Start bash docker run -it cpp-speech bash
  5. In bash run cd /home/cpp-docs-samples/speech/api/
  6. Run make run_tests

Error building grpc source code

I'm getting the following error when building grpc C++ source code from https://github.com/googleapis/googleapis using protoc 3.14.0 and grpc 1.35.0 on Ubuntu 20.10 (WSL). Same issue as #98.

protoc --proto_path=.:/usr/local/include --cpp_out=./gens --grpc_out=./gens --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin google/maps/routes/v1/route_service.proto [libprotobuf FATAL /home/xxxx/xxxxx/grpc/third_party/protobuf/src/google/protobuf/io/printer.cc:142] Unclosed variable name. terminate called after throwing an instance of 'google::protobuf::FatalException' what(): Unclosed variable name. --grpc_out: protoc-gen-grpc: Plugin killed by signal 6. make: *** [Makefile:45: google/maps/routes/v1/route_service.pb.cc] Error 1

Speech Api on Windows

I would like to use the Cloud Speech Api in a Windows c++ application. I've followed the speech api build steps as guidance. How do I generate the googleapis gRPC source code on windows?

Error when make run_tests on ubuntu14

Hi,
I am working on ubuntu 14.04.

I've compiled the latest grpc(with libc-ares-dev (1.13.0)) and protobuf.

but when make run_tests:

ar: creating googleapis.ar
g++ transcribe.o parse_arguments.o googleapis.ar -L/usr/local/lib pkg-config --libs grpc++ grpc -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -lprotobuf -lpthread -ldl -o transcribe
/usr/local/lib/libgrpc.so: undefined reference to `ares_set_servers_ports'
collect2: error: ld returned 1 exit status
make: *** [transcribe] Error 1

Seems like I've picked the wrong version for the c-ares, so how can I fix the error? Thanks.

Besides, the libc-ares-dev (1.11.0) will fail the make of grpc, so I manually make the 1.13.0 for grpc.

Success on Linux (partially)

I confirm possibility of building on Linux platform:
Linux Mint - yes.
openSuse - yes:
Ubunty - NO.

Is there any chance on Windows (MinGW or VS 2015) ?

isuues running mqtt-ciotc

Hi,
im trying to run the mqtt client example to demostrate publishing to google_cloud_iot. i followed the README file and installed all the dependent libraries, and was able to generate the executable also but while executing it, code it is throwing:
Segmentation fault (core dumped)

Any help is appreciated!
Thanks in advance!

Problems to generate googleapis gRPC source code

in googleapis/
$ make all

protoc --proto_path=.:/usr/local/include --cpp_out=./gens --grpc_out=./gens --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin google/ads/googleads/v0/resources/ad_group.proto
google/ads/googleads/v0/common/custom_parameter.proto:31:8: Option "php_metadata_namespace" unknown.
google/ads/googleads/v0/enums/ad_group_status.proto:29:8: Option "php_metadata_namespace" unknown.
google/ads/googleads/v0/enums/ad_group_type.proto:29:8: Option "php_metadata_namespace" unknown.
google/ads/googleads/v0/resources/ad_group.proto: Import "google/ads/googleads/v0/common/custom_parameter.proto" was not found or had errors.
google/ads/googleads/v0/resources/ad_group.proto: Import "google/ads/googleads/v0/enums/ad_group_status.proto" was not found or had errors.
google/ads/googleads/v0/resources/ad_group.proto: Import "google/ads/googleads/v0/enums/ad_group_type.proto" was not found or had errors.
google/ads/googleads/v0/resources/ad_group.proto:60:3: "enums.AdGroupStatusEnum.AdGroupStatus" is not defined.
google/ads/googleads/v0/resources/ad_group.proto:63:3: "enums.AdGroupTypeEnum.AdGroupType" is not defined.
google/ads/googleads/v0/resources/ad_group.proto:70:12: "common.CustomParameter" is not defined.
Makefile:44: recipe for target 'google/ads/googleads/v0/resources/ad_group.pb.cc' failed
make: *** [google/ads/googleads/v0/resources/ad_group.pb.cc] Error 1

how to fix it?

TODO: Use known files on cloud storage for tests.

The only thing that didn't work was the last two tests on GCS since the env variable wasn't set.
Can you use these instead?

gs://cloud-samples-tests/speech/brooklyn.flac for transcribe
gs://cloud-samples-tests/speech/vr.flac for async

Trouble running the iot sample

Hi Team,
After running this
./setup_device.sh --registry-name my_registry --registry-region asia-east1 --device-id led-light
rsa certificate created but getting error like
./setup_device.sh: line 67: gcloud: command not found

setup_device.zip

make run_tests error

I am using Ubuntu bash on Windows 10.
After:
successful compiling (and installing) gRPC (and proto3)
during:
make run_tests
Pawel@DESKTOP-HJSUITN:~/cpp-docs-samples/speech/api$ make run_tests
./transcribe -b 16000 resources/audio.raw
E1127 13:29:22.675581700 26963 ev_epoll_linux.c:1655] pollset_work: {"created":"@1480282162.675479800","descripti
on":"pollset_work_and_unlock","file":"src/core/lib/iomgr/ev_epoll_linux.c","file_line":268,"referenced_errors":[{"create
d":"@1480282162.675471900","description":"OS Error","errno":38,"file":"src/core/lib/iomgr/ev_epoll_linux.c","file_line":
1486,"os_error":"Function not implemented","syscall":"epoll_wait() epoll fd: 6 failed with error: 38 (Function not imple
mented)"}]}
E1127 13:29:22.677600200 26963 google_default_credentials.c:149] pollset_work: {"created":"@1480282162.675479800","des
cription":"pollset_work_and_unlock","file":"src/core/lib/iomgr/ev_epoll_linux.c","file_line":268,"referenced_errors":[{"
created":"@1480282162.675471900","description":"OS Error","errno":38,"file":"src/core/lib/iomgr/ev_epoll_linux.c","file_
line":1486,"os_error":"Function not implemented","syscall":"epoll_wait() epoll fd: 6 failed with error: 38 (Function not
implemented)"}]}
E1127 13:29:22.677996000 26963 google_default_credentials.c:293] Could not create google default credentials.
E1127 13:29:22.678300500 26963 google_default_credentials.c:298] grpc_google_default_credentials_create: {"created":"@
1480282162.668035600","description":"Failed to create Google credentials","file":"src/core/lib/security/credentials/goog
le_default/google_default_credentials.c","file_line":237,"referenced_errors":[{"created":"@1480282162.668040700","descri
ption":"creds_path unset","file":"src/core/lib/security/credentials/google_default/google_default_credentials.c","file_l
ine":181},{"created":"@1480282162.668200400","description":"Failed to load file","file":"src/core/lib/iomgr/load_file.c"
,"file_line":82,"filename":"/home/Pawel/.config/gcloud/application_default_credentials.json","referenced_errors":[{"crea
ted":"@1480282162.668192800","description":"OS Error","errno":2,"file":"src/core/lib/iomgr/load_file.c","file_line":58,"
os_error":"No such file or directory","syscall":"fopen"}]}]}
E1127 13:29:22.841562400 26964 polling_entity.c:101] Invalid grpc_polling_entity tag '-566067776'

Could not create google default credentials

Hi All,
I am working on the Opensuse Leap 155.0 for running these tests.
I have installed protobuf and grpc successfully, and trying to make the cpp-docs-samples > speech > api> make run_tests. I am getting this error

Error.txt

sudo make run_tests

./transcribe -b 16000 resources/audio.raw E0205 18:55:48.361527397 3233 google_default_credentials.cc:350] Could not create google default credentials: {"created":"@1549373148.360106566","description":"Failed to create Google credentials","file":"src/core/lib/security/credentials/google_default/google_default_credentials.cc","file_line":284,"referenced_errors":[{"created":"@1549373148.360126434","description":"Failed to load file","file":"src/core/lib/iomgr/load_file.cc","file_line":71,"filename":"home/rohan/Downloads/proven-caster-222406-5522480516c5.json","referenced_errors":[{"created":"@1549373148.360123641","description":"No such file or directory","errno":2,"file":"src/core/lib/iomgr/load_file.cc","file_line":45,"os_error":"No such file or directory","syscall":"fopen"}]},{"created":"@1549373148.360135072","description":"Failed to load file","file":"src/core/lib/iomgr/load_file.cc","file_line":71,"filename":"/root/.config/gcloud/application_default_credentials.json","referenced_errors":[{"created":"@1549373148.360134709","description":"No such file or directory","errno":2,"file":"src/core/lib/iomgr/load_file.cc","file_line":45,"os_error":"No such file or directory","syscall":"fopen"}]}]} lame client channel make: *** [Makefile:63: run_tests] Error 255

Can someone help me with this?

Hints

Hi Jeff, I don't really have an issue per say but I used your sample as a starting point and I'm trying to add hint phrases to my application that mostly requires single word answers to voice prompts and the the API often returns unexpected responses maybe because of the Australian accent inputs.

To cut a long story short I thought phrase hints might be the solution but lacking any example code for c++ I cobbled the following together by looking at the auto generated header file cloud_speech.pb.h:

    RecognitionConfig *rc = streaming_config->mutable_config();
    rc->set_language_code("en");
    rc->set_sample_rate_hertz(8000);  // Default sample rate.
    rc->set_encoding(RecognitionConfig::LINEAR16);
    _**SpeechContext *speechContext = rc->add_speech_contexts();
    speechContext->add_phrases(std::string("hive,gown"));**_

I tested by saying <I've> (I have) and expected it to interpret as (my phrase hint) but it didn't. It returned <I've> which was correct(what I said) but I wanted it to take my hint instead. Is my understanding of hints wrong or am I not using the API correctly.

I hope you don't mind my request in this forum.

Regards,
Cal

c++ speech sample question.

hello. i'm beginner.

i'm trying to build this sample. but i can't build and run this sample.

i'm install gRPC, and protobuf, and i try build

  1. Generate googleapis gRPC source code.

but filed to make, and I try use bezel build success.

but when i try 8. 9. i'm can't build

  • cd cpp-docs-samples/speech/api
  • make run_tests

error is log.severity.pb.h is not found.

  • i'm usinb grpc 1.30.0

my question is..

now, this sample is can build? and run?

thank you.

Assertion failure in grpc call.

[Steps to reproduce]
Build Dockerfile using the steps found in Docker.README.md.

run: ./streaming_transcribe_singlethread -b 16000 resources/audio.raw

[Error]

channel_cc.cc:136]        assertion failed: GRPC_CALL_OK == grpc_call_start_batch(call->call(), cops, nops, ops, nullptr)

Sending multiple alternative languages

Hey,
I'm using Google speech to text's v1p1beta1 library, which enabled me to send alternative language with a primary language. For one primary language it is working completely fine. But I'm not able to figure out how to send multiple alternative language ? Google's documentation states that upto 3 alternative languages can be sent.

Support Arduino devices

Looking at cpp-docs-samples/iot/mqtt-ciotc/ the example is not able to run on an Arduino device.
I would like to ask for the support of the Arduino environment to be supported, this would allow as vast range of arduino IOT to use Google Clould IOT service, including the MQTT service.

Cloud Run improvements

  • Dockerfile: Add some more comments so the Dockerfile can be more easily followed by someone new to containers.
  • App Code: "World" should be overridable with the environment variable TARGET.
  • README: 1. No need for beta component, 2. Unless using Cloud Run for Anthos, no need for kubectl

Fresh pull of repo won't successfully build cloud run example

Pulling the repo fresh and following the instructions in the readme results in this failure:

joeholley@instance-1:~/repos/git/cpp-samples/cloud-run-hello-world$ bash -x ./bootstrap-cloud-run-hello.sh
+ set -eu
+ [[ -z buildtest01 ]]
+ readonly GOOGLE_CLOUD_PROJECT=buildtest01
+ GOOGLE_CLOUD_PROJECT=buildtest01
+ readonly GOOGLE_CLOUD_REGION=asia-northeast1
+ GOOGLE_CLOUD_REGION=asia-northeast1
+ gcloud services enable cloudbuild.googleapis.com --project=buildtest01
+ gcloud services enable containerregistry.googleapis.com --project=buildtest01
+ gcloud services enable run.googleapis.com --project=buildtest01
++ git rev-parse --short HEAD
+ gcloud builds submit --project=buildtest01 --substitutions=SHORT_SHA=4433ef3 --config=cloudbuild.yaml
Creating temporary tarball archive of 8 file(s) totalling 12.9 KiB before compression.
Some files were not included in the source upload.

Check the gcloud log [/home/joeholley/.config/gcloud/logs/2021.05.27/07.05.46.811772.log] to see which files and the contents of the
default gcloudignore file used (see `$ gcloud topic gcloudignore` to learn
more).

Uploading tarball of [.] to [gs://buildtest01_cloudbuild/source/1622099146.878179-6db645fdfa974f41b0813c21348de0ab.tgz]
ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: generic::invalid_argument: key "SHORT_SHA" in the substitution data is not matched in the template

Removing the substitution argument from the bootstrap script resolves the problem (I didn't see anywhere obvious in the cloudbuild.yaml where the SHORT_SHA substitution was needed and missing):

joeholley@instance-1:~/repos/git/cpp-samples/cloud-run-hello-world$ git diff
diff --git a/cloud-run-hello-world/bootstrap-cloud-run-hello.sh b/cloud-run-hello-world/bootstrap-cloud-run-hello.sh
index 1440f28..fe30357 100755
--- a/cloud-run-hello-world/bootstrap-cloud-run-hello.sh
+++ b/cloud-run-hello-world/bootstrap-cloud-run-hello.sh
@@ -34,7 +34,6 @@ gcloud services enable run.googleapis.com \
 # Build the Docker Images
 gcloud builds submit \
     "--project=${GOOGLE_CLOUD_PROJECT}" \
-    "--substitutions=SHORT_SHA=$(git rev-parse --short HEAD)" \
     "--config=cloudbuild.yaml"

 # Create a service account that will update the index

Let me know if you want me to submit a PR.

C++ continuous speech recognition

Hello all,

I am trying to use Google cloud Speech for speech-to-text using streaming API. The samples work for me fine, however my usecase is a bit different: I would like to do continuous, streaming speech recognition (multiple requests). So I face two issues:

  1. It looks like I cannot use grpc::ClientReaderWriter<StreamingRecognizeRequest, StreamingRecognizeResponse> for multiple requests because I get an exception: assertion failed: call_ == nullptr client_context.cc. So, I have to recreate complete config (credentials, channel, context, config request) for each request and I don't find it elegant because it adds unnecessary overhead.

  2. To avoid any latency due to the config creation I create it beforehand and wait for the audio samples from mics. However, if the audio samples arrive a bit late I get Audio Timeout Error: Long duration elapsed without audio. Audio should be sent close to real time.

So my question(s): What is the correct way to use google streaming API in C++ for multiple requests: Due we have to renew objects for each recognition requests and Is there any way to avoid timeout?

I am working on Ubuntu 14.04 LTS. The speech API code was downloaded in April 2018.

Thanks.

SPEECH_PROTO_PATH role

What does this line of code exactly do ?
SPEECH_PROTO_PATH = google/cloud/speech/v1beta1

Can't run the new v1 speech sample

Here is the error I'm getting:

daharon-macbookair2:api daharon$ make run_tests
./transcribe -b 16000 resources/audio.raw
[libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: google/protobuf/descriptor.proto
[libprotobuf FATAL google/protobuf/descriptor.cc:1272] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
libc++abi.dylib: terminating with uncaught exception of type google::protobuf::FatalException: CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
make: *** [run_tests] Abort trap: 6
daharon-macbookair2:api daharon$ ./transcribe -b 16000 resources/audio.raw
[libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: google/protobuf/descriptor.proto
[libprotobuf FATAL google/protobuf/descriptor.cc:1272] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
libc++abi.dylib: terminating with uncaught exception of type google::protobuf::FatalException: CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
Abort trap: 6
daharon-macbookair2:api daharon$ ls -l
total 220016
-rw-r--r-- 1 daharon eng 871 Apr 12 19:51 Docker.README.md
-rw-r--r-- 1 daharon eng 1640 Apr 12 19:51 Dockerfile
-rw-r--r-- 1 daharon eng 2724 Apr 12 19:51 Makefile
-rw-r--r-- 1 daharon eng 3596 Apr 12 19:51 README.md
-rwxr-xr-x 1 daharon eng 2055728 Apr 12 20:11 async_transcribe
-rw-r--r-- 1 daharon eng 3734 Apr 12 19:51 async_transcribe.cc
-rw-r--r-- 1 daharon eng 31532 Apr 12 20:11 async_transcribe.o
-rw-r--r-- 1 daharon eng 104529280 Apr 12 19:59 googleapis.ar
-rw-r--r-- 1 daharon eng 2356 Apr 12 19:51 parse_arguments.cc
-rw-r--r-- 1 daharon eng 1155 Apr 12 19:51 parse_arguments.h
-rw-r--r-- 1 daharon eng 5824 Apr 12 19:52 parse_arguments.o
drwxr-xr-x 6 daharon eng 204 Apr 12 19:51 resources
-rwxr-xr-x 1 daharon eng 1914380 Apr 12 20:11 streaming_transcribe
-rw-r--r-- 1 daharon eng 4141 Apr 12 19:51 streaming_transcribe.cc
-rw-r--r-- 1 daharon eng 106228 Apr 12 20:11 streaming_transcribe.o
-rwxr-xr-x 1 daharon eng 1909128 Apr 12 20:11 streaming_transcribe_singlethread
-rw-r--r-- 1 daharon eng 6247 Apr 12 19:51 streaming_transcribe_singlethread.cc
-rw-r--r-- 1 daharon eng 76920 Apr 12 20:11 streaming_transcribe_singlethread.o
-rwxr-xr-x 1 daharon eng 1901552 Apr 12 20:11 transcribe
-rw-r--r-- 1 daharon eng 3145 Apr 12 19:51 transcribe.cc
-rw-r--r-- 1 daharon eng 50476 Apr 12 19:52 transcribe.o
daharon-macbookair2:api daharon$ ./transcribe
[libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: google/protobuf/descriptor.proto
[libprotobuf FATAL google/protobuf/descriptor.cc:1272] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
libc++abi.dylib: terminating with uncaught exception of type google::protobuf::FatalException: CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
Abort trap: 6

Google Cloud Speech API

According to google the Google Cloud Speech API is now Generally Available.
Within this change, some other changes were made on the api.
Does it influences this demo program? What kind of changes are needed to migrate this demo to the new GCSAPI version?

Google speech not good at split Chinese

We use CPP Google Speech APIs to transfer voice into text, it works fine for English, but not good at split sentence for Chinese. At result, we can also received the last sentence text, didn't be cleared when new sentence start, not same as English.
Is there are any APIs to solve this issue ?

Our codes are:
void Run()
{
auto creds = grpc::GoogleDefaultCredentials();
auto channel = grpc::CreateChannel("speech.googleapis.com", creds);

std::unique_ptrSpeech::Stub speech(Speech::NewStub(channel));

StreamingRecognizeRequest request;
auto * streaming_config = request.mutable_streaming_config();

streaming_config->mutable_config()->set_language_code("zh");
streaming_config->mutable_config()->set_sample_rate_hertz(RATE);
streaming_config->mutable_config()->set_encoding(RecognitionConfig::LINEAR16);
streaming_config->set_interim_results(true);
streaming_config->set_single_utterance(false);

grpc::ClientContext context;
auto streamer = speech->StreamingRecognize(&context);
streamer->Write(request);

std::thread wavein_thread(&CSpeechClient::waveIn_Proc, streamer.get(), this);

StreamingRecognizeResponse response;
while (streamer->Read(&response))
{
for (int i = 0; i < response.results_size(); ++i)
{
auto result = response.results(i);
std::cout << "Result stability: " << result.stability() << ", " << result.is_final() << std::endl;
for (int a = 0; a < result.alternatives_size(); ++a)
{
auto alternative = result.alternatives(a);
if (result.stability() > 0.1 || alternative.confidence() > 0.1)
{
std::cout << alternative.confidence() << "\t" << alternative.transcript() << std::endl;
}
}
}
}
grpc::Status status = streamer->Finish();
wavein_thread.join();

if (!status.ok())
{
std::cerr << status.error_message() << std::endl;
}
};

Configure ci builds

Since we have multiple sub directories, the test driver ideally run the tests for sub directories which has changes for pull requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.