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        ///
58        /// This property is not atomic.
59        ///
60        /// # Safety
61        ///
62        /// This might not be thread-safe.
63        #[unsafe(method(name))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn name(&self) -> Retained<NSString>;
66
67        /// A unique identifier for the voice
68        ///
69        /// The recommended format is reverse domain notation.
70        /// Behavior is undefined if identifiers are not unique for all voices within a given extension.
71        ///
72        /// This property is not atomic.
73        ///
74        /// # Safety
75        ///
76        /// This might not be thread-safe.
77        #[unsafe(method(identifier))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn identifier(&self) -> Retained<NSString>;
80
81        /// A set of BCP 47 codes identifying the languages this synthesizer is primarily used for.
82        ///
83        /// These languages are what a user would expect a synthesizer to fully support and be primarily used for.
84        ///
85        /// This property is not atomic.
86        ///
87        /// # Safety
88        ///
89        /// This might not be thread-safe.
90        #[unsafe(method(primaryLanguages))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn primaryLanguages(&self) -> Retained<NSArray<NSString>>;
93
94        /// A superset of BCP 47 codes identifying the voice’s supported languages.
95        ///
96        /// 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
97        /// `["zh-CN"]`as its
98        /// `primaryLanguages,`but in
99        /// `supportedLanguages`have
100        /// `["zh-CN","en-US"]`indicating if it received "你好 means Hello", it would be able to speak the entire phrase.
101        ///
102        /// This property is not atomic.
103        ///
104        /// # Safety
105        ///
106        /// This might not be thread-safe.
107        #[unsafe(method(supportedLanguages))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn supportedLanguages(&self) -> Retained<NSArray<NSString>>;
110
111        /// The size of the voice (optional)
112        ///
113        /// This reported size of the voice package on disk, in bytes. Defaults to 0.
114        ///
115        /// This property is not atomic.
116        ///
117        /// # Safety
118        ///
119        /// This might not be thread-safe.
120        #[unsafe(method(voiceSize))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn voiceSize(&self) -> i64;
123
124        /// Setter for [`voiceSize`][Self::voiceSize].
125        ///
126        /// # Safety
127        ///
128        /// This might not be thread-safe.
129        #[unsafe(method(setVoiceSize:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn setVoiceSize(&self, voice_size: i64);
132
133        /// The voice version (optional)
134        ///
135        /// This is an optional property for bookkeeping. This value does not affect system behavior.
136        ///
137        /// This property is not atomic.
138        ///
139        /// # Safety
140        ///
141        /// This might not be thread-safe.
142        #[unsafe(method(version))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn version(&self) -> Retained<NSString>;
145
146        /// Setter for [`version`][Self::version].
147        ///
148        /// # Safety
149        ///
150        /// This might not be thread-safe.
151        #[unsafe(method(setVersion:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setVersion(&self, version: &NSString);
154
155        #[cfg(feature = "AVSpeechSynthesis")]
156        /// The gender of the voice (optional)
157        ///
158        /// This property is not atomic.
159        ///
160        /// # Safety
161        ///
162        /// This might not be thread-safe.
163        #[unsafe(method(gender))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn gender(&self) -> AVSpeechSynthesisVoiceGender;
166
167        #[cfg(feature = "AVSpeechSynthesis")]
168        /// Setter for [`gender`][Self::gender].
169        ///
170        /// # Safety
171        ///
172        /// This might not be thread-safe.
173        #[unsafe(method(setGender:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setGender(&self, gender: AVSpeechSynthesisVoiceGender);
176
177        /// The age of the voice in years (optional)
178        ///
179        /// This is an optional property that indicates the age of this voice, to be treated as a personality trait. Defaults to 0.
180        ///
181        /// This property is not atomic.
182        ///
183        /// # Safety
184        ///
185        /// This might not be thread-safe.
186        #[unsafe(method(age))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn age(&self) -> NSInteger;
189
190        /// Setter for [`age`][Self::age].
191        ///
192        /// # Safety
193        ///
194        /// This might not be thread-safe.
195        #[unsafe(method(setAge:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setAge(&self, age: NSInteger);
198
199        #[unsafe(method(initWithName:identifier:primaryLanguages:supportedLanguages:))]
200        #[unsafe(method_family = init)]
201        pub unsafe fn initWithName_identifier_primaryLanguages_supportedLanguages(
202            this: Allocated<Self>,
203            name: &NSString,
204            identifier: &NSString,
205            primary_languages: &NSArray<NSString>,
206            supported_languages: &NSArray<NSString>,
207        ) -> Retained<Self>;
208
209        #[unsafe(method(init))]
210        #[unsafe(method_family = init)]
211        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
212
213        #[unsafe(method(new))]
214        #[unsafe(method_family = new)]
215        pub unsafe fn new() -> Retained<Self>;
216
217        /// A call that indicates that a new voice or set of voices is available, or no longer available, for system use.
218        ///
219        /// 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.
220        #[unsafe(method(updateSpeechVoices))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn updateSpeechVoices();
223    );
224}
225
226extern_class!(
227    /// An
228    /// `AVSpeechSynthesisProviderRequest`gets delivered to an
229    /// `AVSpeechSynthesisProviderAudioUnit`in order to synthesize audio.
230    /// This is distinct from an
231    /// `AVSpeechUtterance,`which is a generic utterance to be spoken.
232    ///
233    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avspeechsynthesisproviderrequest?language=objc)
234    #[unsafe(super(NSObject))]
235    #[derive(Debug, PartialEq, Eq, Hash)]
236    pub struct AVSpeechSynthesisProviderRequest;
237);
238
239unsafe impl Send for AVSpeechSynthesisProviderRequest {}
240
241unsafe impl Sync for AVSpeechSynthesisProviderRequest {}
242
243extern_conformance!(
244    unsafe impl NSCoding for AVSpeechSynthesisProviderRequest {}
245);
246
247extern_conformance!(
248    unsafe impl NSCopying for AVSpeechSynthesisProviderRequest {}
249);
250
251unsafe impl CopyingHelper for AVSpeechSynthesisProviderRequest {
252    type Result = Self;
253}
254
255extern_conformance!(
256    unsafe impl NSObjectProtocol for AVSpeechSynthesisProviderRequest {}
257);
258
259extern_conformance!(
260    unsafe impl NSSecureCoding for AVSpeechSynthesisProviderRequest {}
261);
262
263impl AVSpeechSynthesisProviderRequest {
264    extern_methods!(
265        /// The SSML representation of the text to be synthesized with the corresponding speech synthesis attributes for customization of pitch, rate, intonation, and more.
266        ///
267        /// See: https://www.w3.org/TR/speech-synthesis11/
268        ///
269        /// This property is not atomic.
270        ///
271        /// # Safety
272        ///
273        /// This might not be thread-safe.
274        #[unsafe(method(ssmlRepresentation))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn ssmlRepresentation(&self) -> Retained<NSString>;
277
278        /// The voice to be used in this speech request
279        ///
280        /// This property is not atomic.
281        ///
282        /// # Safety
283        ///
284        /// This might not be thread-safe.
285        #[unsafe(method(voice))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn voice(&self) -> Retained<AVSpeechSynthesisProviderVoice>;
288
289        #[unsafe(method(initWithSSMLRepresentation:voice:))]
290        #[unsafe(method_family = init)]
291        pub unsafe fn initWithSSMLRepresentation_voice(
292            this: Allocated<Self>,
293            text: &NSString,
294            voice: &AVSpeechSynthesisProviderVoice,
295        ) -> Retained<Self>;
296
297        #[unsafe(method(init))]
298        #[unsafe(method_family = init)]
299        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
300
301        #[unsafe(method(new))]
302        #[unsafe(method_family = new)]
303        pub unsafe fn new() -> Retained<Self>;
304    );
305}
306
307/// A block of information that is relevant to the generation of speech synthesis.
308///
309/// Parameter `metadata`: An array of speech synthesis metadata
310///
311/// Parameter `speechRequest`: The speech request associated with the metadata
312///
313/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avspeechsynthesisprovideroutputblock?language=objc)
314#[cfg(all(feature = "AVSpeechSynthesis", feature = "block2"))]
315pub type AVSpeechSynthesisProviderOutputBlock = *mut block2::DynBlock<
316    dyn Fn(NonNull<NSArray<AVSpeechSynthesisMarker>>, NonNull<AVSpeechSynthesisProviderRequest>),
317>;
318
319extern_class!(
320    /// [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avspeechsynthesisprovideraudiounit?language=objc)
321    #[unsafe(super(AUAudioUnit, NSObject))]
322    #[derive(Debug, PartialEq, Eq, Hash)]
323    #[cfg(feature = "objc2-audio-toolbox")]
324    #[cfg(not(target_os = "watchos"))]
325    pub struct AVSpeechSynthesisProviderAudioUnit;
326);
327
328#[cfg(feature = "objc2-audio-toolbox")]
329#[cfg(not(target_os = "watchos"))]
330extern_conformance!(
331    unsafe impl NSObjectProtocol for AVSpeechSynthesisProviderAudioUnit {}
332);
333
334#[cfg(feature = "objc2-audio-toolbox")]
335#[cfg(not(target_os = "watchos"))]
336impl AVSpeechSynthesisProviderAudioUnit {
337    extern_methods!(
338        /// Returns the voices this audio unit has available and ready for synthesis.
339        ///
340        /// This method should fetch and return the voices ready to synthesize that a user can select from (usually through Settings).
341        /// 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.
342        #[unsafe(method(speechVoices))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn speechVoices(&self) -> Retained<NSArray<AVSpeechSynthesisProviderVoice>>;
345
346        /// Setter for [`speechVoices`][Self::speechVoices].
347        #[unsafe(method(setSpeechVoices:))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn setSpeechVoices(
350            &self,
351            speech_voices: &NSArray<AVSpeechSynthesisProviderVoice>,
352        );
353
354        #[cfg(all(feature = "AVSpeechSynthesis", feature = "block2"))]
355        /// A property set by the host that is called by the audio unit to supply metadata for a speech request.
356        ///
357        /// 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.
358        ///
359        /// 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.
360        ///
361        /// # Safety
362        ///
363        /// - The returned block's argument 1 must be a valid pointer.
364        /// - The returned block's argument 2 must be a valid pointer.
365        #[unsafe(method(speechSynthesisOutputMetadataBlock))]
366        #[unsafe(method_family = none)]
367        pub unsafe fn speechSynthesisOutputMetadataBlock(
368            &self,
369        ) -> AVSpeechSynthesisProviderOutputBlock;
370
371        #[cfg(all(feature = "AVSpeechSynthesis", feature = "block2"))]
372        /// Setter for [`speechSynthesisOutputMetadataBlock`][Self::speechSynthesisOutputMetadataBlock].
373        ///
374        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
375        ///
376        /// # Safety
377        ///
378        /// `speech_synthesis_output_metadata_block` must be a valid pointer or null.
379        #[unsafe(method(setSpeechSynthesisOutputMetadataBlock:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn setSpeechSynthesisOutputMetadataBlock(
382            &self,
383            speech_synthesis_output_metadata_block: AVSpeechSynthesisProviderOutputBlock,
384        );
385
386        /// Sends a new speech request to be synthesized
387        ///
388        /// 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,
389        /// `AUInternalRenderBlock,`specifically through the
390        /// `AudioUnitRenderActionFlags`flag
391        /// `kAudioOfflineUnitRenderAction_Complete.`
392        #[unsafe(method(synthesizeSpeechRequest:))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn synthesizeSpeechRequest(
395            &self,
396            speech_request: &AVSpeechSynthesisProviderRequest,
397        );
398
399        /// Informs the audio unit that the speech request job should be discarded.
400        #[unsafe(method(cancelSpeechRequest))]
401        #[unsafe(method_family = none)]
402        pub unsafe fn cancelSpeechRequest(&self);
403    );
404}
405
406/// Methods declared on superclass `AUAudioUnit`.
407#[cfg(feature = "objc2-audio-toolbox")]
408#[cfg(not(target_os = "watchos"))]
409impl AVSpeechSynthesisProviderAudioUnit {
410    extern_methods!(
411        #[unsafe(method(init))]
412        #[unsafe(method_family = init)]
413        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
414
415        /// Designated initializer.
416        ///
417        /// Parameter `componentDescription`: A single AUAudioUnit subclass may implement multiple audio units, for example, an effect
418        /// that can also function as a generator, or a cluster of related effects. The component
419        /// description specifies the component which was instantiated.
420        ///
421        /// Parameter `options`: Options for loading the unit in-process or out-of-process.
422        ///
423        /// Parameter `outError`: Returned in the event of failure.
424        #[unsafe(method(initWithComponentDescription:options:error:_))]
425        #[unsafe(method_family = init)]
426        pub unsafe fn initWithComponentDescription_options_error(
427            this: Allocated<Self>,
428            component_description: AudioComponentDescription,
429            options: AudioComponentInstantiationOptions,
430        ) -> Result<Retained<Self>, Retained<NSError>>;
431
432        /// Convenience initializer (omits options).
433        #[unsafe(method(initWithComponentDescription:error:_))]
434        #[unsafe(method_family = init)]
435        pub unsafe fn initWithComponentDescription_error(
436            this: Allocated<Self>,
437            component_description: AudioComponentDescription,
438        ) -> Result<Retained<Self>, Retained<NSError>>;
439    );
440}
441
442/// Methods declared on superclass `NSObject`.
443#[cfg(feature = "objc2-audio-toolbox")]
444#[cfg(not(target_os = "watchos"))]
445impl AVSpeechSynthesisProviderAudioUnit {
446    extern_methods!(
447        #[unsafe(method(new))]
448        #[unsafe(method_family = new)]
449        pub unsafe fn new() -> Retained<Self>;
450    );
451}