objc2-speech 0.3.2

Bindings to the Speech framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// The value of a voice analysis metric.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/speech/sfacousticfeature?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SFAcousticFeature;
);

extern_conformance!(
    unsafe impl NSCoding for SFAcousticFeature {}
);

extern_conformance!(
    unsafe impl NSCopying for SFAcousticFeature {}
);

unsafe impl CopyingHelper for SFAcousticFeature {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for SFAcousticFeature {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for SFAcousticFeature {}
);

impl SFAcousticFeature {
    extern_methods!(
        /// An array of feature values, one value per audio frame, corresponding to a transcript segment of recorded audio.
        #[unsafe(method(acousticFeatureValuePerFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn acousticFeatureValuePerFrame(&self) -> Retained<NSArray<NSNumber>>;

        /// The duration of the audio frame.
        #[unsafe(method(frameDuration))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameDuration(&self) -> NSTimeInterval;
    );
}

/// Methods declared on superclass `NSObject`.
impl SFAcousticFeature {
    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 collection of vocal analysis metrics.
    ///
    /// Use an ``SFAcousticFeature`` object to access the `SFVoiceAnalytics` insights. Voice analytics include the following features:
    ///
    /// - Use ``jitter`` to measure how pitch varies in audio.
    /// - Use ``shimmer`` to measure how amplitude varies in audio.
    /// - Use ``pitch`` to measure the highness and lowness of the tone.
    /// - Use ``voicing`` to identify voiced regions in speech.
    ///
    /// These results are part of the ``SFTranscriptionSegment`` object and are available when the system sends the ``SFSpeechRecognitionResult/isFinal`` flag.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/speech/sfvoiceanalytics?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SFVoiceAnalytics;
);

extern_conformance!(
    unsafe impl NSCoding for SFVoiceAnalytics {}
);

extern_conformance!(
    unsafe impl NSCopying for SFVoiceAnalytics {}
);

unsafe impl CopyingHelper for SFVoiceAnalytics {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for SFVoiceAnalytics {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for SFVoiceAnalytics {}
);

impl SFVoiceAnalytics {
    extern_methods!(
        /// The variation in pitch in each frame of a transcription segment, expressed as a percentage of the frame's fundamental frequency.
        #[unsafe(method(jitter))]
        #[unsafe(method_family = none)]
        pub unsafe fn jitter(&self) -> Retained<SFAcousticFeature>;

        /// The variation in vocal volume stability (amplitude) in each frame of a transcription segment, expressed in decibels.
        #[unsafe(method(shimmer))]
        #[unsafe(method_family = none)]
        pub unsafe fn shimmer(&self) -> Retained<SFAcousticFeature>;

        /// The highness or lowness of the tone (fundamental frequency) in each frame of a transcription segment, expressed as a logarithm.
        ///
        /// The value is a logarithm (base `e`) of the normalized pitch estimate for each frame.
        #[unsafe(method(pitch))]
        #[unsafe(method_family = none)]
        pub unsafe fn pitch(&self) -> Retained<SFAcousticFeature>;

        /// The likelihood of a voice in each frame of a transcription segment.
        ///
        /// The `voicing` value is expressed as a probability in the range `[0.0, 1.0]`.
        #[unsafe(method(voicing))]
        #[unsafe(method_family = none)]
        pub unsafe fn voicing(&self) -> Retained<SFAcousticFeature>;
    );
}

/// Methods declared on superclass `NSObject`.
impl SFVoiceAnalytics {
    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>;
    );
}