Contents

rangeOfAudioTimeRangeAttributes(intersecting:)

Returns the range of the attributed string that is within the given time range.

Declaration

func rangeOfAudioTimeRangeAttributes(intersecting timeRange: CMTimeRange) -> Range<AttributedString.Index>?

Parameters

  • timeRange:

    An audio time range.

Return Value

The range of the string’s intersecting text, or nil if the string has no intersecting text.

Discussion

The method compares the given time range against the AttributeScopes.SpeechAttributes.TimeRangeAttribute attributes of the string. The time ranges in the string should be in ascending order, but not necessarily contiguous, and the string can include runs without a time range attribute.

You can use this method to help update an attributed string that tracks the volatile or finalized results of a SpeechTranscriber or DictationTranscriber module.