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