Add Google Speech To Text To Existing Project

Google created many useful libraries also on iOS platform. One of them is Speech to Text.

We will add it to our existing project using CocoaPods.

Before you start you need:
1 Have some existing project where you want to add speech recognition.
2 How to use CocoaPods
3 Use Google’s code

Firstly, download or clone the repository and open it.

Go to speech folder.

Next to Swift folder.

Next to Speech-gRPC-Streaming. Inside copy google folder and googleapis.podspec.

Go to your project folder and paste them.

Then add googleapis dependency using Podfile.

After you open the project you won’t be able to use googleapis yet. Some headers are imported incorrectly and you need to change them manually.

After each change try to build a project and you’ll be moved to next. There are about 10 changes.

“google/cloud/speech/v1beta1/CloudSpeech.pbobjc.h” 
change to
<googleapis/CloudSpeech.pbobjc.h>

“google/api/Annotations.pbobjc.h”
change to
<googleapis/Annotations.pbobjc.h>

“google/longrunning/Operations.pbobjc.h”
change to
<googleapis/Operations.pbobjc.h>

“google/rpc/Status.pbobjc.h”
change to
<googleapis/Status.pbobjc.h>

“google/cloud/texttospeech/v1beta1/CloudTts.pbobjc.h”
change to
<googleapis/CloudTts.pbobjc.h>

“google/cloud/translate/v3beta1/TranslationService.pbobjc.h”
change to
<googleapis/TranslationService.pbobjc.h>

After these changes you can use Google’s api.