Remove profanity censor from Google Speech Recognition
Asked Answered
W

1

3

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];
Worth answered 22/2, 2013 at 17:57 Comment(0)
W
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***.

Worth answered 25/2, 2013 at 16:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.