问题
I am trying to convert speech to text in an iOS application using Google's Speech to Text API. I am simply sending some audio data to the URL "https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US" and it is returning me the (mostly) correct words I say. However, it is replacing any profanity with '####'. How can I replace the '####' with the actual curse words?
Just some additional information: I am using the todoroo SpeechToText library. The code for the request is as follows:
NSURL *url = [NSURL URLWithString:@"https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:byteData];
[request addValue:@"audio/x-speex-with-header-byte; rate=16000" forHTTPHeaderField:@"Content-Type"];
[request setURL:url];
[request setTimeoutInterval:15];
NSURLResponse *response;
NSError *error = nil;
....
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
回答1:
Found it: Simply add &pfilter=0 to the URL so it becomes
https://www.google.com/speech-api/v1/recognize?xjerr=1&pfilter=0&client=chromium&lang=en-US"
Note that setting pfilter=0 removes the profanity filter, pfilter = 1 replaces any profanity with '####' (always 4 hash marks), and pfilter = 2 replaces profanity with its first letter and the correct number of asterisks, i.e: b**** or f***.
来源:https://stackoverflow.com/questions/15030339/remove-profanity-censor-from-google-speech-recognition