objc2_speech/generated/
SFSpeechLanguageModel.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// An object describing the location of a custom language model and specialized vocabulary.
12    ///
13    /// Pass this object to ``SFSpeechLanguageModel/prepareCustomLanguageModelForUrl:configuration:completion:`` to indicate where that method should create the custom language model file, and to ``SFSpeechRecognitionRequest/customizedLanguageModel`` or ``DictationTranscriber/ContentHint/customizedLanguage(modelConfiguration:)`` to indicate where the system should find that model to use.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/speech/sfspeechlanguagemodelconfiguration?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct SFSpeechLanguageModelConfiguration;
19);
20
21unsafe impl Send for SFSpeechLanguageModelConfiguration {}
22
23unsafe impl Sync for SFSpeechLanguageModelConfiguration {}
24
25extern_conformance!(
26    unsafe impl NSCoding for SFSpeechLanguageModelConfiguration {}
27);
28
29extern_conformance!(
30    unsafe impl NSCopying for SFSpeechLanguageModelConfiguration {}
31);
32
33unsafe impl CopyingHelper for SFSpeechLanguageModelConfiguration {
34    type Result = Self;
35}
36
37extern_conformance!(
38    unsafe impl NSObjectProtocol for SFSpeechLanguageModelConfiguration {}
39);
40
41extern_conformance!(
42    unsafe impl NSSecureCoding for SFSpeechLanguageModelConfiguration {}
43);
44
45impl SFSpeechLanguageModelConfiguration {
46    extern_methods!(
47        /// The location of a compiled language model file.
48        ///
49        /// This property is not atomic.
50        ///
51        /// # Safety
52        ///
53        /// This might not be thread-safe.
54        #[unsafe(method(languageModel))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn languageModel(&self) -> Retained<NSURL>;
57
58        /// The location of a compiled vocabulary file.
59        ///
60        /// This property is not atomic.
61        ///
62        /// # Safety
63        ///
64        /// This might not be thread-safe.
65        #[unsafe(method(vocabulary))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn vocabulary(&self) -> Option<Retained<NSURL>>;
68
69        /// The relative weight of the language model customization. Value must be between 0.0 and 1.0 inclusive.
70        ///
71        /// This property is not atomic.
72        ///
73        /// # Safety
74        ///
75        /// This might not be thread-safe.
76        #[unsafe(method(weight))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn weight(&self) -> Option<Retained<NSNumber>>;
79
80        /// Creates a configuration with the location of a language model file.
81        #[unsafe(method(initWithLanguageModel:))]
82        #[unsafe(method_family = init)]
83        pub unsafe fn initWithLanguageModel(
84            this: Allocated<Self>,
85            language_model: &NSURL,
86        ) -> Retained<Self>;
87
88        /// Creates a configuration with the locations of language model and vocabulary files.
89        #[unsafe(method(initWithLanguageModel:vocabulary:))]
90        #[unsafe(method_family = init)]
91        pub unsafe fn initWithLanguageModel_vocabulary(
92            this: Allocated<Self>,
93            language_model: &NSURL,
94            vocabulary: Option<&NSURL>,
95        ) -> Retained<Self>;
96
97        /// Creates a configuration with the locations of language model and vocabulary files, and custom weight.
98        #[unsafe(method(initWithLanguageModel:vocabulary:weight:))]
99        #[unsafe(method_family = init)]
100        pub unsafe fn initWithLanguageModel_vocabulary_weight(
101            this: Allocated<Self>,
102            language_model: &NSURL,
103            vocabulary: Option<&NSURL>,
104            weight: Option<&NSNumber>,
105        ) -> Retained<Self>;
106    );
107}
108
109/// Methods declared on superclass `NSObject`.
110impl SFSpeechLanguageModelConfiguration {
111    extern_methods!(
112        #[unsafe(method(init))]
113        #[unsafe(method_family = init)]
114        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
115
116        #[unsafe(method(new))]
117        #[unsafe(method_family = new)]
118        pub unsafe fn new() -> Retained<Self>;
119    );
120}
121
122extern_class!(
123    /// A language model built from custom training data.
124    ///
125    /// Create this object using ``SFSpeechLanguageModel/prepareCustomLanguageModelForUrl:configuration:completion:`` or ``SFSpeechLanguageModel/prepareCustomLanguageModelForUrl:configuration:ignoresCache:completion:``.
126    ///
127    /// See also [Apple's documentation](https://developer.apple.com/documentation/speech/sfspeechlanguagemodel?language=objc)
128    #[unsafe(super(NSObject))]
129    #[derive(Debug, PartialEq, Eq, Hash)]
130    pub struct SFSpeechLanguageModel;
131);
132
133extern_conformance!(
134    unsafe impl NSObjectProtocol for SFSpeechLanguageModel {}
135);
136
137impl SFSpeechLanguageModel {
138    extern_methods!(
139        #[cfg(feature = "block2")]
140        #[deprecated]
141        #[unsafe(method(prepareCustomLanguageModelForUrl:clientIdentifier:configuration:completion:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn prepareCustomLanguageModelForUrl_clientIdentifier_configuration_completion(
144            asset: &NSURL,
145            client_identifier: &NSString,
146            configuration: &SFSpeechLanguageModelConfiguration,
147            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
148        );
149
150        #[cfg(feature = "block2")]
151        #[deprecated]
152        #[unsafe(method(prepareCustomLanguageModelForUrl:clientIdentifier:configuration:ignoresCache:completion:))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn prepareCustomLanguageModelForUrl_clientIdentifier_configuration_ignoresCache_completion(
155            asset: &NSURL,
156            client_identifier: &NSString,
157            configuration: &SFSpeechLanguageModelConfiguration,
158            ignores_cache: bool,
159            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
160        );
161
162        #[cfg(feature = "block2")]
163        /// Creates a language model from custom training data.
164        ///
165        /// - Parameters:
166        /// - asset: The URL of a file containing custom training data. Create this file with ``SFCustomLanguageModelData/export(to:)``.
167        /// - configuration: An object listing the URLs at which this method should create the language model and compiled vocabulary from the training data.
168        /// - completion: Called when the language model has been created.
169        #[unsafe(method(prepareCustomLanguageModelForUrl:configuration:completion:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn prepareCustomLanguageModelForUrl_configuration_completion(
172            asset: &NSURL,
173            configuration: &SFSpeechLanguageModelConfiguration,
174            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
175        );
176
177        #[cfg(feature = "block2")]
178        /// Creates a language model from custom training data.
179        ///
180        /// - Parameters:
181        /// - asset: The URL of a file containing custom training data. Create this file with ``SFCustomLanguageModelData/export(to:)``.
182        /// - configuration: An object listing the URLs at which this method should create the language model and compiled vocabulary from the training data.
183        /// - ignoresCache: If `true`, the language model identified by the configuration will be recreated even if the `asset` file is unchanged.
184        /// - completion: Called when the language model has been created.
185        #[unsafe(method(prepareCustomLanguageModelForUrl:configuration:ignoresCache:completion:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn prepareCustomLanguageModelForUrl_configuration_ignoresCache_completion(
188            asset: &NSURL,
189            configuration: &SFSpeechLanguageModelConfiguration,
190            ignores_cache: bool,
191            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
192        );
193    );
194}
195
196/// Methods declared on superclass `NSObject`.
197impl SFSpeechLanguageModel {
198    extern_methods!(
199        #[unsafe(method(init))]
200        #[unsafe(method_family = init)]
201        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
202
203        #[unsafe(method(new))]
204        #[unsafe(method_family = new)]
205        pub unsafe fn new() -> Retained<Self>;
206    );
207}