Remove profanity censor from Google Speech Recognition

筅森魡賤 提交于 2019-12-10 20:22:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!