// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

edition = "2023";

package optimization_guide.proto;

option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.features.proto";

option java_outer_classname = "ReadAloudSynthesizeProto";

// DO NOT EDIT THIS FILE DIRECTLY!
//
// This file is generated in g3 and then synced to Chrome. Instead, please refer to
// http://go/chrome-mqls-onboarding (Google-internal link), and then changes will
// be synced with Chrome automatically.

// Wrapper message for MQLS (Model Quality Logging Service) quality evaluation
// logging.
message ReadAloudSynthesizeLoggingData {
  // Request for speech synthesis.
  ReadAloudSynthesizeRequest request = 1 [features = { field_presence: EXPLICIT }];

  // Response from speech synthesis.
  ReadAloudSynthesizeResponse response = 2 [features = { field_presence: EXPLICIT }];
}

// Request message for synthesizing text speech audio in Read Aloud.
message ReadAloudSynthesizeRequest {
  // Text snippet or chunk to be synthesized into audio.
  string text_chunk = 1 [features = { field_presence: EXPLICIT }];

  // Identifier of the specific voice model requested for speech synthesis.
  string voice_id = 2 [features = { field_presence: EXPLICIT }];

  // Target language code for speech synthesis, formatted as an IETF BCP-47 tag
  // (e.g., "en-US").
  string language_code = 3 [features = { field_presence: EXPLICIT }];
}

// Response message containing synthesized speech audio bytes and word-level UI
// sync timings.
message ReadAloudSynthesizeResponse {
  // Synthesized audio payload.
  bytes audio_bytes = 1 [features = { field_presence: EXPLICIT }];

  // Timing metadata for each spoken word, used for UI synchronization and
  // highlighting.
  repeated WordTiming timings = 2;
}

// Timing offset details for an individual word in the synthesized audio stream.
message WordTiming {
  // Character start index of the word within the text chunk.
  int32 start_offset = 1 [features = { field_presence: EXPLICIT }];

  // Character end index (exclusive) of the word within the text chunk.
  int32 end_offset = 2 [features = { field_presence: EXPLICIT }];

  // Time offset in milliseconds from the start of the audio stream when this
  // word begins speaking.
  int32 time_offset_ms = 3 [features = { field_presence: EXPLICIT }];
}
