objc2_avf_audio/generated/
AVSpeechSynthesisProvider.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::*;
6#[cfg(feature = "objc2-audio-toolbox")]
7#[cfg(not(target_os = "watchos"))]
8use objc2_audio_toolbox::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern_class!(
14    /// The representation of a provided voice that is available for speech synthesis.
15    ///
16    /// `AVSpeechSynthesisProviderVoice`is distinct from
17    /// `AVSpeechSynthesisVoice,`in that it is a voice provided to the system by an
18    /// `AVSpeechSynthesisProviderAudioUnit.`An
19    /// `AVSpeechSynthesisProviderVoice`will surface as an
20    /// `AVSpeechSynthesisVoice`when using
21    /// `AVSpeechSynthesisVoice.speechVoices().`The quality will always be listed as
22    /// `.enhanced`
23    ///
24    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avspeechsynthesisprovidervoice?language=objc)
25    #[unsafe(super(NSObject))]
26    #[derive(Debug, PartialEq, Eq, Hash)]
27    pub struct AVSpeechSynthesisProviderVoice;
28);
29
30unsafe impl Send for AVSpeechSynthesisProviderVoice {}
31
32unsafe impl Sync for AVSpeechSynthesisProviderVoice {}
33
34extern_conformance!(
35    unsafe impl NSCoding for AVSpeechSynthesisProviderVoice {}
36);
37
38extern_conformance!(
39    unsafe impl NSCopying for AVSpeechSynthesisProviderVoice {}
40);
41
42unsafe impl CopyingHelper for AVSpeechSynthesisProviderVoice {
43    type Result = Self;
44}
45
46extern_conformance!(
47    unsafe impl NSObjectProtocol for AVSpeechSynthesisProviderVoice {}
48);
49
50extern_conformance!(
51    unsafe impl NSSecureCoding for AVSpeechSynthesisProviderVoice {}
52);
53
54impl AVSpeechSynthesisProviderVoice {
55    extern_methods!(
56        /// The localized name of the voice
57        #[unsafe(method(name))]
58        #[unsafe(method_family = none)]
59        pub unsafe fn name(&self) -> Retained<NSString>;
60
61        /// A unique identifier for the voice
62        ///
63        /// The recommended format is reverse domain notation.
64        /// Behavior is undefined if identifiers are not unique for all voices within a given extension.
65        #[unsafe(method(identifier))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn identifier(&self) -> Retained<NSString>;
68
69        /// A set of BCP 47 codes identifying the languages this synthesizer is primarily used for.
70        ///
71        /// These languages are what a user would expect a synthesizer to fully support and be primarily used for.
72        #[unsafe(method(primaryLanguages))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn primaryLanguages(&self) -> Retained<NSArray<NSString>>;
75
76        /// A superset of BCP 47 codes identifying the voice’s supported languages.
77        ///
78        /// These languages are what a user would expect a voice to be able to speak such that if the voice is given a multi-lingual phrase, it would be able to speak the entire phrase without a need to to switch voices. For example, a zh-CN voice could have
79        /// `["zh-CN"]`as its
80        /// `primaryLanguages,`but in
81        /// `supportedLanguages`have
82        /// `["zh-CN","en-US"]`indicating if it received "你好 means Hello", it would be able to speak the entire phrase.
83        #[unsafe(method(supportedLanguages))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn supportedLanguages(&self) -> Retained<NSArray<NSString>>;
86
87        /// The size of the voice (optional)
88        ///
89        /// This reported size of the voice package on disk, in bytes. Defaults to 0.
90        #[unsafe(method(voiceSize))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn voiceSize(&self) -> i64;
93
94        /// Setter for [`voiceSize`][Self::voiceSize].
95        #[unsafe(method(setVoiceSize:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn setVoiceSize(&self, voice_size: i64);
98
99        /// The voice version (optional)
100        ///
101        /// This is an optional property for bookkeeping. This value does not affect system behavior.
102        #[unsafe(method(version))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn version(&self) -> Retained<NSString>;
105
106        /// Setter for [`version`][Self::version].
107        #[unsafe(method(setVersion:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn setVersion(&self, version: &NSString);
110
111        #[cfg(feature = "AVSpeechSynthesis")]
112        /// The gender of the voice (optional)
113        #[unsafe(method(gender))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn gender(&self) -> AVSpeechSynthesisVoiceGender;
116
117        #[cfg(feature = "AVSpeechSynthesis")]
118        /// Setter for [`gender`][Self::gender].
119        #[unsafe(method(setGender:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn setGender(&self, gender: AVSpeechSynthesisVoiceGender);
122
123        /// The age of the voice in years (optional)
124        ///
125        /// This is an optional property that indicates the age of this voice, to be treated as a personality trait. Defaults to 0.
126        #[unsafe(method(age))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn age(&self) -> NSInteger;
129
130        /// Setter for [`age`][Self::age].
131        #[unsafe(method(setAge:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn setAge(&self, age: NSInteger);
134
135        #[unsafe(method(initWithName:identifier:primaryLanguages:supportedLanguages:))]
136        #[unsafe(method_family = init)]
137        pub unsafe fn initWithName_identifier_primaryLanguages_supportedLanguages(
138            this: Allocated<Self>,
139            name: &NSString,
140            identifier: &NSString,
141            primary_languages: &NSArray<NSString>,
142            supported_languages: &NSArray<NSString>,
143        ) -> Retained<Self>;
144
145        #[unsafe(method(init))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
148
149        #[unsafe(method(new))]
150        #[unsafe(method_family = new)]
151        pub unsafe fn new() -> Retained<Self>;
152
153        /// A call that indicates that a new voice or set of voices is available, or no longer available, for system use.
154        ///
155        /// Call this method to indicate to the system that there has been change in the availability of the voices your application is providing to the system.
156        #[unsafe(method(updateSpeechVoices))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn updateSpeechVoices();
159    );
160}
161
162extern_class!(
163    /// An
164    /// `AVSpeechSynthesisProviderRequest`gets delivered to an
165    /// `AVSpeechSynthesisProviderAudioUnit`in order to synthesize audio.
166    /// This is distinct from an
167    /// `AVSpeechUtterance,`which is a generic utterance to be spoken.
168    ///
169    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avspeechsynthesisproviderrequest?language=objc)
170    #[unsafe(super(NSObject))]
171    #[derive(Debug, PartialEq, Eq, Hash)]
172    pub struct AVSpeechSynthesisProviderRequest;
173);
174
175unsafe impl Send for AVSpeechSynthesisProviderRequest {}
176
177unsafe impl Sync for AVSpeechSynthesisProviderRequest {}
178
179extern_conformance!(
180    unsafe impl NSCoding for AVSpeechSynthesisProviderRequest {}
181);
182
183extern_conformance!(
184    unsafe impl NSCopying for AVSpeechSynthesisProviderRequest {}
185);
186
187unsafe impl CopyingHelper for AVSpeechSynthesisProviderRequest {
188    type Result = Self;
189}
190
191extern_conformance!(
192    unsafe impl NSObjectProtocol for AVSpeechSynthesisProviderRequest {}
193);
194
195extern_conformance!(
196    unsafe impl NSSecureCoding for AVSpeechSynthesisProviderRequest {}
197);
198
199impl AVSpeechSynthesisProviderRequest {
200    extern_methods!(
201        /// The SSML representation of the text to be synthesized with the corresponding speech synthesis attributes for customization of pitch, rate, intonation, and more.
202        ///
203        /// See: https://www.w3.org/TR/speech-synthesis11/
204        #[unsafe(method(ssmlRepresentation))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn ssmlRepresentation(&self) -> Retained<NSString>;
207
208        /// The voice to be used in this speech request
209        #[unsafe(method(voice))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn voice(&self) -> Retained<AVSpeechSynthesisProviderVoice>;
212
213        #[unsafe(method(initWithSSMLRepresentation:voice:))]
214        #[unsafe(method_family = init)]
215        pub unsafe fn initWithSSMLRepresentation_voice(
216            this: Allocated<Self>,
217            text: &NSString,
218            voice: &AVSpeechSynthesisProviderVoice,
219        ) -> Retained<Self>;
220
221        #[unsafe(method(init))]
222        #[unsafe(method_family = init)]
223        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
224
225        #[unsafe(method(new))]
226        #[unsafe(method_family = new)]
227        pub unsafe fn new() -> Retained<Self>;
228    );
229}
230
231/// A block of information that is relevant to the generation of speech synthesis.
232///
233/// Parameter `metadata`: An array of speech synthesis metadata
234///
235/// Parameter `speechRequest`: The speech request associated with the metadata
236///
237/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avspeechsynthesisprovideroutputblock?language=objc)
238#[cfg(all(feature = "AVSpeechSynthesis", feature = "block2"))]
239pub type AVSpeechSynthesisProviderOutputBlock = *mut block2::DynBlock<
240    dyn Fn(NonNull<NSArray<AVSpeechSynthesisMarker>>, NonNull<AVSpeechSynthesisProviderRequest>),
241>;
242
243extern_class!(
244    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avspeechsynthesisprovideraudiounit?language=objc)
245    #[unsafe(super(AUAudioUnit, NSObject))]
246    #[derive(Debug, PartialEq, Eq, Hash)]
247    #[cfg(feature = "objc2-audio-toolbox")]
248    #[cfg(not(target_os = "watchos"))]
249    pub struct AVSpeechSynthesisProviderAudioUnit;
250);
251
252#[cfg(feature = "objc2-audio-toolbox")]
253#[cfg(not(target_os = "watchos"))]
254extern_conformance!(
255    unsafe impl NSObjectProtocol for AVSpeechSynthesisProviderAudioUnit {}
256);
257
258#[cfg(feature = "objc2-audio-toolbox")]
259#[cfg(not(target_os = "watchos"))]
260impl AVSpeechSynthesisProviderAudioUnit {
261    extern_methods!(
262        /// Returns the voices this audio unit has available and ready for synthesis.
263        ///
264        /// This method should fetch and return the voices ready to synthesize that a user can select from (usually through Settings).
265        /// Required for speech synthesizer audio unit extensions. An audio unit with a dynamic list of voices can override this property's getter to perform a more complex fetch.
266        #[unsafe(method(speechVoices))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn speechVoices(&self) -> Retained<NSArray<AVSpeechSynthesisProviderVoice>>;
269
270        /// Setter for [`speechVoices`][Self::speechVoices].
271        #[unsafe(method(setSpeechVoices:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn setSpeechVoices(
274            &self,
275            speech_voices: &NSArray<AVSpeechSynthesisProviderVoice>,
276        );
277
278        #[cfg(all(feature = "AVSpeechSynthesis", feature = "block2"))]
279        /// A property set by the host that is called by the audio unit to supply metadata for a speech request.
280        ///
281        /// A synthesizer should call this method when it has produced relevant data to the audio buffers it is sending back to the host. In some cases speech output may be delayed until these markers are delivered. For example, word highlighting depends on marker data from synthesizers in order to properly time which words are highlighted. Many speech synthesizers generate this information on the fly, while synthesizing the audio. The array of markers can reference future audio buffers that have yet to be delivered.
282        ///
283        /// There may be cases in which marker data is not fully known until further audio processing is done. In these cases, and other casers where marker data has changed, calling this block with marker data that contains perviously delivered audio buffer ranges will replace that audio buffer range's marker data, as it will be considered stale.
284        #[unsafe(method(speechSynthesisOutputMetadataBlock))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn speechSynthesisOutputMetadataBlock(
287            &self,
288        ) -> AVSpeechSynthesisProviderOutputBlock;
289
290        #[cfg(all(feature = "AVSpeechSynthesis", feature = "block2"))]
291        /// Setter for [`speechSynthesisOutputMetadataBlock`][Self::speechSynthesisOutputMetadataBlock].
292        #[unsafe(method(setSpeechSynthesisOutputMetadataBlock:))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn setSpeechSynthesisOutputMetadataBlock(
295            &self,
296            speech_synthesis_output_metadata_block: AVSpeechSynthesisProviderOutputBlock,
297        );
298
299        /// Sends a new speech request to be synthesized
300        ///
301        /// Sends a new speech request to the synthesizer to render. When the synthesizer audio unit is finished generating audio buffers for the speech request, it should indicate this within its internal render block,
302        /// `AUInternalRenderBlock,`specifically through the
303        /// `AudioUnitRenderActionFlags`flag
304        /// `kAudioOfflineUnitRenderAction_Complete.`
305        #[unsafe(method(synthesizeSpeechRequest:))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn synthesizeSpeechRequest(
308            &self,
309            speech_request: &AVSpeechSynthesisProviderRequest,
310        );
311
312        /// Informs the audio unit that the speech request job should be discarded.
313        #[unsafe(method(cancelSpeechRequest))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn cancelSpeechRequest(&self);
316    );
317}
318
319/// Methods declared on superclass `AUAudioUnit`.
320#[cfg(feature = "objc2-audio-toolbox")]
321#[cfg(not(target_os = "watchos"))]
322impl AVSpeechSynthesisProviderAudioUnit {
323    extern_methods!(
324        #[unsafe(method(init))]
325        #[unsafe(method_family = init)]
326        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
327
328        /// Designated initializer.
329        ///
330        /// Parameter `componentDescription`: A single AUAudioUnit subclass may implement multiple audio units, for example, an effect
331        /// that can also function as a generator, or a cluster of related effects. The component
332        /// description specifies the component which was instantiated.
333        ///
334        /// Parameter `options`: Options for loading the unit in-process or out-of-process.
335        ///
336        /// Parameter `outError`: Returned in the event of failure.
337        #[unsafe(method(initWithComponentDescription:options:error:_))]
338        #[unsafe(method_family = init)]
339        pub unsafe fn initWithComponentDescription_options_error(
340            this: Allocated<Self>,
341            component_description: AudioComponentDescription,
342            options: AudioComponentInstantiationOptions,
343        ) -> Result<Retained<Self>, Retained<NSError>>;
344
345        /// Convenience initializer (omits options).
346        #[unsafe(method(initWithComponentDescription:error:_))]
347        #[unsafe(method_family = init)]
348        pub unsafe fn initWithComponentDescription_error(
349            this: Allocated<Self>,
350            component_description: AudioComponentDescription,
351        ) -> Result<Retained<Self>, Retained<NSError>>;
352    );
353}
354
355/// Methods declared on superclass `NSObject`.
356#[cfg(feature = "objc2-audio-toolbox")]
357#[cfg(not(target_os = "watchos"))]
358impl AVSpeechSynthesisProviderAudioUnit {
359    extern_methods!(
360        #[unsafe(method(new))]
361        #[unsafe(method_family = new)]
362        pub unsafe fn new() -> Retained<Self>;
363    );
364}