user2618662
user2618662

Reputation: 41

Using Google Voice Recognition API in building an iOS application

I am developing an iOS application with voice recognition functionality. I found the way to use Google Web Speech API for voice recognition and text-to-speech purposes. It works fine. I am wondering if it is legal to use Google Web Speech API in an iOS application? Also are there any limits of usage for this API? I tried to find any terms of service for it, but could not find any.

Upvotes: 3

Views: 4746

Answers (2)

rossodisera
rossodisera

Reputation: 81

Record your voice with standard ios format (example mpeg4). Convert your recording in flac format (you cannot do this inside xcode, I used a php service with ffmpeg command). Then call google service with the following code:

NSMutableURLRequest *urlGoogleRequest = [[NSMutableURLRequest  alloc]initWithURL:urlGoogle];
[urlGoogleRequest setHTTPMethod:@"POST"];
[urlGoogleRequest addValue:@"audio/x-flac; rate=16000" forHTTPHeaderField:@"Content-Type"];
NSURLResponse* response = nil;
            NSError* error = nil;
[urlGoogleRequest setHTTPBody:audioDataFlac];
NSData* googleResponse = [NSURLConnection sendSynchronousRequest:urlGoogleRequest
                                                 returningResponse:&response
                                                             error:&error];
id jsonObject=[NSJSONSerialization JSONObjectWithData:googleResponse options:kNilOptions error:nil];

Example response from google:

{ "status": 0, "id": "b3447b5d98c5653e0067f35b32c0a8ca-1", "hypotheses": [ { "utterance": "i like pickles", "confidence": 0.9012539 }, { "utterance": "i like pickle" }] }

This method is not very straight-forward, anyway it works for me. Remember that google speech recognition is valid only for test purpose.

Good Luck!

Upvotes: 3

John Martin
John Martin

Reputation: 1

It depends on the type of application you would like to develop. But generally it is not very easy to use this API for an iOS application.

Upvotes: -1

Related Questions