| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
These samples demonstrate how to call the Google Cloud Speech API using C++.
We only test these samples on Linux. If you are running Windows and macOS please see the additional notes for your platform.
Create a project in the Google Cloud Platform Console. If you haven't already created a project, create one now. Projects enable you to manage all Google Cloud Platform resources for your app, including deployment, access control, billing, and services.
Enable billing for your project. If you haven't already enabled billing for your project, enable billing now. Enabling billing allows the application to consume billable resources such as Speech API calls. See Cloud Platform Console Help for more information about billing settings.
Enable APIs for your project. Click here to visit Cloud Platform Console and enable the Speech API via the UI.
Or use the CLI:
gcloud services enable speech.googleapis.com
If needed, override the Billing Project. If you are using a user account for authentication, you need to set the GOOGLE_CLOUD_CPP_USER_PROJECT environment variable to the project you created in the previous step. Be aware that you must have serviceusage.services.use permission on the project. Alternatively, use a service account as described next.
Download service account credentials. These samples can use service accounts for authentication.
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials-key.json
See the Cloud Platform Auth Guide for more information.
Install vcpkg. This project uses vcpkg for dependency management. Clone the vcpkg repository to your preferred location. In these instructions we use$HOME:
git clone -C $HOME https://github.com/microsoft/vcpkg.gitDownload or clone this repo with
git clone https://github.com/GoogleCloudPlatform/cpp-samplesCompile these examples: Use the vcpkg toolchain file to download and compile dependencies. This file would be in the directory you cloned vcpkg into, $HOME/vcpkg if you are following the instructions to the letter. Note that building all the dependencies can take up to an hour, depending on the performance of your workstation. These dependencies are cached, so a second build should be substantially faster.
cd cpp-samples/speech/api
cmake -S. -B.build -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build .buildRun the examples:
.build/transcribe --bitrate 16000 resources/audio2.raw
.build/transcribe resources/audio.flac
.build/transcribe resources/quit.raw
.build/streaming_transcribe --bitrate 16000 resources/audio2.raw
.build/streaming_transcribe resources/audio.flac
.build/streaming_transcribe resources/quit.raw
.build/streaming_transcribe_coroutines --bitrate 16000 resources/audio2.raw
.build/streaming_transcribe_coroutines resources/audio.flac
.build/streaming_transcribe_coroutines resources/quit.raw
.build/streaming_transcribe_singlethread --bitrate 16000 resources/audio.raw
.build/transcribe gs://cloud-samples-tests/speech/brooklyn.flac
.build/async_transcribe gs://cloud-samples-tests/speech/vr.flacgRPC requires an environment variable to configure the trust store for SSL certificates, you can download and configure this using:
curl -Lo roots.pem https://pki.google.com/roots.pem
export GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="$PWD/roots.pem"gRPC requires an environment variable to configure the trust store for SSL certificates, you can download and configure this using:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command ^
(new-object System.Net.WebClient).Downloadfile( ^
'https://pki.google.com/roots.pem', 'roots.pem')
set GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=%cd%\roots.pem| Back | FazBrowse Home | New Git URL |