objc2_speech/generated/SFTranscriptionSegment.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11 /// A discrete part of an entire transcription, as identified by the speech recognizer.
12 ///
13 /// Use ``SFTranscriptionSegment`` to get details about a part of an overall ``SFTranscription``. An ``SFTranscriptionSegment`` represents an utterance, which is a vocalized word or group of words that represent a single meaning to the speech recognizer (``SFSpeechRecognizer``).
14 ///
15 /// You don't create transcription object segments directly. Instead, you access them from a transcription's ``SFTranscription/segments`` property.
16 ///
17 /// A transcription segment includes the following information:
18 ///
19 /// - The text of the utterance, plus any alternative interpretations of the spoken word.
20 /// - The character range of the segment within the ``SFTranscription/formattedString`` of its parent ``SFTranscription``.
21 /// - A ``confidence`` value, indicating how likely it is that the specified string matches the audible speech.
22 /// - A ``timestamp`` and ``duration`` value, indicating the position of the segment within the provided audio stream.
23 ///
24 /// See also [Apple's documentation](https://developer.apple.com/documentation/speech/sftranscriptionsegment?language=objc)
25 #[unsafe(super(NSObject))]
26 #[derive(Debug, PartialEq, Eq, Hash)]
27 pub struct SFTranscriptionSegment;
28);
29
30extern_conformance!(
31 unsafe impl NSCoding for SFTranscriptionSegment {}
32);
33
34extern_conformance!(
35 unsafe impl NSCopying for SFTranscriptionSegment {}
36);
37
38unsafe impl CopyingHelper for SFTranscriptionSegment {
39 type Result = Self;
40}
41
42extern_conformance!(
43 unsafe impl NSObjectProtocol for SFTranscriptionSegment {}
44);
45
46extern_conformance!(
47 unsafe impl NSSecureCoding for SFTranscriptionSegment {}
48);
49
50impl SFTranscriptionSegment {
51 extern_methods!(
52 /// The string representation of the utterance in the transcription segment.
53 #[unsafe(method(substring))]
54 #[unsafe(method_family = none)]
55 pub unsafe fn substring(&self) -> Retained<NSString>;
56
57 /// The range information for the transcription segment's substring, relative to the overall transcription.
58 ///
59 /// Use the range information to find the position of the segment within the ``SFTranscription/formattedString`` property of the ``SFTranscription`` object containing this segment.
60 #[unsafe(method(substringRange))]
61 #[unsafe(method_family = none)]
62 pub unsafe fn substringRange(&self) -> NSRange;
63
64 /// The start time of the segment in the processed audio stream.
65 ///
66 /// The ``timestamp`` is the number of seconds between the beginning of the audio content and when the user spoke the word represented by the segment. For example, if the user said the word "time" one second into the transcription "What time is it", the timestamp would be equal to `1.0`.
67 #[unsafe(method(timestamp))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn timestamp(&self) -> NSTimeInterval;
70
71 /// The number of seconds it took for the user to speak the utterance represented by the segment.
72 ///
73 /// The ``duration`` contains the number of seconds it took for the user to speak the one or more words (utterance) represented by the segment. For example, the ``SFSpeechRecognizer`` sets ``duration`` to `0.6` if the user took `0.6` seconds to say `“time”` in the transcription of `“What time is it?"`.
74 #[unsafe(method(duration))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn duration(&self) -> NSTimeInterval;
77
78 /// The level of confidence the speech recognizer has in its recognition of the speech transcribed for the segment.
79 ///
80 /// This property reflects the overall confidence in the recognition of the entire phrase. The value is `0` if there was no recognition, and it is closer to `1` when there is a high certainty that a transcription matches the user's speech exactly. For example, a confidence value of `0.94` represents a very high confidence level, and is more likely to be correct than a transcription with a confidence value of `0.72`.
81 #[unsafe(method(confidence))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn confidence(&self) -> c_float;
84
85 /// An array of alternate interpretations of the utterance in the transcription segment.
86 #[unsafe(method(alternativeSubstrings))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn alternativeSubstrings(&self) -> Retained<NSArray<NSString>>;
89
90 #[cfg(feature = "SFVoiceAnalytics")]
91 /// An analysis of the transcription segment's vocal properties.
92 #[deprecated = "voiceAnalytics is moved to SFSpeechRecognitionMetadata"]
93 #[unsafe(method(voiceAnalytics))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn voiceAnalytics(&self) -> Option<Retained<SFVoiceAnalytics>>;
96 );
97}
98
99/// Methods declared on superclass `NSObject`.
100impl SFTranscriptionSegment {
101 extern_methods!(
102 #[unsafe(method(init))]
103 #[unsafe(method_family = init)]
104 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
105
106 #[unsafe(method(new))]
107 #[unsafe(method_family = new)]
108 pub unsafe fn new() -> Retained<Self>;
109 );
110}