910e62b5创建于 1月15日历史提交
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file was generated by:
//   tools/json_schema_compiler/compiler.py.
// NOTE: The format of types has changed. 'FooType' is now
//   'chrome.ttsEngine.FooType'.
// Please run the closure compiler before committing changes.
// See
// https://chromium.googlesource.com/chromium/src/+/main/docs/closure_compilation.md

/**
 * @fileoverview Externs generated from namespace: ttsEngine
 * @externs
 */

/** @const */
chrome.ttsEngine = {};

/**
 * @enum {string}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-TtsClientSource
 */
chrome.ttsEngine.TtsClientSource = {
  CHROMEFEATURE: 'chromefeature',
  EXTENSION: 'extension',
};

/**
 * Identifier for the client requesting status.
 * @typedef {{
 *   id: string,
 *   source: !chrome.ttsEngine.TtsClientSource
 * }}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-TtsClient
 */
chrome.ttsEngine.TtsClient;

/**
 * @enum {string}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-VoiceGender
 */
chrome.ttsEngine.VoiceGender = {
  MALE: 'male',
  FEMALE: 'female',
};

/**
 * Options for removing a given language.
 * @typedef {{
 *   uninstallImmediately: boolean
 * }}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-LanguageUninstallOptions
 */
chrome.ttsEngine.LanguageUninstallOptions;

/**
 * @enum {string}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-LanguageInstallStatus
 */
chrome.ttsEngine.LanguageInstallStatus = {
  NOT_INSTALLED: 'notInstalled',
  INSTALLING: 'installing',
  INSTALLED: 'installed',
  FAILED: 'failed',
};

/**
 * Install status of a language.
 * @typedef {{
 *   lang: string,
 *   installStatus: !chrome.ttsEngine.LanguageInstallStatus,
 *   error: (string|undefined)
 * }}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-LanguageStatus
 */
chrome.ttsEngine.LanguageStatus;

/**
 * Options specified to the tts.speak() method.
 * @typedef {{
 *   voiceName: (string|undefined),
 *   lang: (string|undefined),
 *   gender: (!chrome.ttsEngine.VoiceGender|undefined),
 *   rate: (number|undefined),
 *   pitch: (number|undefined),
 *   volume: (number|undefined)
 * }}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-SpeakOptions
 */
chrome.ttsEngine.SpeakOptions;

/**
 * Contains the audio stream format expected to be produced by an engine.
 * @typedef {{
 *   sampleRate: number,
 *   bufferSize: number
 * }}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-AudioStreamOptions
 */
chrome.ttsEngine.AudioStreamOptions;

/**
 * Parameters containing an audio buffer and associated data.
 * @typedef {{
 *   audioBuffer: ArrayBuffer,
 *   charIndex: (number|undefined),
 *   isLastBuffer: (boolean|undefined)
 * }}
 * @see https://developer.chrome.com/extensions/ttsEngine#type-AudioBuffer
 */
chrome.ttsEngine.AudioBuffer;

/**
 * Called by an engine to update its list of voices. This list overrides any
 * voices declared in this extension's manifest.
 * @param {!Array<!chrome.ttsEngine.tts.TtsVoice>} voices Array of
 *     $(ref:tts.TtsVoice) objects representing the available voices for speech
 *     synthesis.
 * @see https://developer.chrome.com/extensions/ttsEngine#method-updateVoices
 */
chrome.ttsEngine.updateVoices = function(voices) {};

/**
 * Routes a TTS event from a speech engine to a client.
 * @param {number} requestId
 * @param {!chrome.ttsEngine.tts.TtsEvent} event The update event from the
 *     text-to-speech engine indicating the status of this utterance.
 * @see https://developer.chrome.com/extensions/ttsEngine#method-sendTtsEvent
 */
chrome.ttsEngine.sendTtsEvent = function(requestId, event) {};

/**
 * Routes TTS audio from a speech engine to a client.
 * @param {number} requestId
 * @param {!chrome.ttsEngine.AudioBuffer} audio An audio buffer from the
 *     text-to-speech engine.
 * @see https://developer.chrome.com/extensions/ttsEngine#method-sendTtsAudio
 */
chrome.ttsEngine.sendTtsAudio = function(requestId, audio) {};

/**
 * Called by an engine when a language install is attempted, and when a language
 * is uninstalled. Also called in response to a status request from a client.
 * When a voice is installed or uninstalled, the engine should also call
 * ttsEngine.updateVoices to register the voice.
 * @param {!chrome.ttsEngine.LanguageStatus} status The install status of the
 *     language.
 * @see https://developer.chrome.com/extensions/ttsEngine#method-updateLanguage
 */
chrome.ttsEngine.updateLanguage = function(status) {};

/**
 * Called when the user makes a call to tts.speak() and one of the voices from
 * this extension's manifest is the first to match the options object.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onSpeak
 */
chrome.ttsEngine.onSpeak;

/**
 * Called when the user makes a call to tts.speak() and one of the voices from
 * this extension's manifest is the first to match the options object. Differs
 * from ttsEngine.onSpeak in that Chrome provides audio playback services and
 * handles dispatching tts events.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onSpeakWithAudioStream
 */
chrome.ttsEngine.onSpeakWithAudioStream;

/**
 * Fired when a call is made to tts.stop and this extension may be in the middle
 * of speaking. If an extension receives a call to onStop and speech is already
 * stopped, it should do nothing (not raise an error). If speech is in the
 * paused state, this should cancel the paused state.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onStop
 */
chrome.ttsEngine.onStop;

/**
 * Optional: if an engine supports the pause event, it should pause the current
 * utterance being spoken, if any, until it receives a resume event or stop
 * event. Note that a stop event should also clear the paused state.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onPause
 */
chrome.ttsEngine.onPause;

/**
 * Optional: if an engine supports the pause event, it should also support the
 * resume event, to continue speaking the current utterance, if any. Note that a
 * stop event should also clear the paused state.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onResume
 */
chrome.ttsEngine.onResume;

/**
 * Fired when a TTS client requests to install a new language. The engine should
 * attempt to download and install the language, and call
 * ttsEngine.updateLanguage with the result. On success, the engine should also
 * call ttsEngine.updateVoices to register the newly available voices.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onInstallLanguageRequest
 */
chrome.ttsEngine.onInstallLanguageRequest;

/**
 * Fired when a TTS client indicates a language is no longer needed.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onUninstallLanguageRequest
 */
chrome.ttsEngine.onUninstallLanguageRequest;

/**
 * Fired when a TTS client requests the install status of a language.
 * @type {!ChromeEvent}
 * @see https://developer.chrome.com/extensions/ttsEngine#event-onLanguageStatusRequest
 */
chrome.ttsEngine.onLanguageStatusRequest;