Using Siri to set params, don't recognize personal names in Portuguese, even the Siri is configured in same language

37 views Asked by At

(on the Simulator works)

When we attempt to use the common Siri to recognize speech with the same names in Brazil, it works. However, when using the same names in App Shortcuts, it is not recognized (although it works on the Simulator).

The code is designed to recognize personal names in Portuguese and has been tested on an iPhone 13 Pro running iOS 17.2.

struct Intents {
    @available(iOS 16, *)
    struct ShortcutsProvider: AppShortcutsProvider {

        static var appShortcuts: [AppShortcut] {
            AppShortcut(
                intent: ContactsIntent(),
                phrases: [
                    "Contato com \(.applicationName)"
                ],
                shortTitle: LocalizedStringResource("Falar")
            )
        }
    }
}

@available(iOS 16, *)

struct ContactsIntent: AppIntent {

    static var title: LocalizedStringResource = "Select contact"

    static var openAppWhenRun = true

    static var authenticationPolicy: IntentAuthenticationPolicy = .requiresAuthentication

    @Parameter(
        title: "Contacts",
        description: "Send to contacts",
        requestValueDialog: IntentDialog("Who is the contact?"),
        optionsProvider: ContactsectionsOptionsProvider()
    )
    var contact: String


    private struct ContactsectionsOptionsProvider: DynamicOptionsProvider {
        func results() async throws -> ItemCollection<String> {
            return ItemCollection {
                ItemSection(
                    items: DataStorage.contacts.map {
                        let name = $0.capitalized(with: .autoupdatingCurrent)
                        return IntentItem<String>.init(
                            name,
                            title: LocalizedStringResource(stringLiteral: name)
                        )
                    }
                )
            }
        }
    }

    @MainActor
    func perform() async throws -> some IntentResult {

        // This never is called

        return .result()
    }
}

struct DataStorage {
    // Communs names in Brazil
    static var contacts: [String] {
        [
            "Adriano",
            "Ricardo",
            "Bruno"
        ]
    }
}
0

There are 0 answers