'FirebaseMLNLTranslation model files not found
I am adding a translate text feature to my app. I have the text and run the initial setup, but this error keeps coming up.
error: Error Domain=com.firebase.ml Code=13 "Translation model files not found. Make sure to call downloadModelIfNeeded and if that fails, delete the models and retry." UserInfo={NSLocalizedDescription=Translation model files not found. Make sure to call downloadModelIfNeeded and if that fails, delete the models and retry.}
This is the function that translates the text...
translator.translate(textView.text) { [self] translatedText, error in
print("Translator Translated")
guard error == nil, let translatedText = translatedText else {
print(error!); return // prints the error below...
}
print(translatedText) // nil (when I comment out the guard statement)
}
This is the setup code run before the translation.
let options = TranslatorOptions(sourceLanguage: .en, targetLanguage: .es) //
print("Options: \(options)") // Options: sourceLanguage: en, targetLanguage: es
let translator = NaturalLanguage.naturalLanguage().translator(options: options)
print("Translator: \(translator)") // Translator: <FIRTranslator: 0x280173ac0>
let conditions = ModelDownloadConditions (
allowsCellularAccess: true,
allowsBackgroundDownloading: false
); print("Conditions: \(conditions)") // Conditions: allowsCellularAccess: 1, allowsBackgroundDownloading: 0
translator.downloadModelIfNeeded(with: conditions) { error in
guard error == nil else {
print("Model Failed To Download because: \(error!)"); return
}
}
textView.text
is not nil
. I have no idea how to solve this problem and there are no solutions that I have found online. It actually used to work and I revisited my project after some time off and it all of a sudden started presenting this error. Any help is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|