Reputation: 21
I uploaded a 2-minute audio file, and the transcript results began after half of the audio was processed. However, the result.formattedString started a new string instead of appending to the already transcribed text.
This issue occur only onDeviceTranscript, How to fix it?
NSLocale *locale =[[NSLocale alloc] initWithLocaleIdentifier:[[NSLocale preferredLanguages] firstObject]];
SFSpeechRecognizer* recognizer = [[SFSpeechRecognizer alloc] initWithLocale:locale];
SFSpeechURLRecognitionRequest* request = [[SFSpeechURLRecognitionRequest alloc] initWithURL:[NSURL fileURLWithPath:filePath]];
if(device){
request.requiresOnDeviceRecognition = YES;
}
[recognizer recognitionTaskWithRequest:request resultHandler:^(SFSpeechRecognitionResult * _Nullable result, NSError * _Nullable error) {
if (error) {
convertedString(textString);
}
else {
textString = [[result bestTranscription] formattedString];
}
if (result.isFinal)
{
convertedString([[result bestTranscription] formattedString]);
}
}];
Upvotes: 0
Views: 48