// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation
import GoogleCloudWkt

/// Word-specific information for recognized words.
public struct WordInfo: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Time offset relative to the beginning of the audio,
  /// and corresponding to the start of the spoken word.
  /// This field is only set if
  /// [enable_word_time_offsets][google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]
  /// is `true` and only in the top hypothesis. This is an experimental feature
  /// and the accuracy of the time offset can vary.
  ///
  /// [google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]: <doc:RecognitionFeatures/enableWordTimeOffsets>
  public var startOffset: GoogleCloudWkt.Duration? = nil

  /// Time offset relative to the beginning of the audio,
  /// and corresponding to the end of the spoken word.
  /// This field is only set if
  /// [enable_word_time_offsets][google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]
  /// is `true` and only in the top hypothesis. This is an experimental feature
  /// and the accuracy of the time offset can vary.
  ///
  /// [google.cloud.speech.v2.RecognitionFeatures.enable_word_time_offsets]: <doc:RecognitionFeatures/enableWordTimeOffsets>
  public var endOffset: GoogleCloudWkt.Duration? = nil

  /// The word corresponding to this set of information.
  public var word: Swift.String = Swift.String()

  /// The confidence estimate between 0.0 and 1.0. A higher number
  /// indicates an estimated greater likelihood that the recognized words are
  /// correct. This field is set only for the top alternative of a non-streaming
  /// result or, of a streaming result where
  /// [is_final][google.cloud.speech.v2.StreamingRecognitionResult.is_final] is
  /// set to `true`. This field is not guaranteed to be accurate and users should
  /// not rely on it to be always provided. The default of 0.0 is a sentinel
  /// value indicating `confidence` was not set.
  ///
  /// [google.cloud.speech.v2.StreamingRecognitionResult.is_final]: <doc:StreamingRecognitionResult/isFinal>
  public var confidence: Swift.Float = Swift.Float()

  /// A distinct label is assigned for every speaker within the audio. This field
  /// specifies which one of those speakers was detected to have spoken this
  /// word. `speaker_label` is set if
  /// [SpeakerDiarizationConfig][google.cloud.speech.v2.SpeakerDiarizationConfig]
  /// is given and only in the top alternative.
  ///
  /// [google.cloud.speech.v2.SpeakerDiarizationConfig]: <doc:SpeakerDiarizationConfig>
  public var speakerLabel: Swift.String = Swift.String()

  /// Initialize a new instance of `WordInfo`.
  public init() {}

  /// Use `config` to return a new instance of this object, with some fields updated.
  ///
  /// Commonly used to initialize the value, for example:
  ///
  /// ```
  /// let value = WordInfo().with { $0.startOffset = ... }
  /// ```
  public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
    var copy = self
    try config(&copy)
    return copy
  }

  public static var _anyTypeUrl: Swift.String {
    return "type.googleapis.com/google.cloud.speech.v2.WordInfo"
  }
  public init(fromAny any: GoogleCloudWkt.`Any`) throws {
    self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
  }
  public func _pack() throws -> GoogleCloudWkt.Struct {
    return try GoogleCloudWkt._slowAnySerialize(message: self)
  }
}
