I am trying to integrate google cloud speech API in my demo app. What I am getting as result is below :
{
results {
alternatives {
transcript: "hello"
}
stability: 0.01
}
}
Code to get response :
[[SpeechRecognitionService sharedInstance] streamAudioData:self.audioData
withCompletion:^(StreamingRecognizeResponse *response, NSError *error) {
if (error) {
NSLog(@"ERROR: %@", error);
_textView.text = [error localizedDescription];
[self stopAudio:nil];
} else if (response) {
BOOL finished = NO;
//NSLog(@"RESPONSE: %@", response.resultsArray);
for (StreamingRecognitionResult *result in response.resultsArray) {
NSLog(@"result : %@",result);
//_textView.text = result.alternatives.transcript;
if (result.isFinal) {
finished = YES;
}
}
if (finished) {
[self stopAudio:nil];
}
}
}
];
My problem is, the response i am getting is not a proper JSON then how do i get the value of key transcript
? Any help would be appreciated. Thanks.
For someone who is looking for this problem's solution:
for (StreamingRecognitionResult *result in response.resultsArray) {
for (StreamingRecognitionResult *alternative in result.alternativesArray) {
_textView.text = [NSString stringWithFormat:@"%@",[alternative valueForKey:@"transcript"]];
}
if (result.isFinal) {
finished = YES;
}
}
This is what i did to get the value for transcript
continuously.