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