@google-cloud/text-to-speech
Version:
Cloud Text-to-Speech API client for Node.js
852 lines (779 loc) • 1.95 MB
JavaScript
// Copyright 2025 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
//
// http://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.
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd)
define(["protobufjs/minimal"], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
module.exports = factory(require("google-gax/build/src/protobuf").protobufMinimal);
})(this, function($protobuf) {
"use strict";
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots._google_cloud_text_to_speech_protos || ($protobuf.roots._google_cloud_text_to_speech_protos = {});
$root.google = (function() {
/**
* Namespace google.
* @exports google
* @namespace
*/
var google = {};
google.cloud = (function() {
/**
* Namespace cloud.
* @memberof google
* @namespace
*/
var cloud = {};
cloud.texttospeech = (function() {
/**
* Namespace texttospeech.
* @memberof google.cloud
* @namespace
*/
var texttospeech = {};
texttospeech.v1 = (function() {
/**
* Namespace v1.
* @memberof google.cloud.texttospeech
* @namespace
*/
var v1 = {};
v1.TextToSpeech = (function() {
/**
* Constructs a new TextToSpeech service.
* @memberof google.cloud.texttospeech.v1
* @classdesc Represents a TextToSpeech
* @extends $protobuf.rpc.Service
* @constructor
* @param {$protobuf.RPCImpl} rpcImpl RPC implementation
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
*/
function TextToSpeech(rpcImpl, requestDelimited, responseDelimited) {
$protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited);
}
(TextToSpeech.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = TextToSpeech;
/**
* Creates new TextToSpeech service using the specified rpc implementation.
* @function create
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @static
* @param {$protobuf.RPCImpl} rpcImpl RPC implementation
* @param {boolean} [requestDelimited=false] Whether requests are length-delimited
* @param {boolean} [responseDelimited=false] Whether responses are length-delimited
* @returns {TextToSpeech} RPC service. Useful where requests and/or responses are streamed.
*/
TextToSpeech.create = function create(rpcImpl, requestDelimited, responseDelimited) {
return new this(rpcImpl, requestDelimited, responseDelimited);
};
/**
* Callback as used by {@link google.cloud.texttospeech.v1.TextToSpeech|listVoices}.
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @typedef ListVoicesCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.cloud.texttospeech.v1.ListVoicesResponse} [response] ListVoicesResponse
*/
/**
* Calls ListVoices.
* @function listVoices
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @instance
* @param {google.cloud.texttospeech.v1.IListVoicesRequest} request ListVoicesRequest message or plain object
* @param {google.cloud.texttospeech.v1.TextToSpeech.ListVoicesCallback} callback Node-style callback called with the error, if any, and ListVoicesResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(TextToSpeech.prototype.listVoices = function listVoices(request, callback) {
return this.rpcCall(listVoices, $root.google.cloud.texttospeech.v1.ListVoicesRequest, $root.google.cloud.texttospeech.v1.ListVoicesResponse, request, callback);
}, "name", { value: "ListVoices" });
/**
* Calls ListVoices.
* @function listVoices
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @instance
* @param {google.cloud.texttospeech.v1.IListVoicesRequest} request ListVoicesRequest message or plain object
* @returns {Promise<google.cloud.texttospeech.v1.ListVoicesResponse>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.cloud.texttospeech.v1.TextToSpeech|synthesizeSpeech}.
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @typedef SynthesizeSpeechCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.cloud.texttospeech.v1.SynthesizeSpeechResponse} [response] SynthesizeSpeechResponse
*/
/**
* Calls SynthesizeSpeech.
* @function synthesizeSpeech
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @instance
* @param {google.cloud.texttospeech.v1.ISynthesizeSpeechRequest} request SynthesizeSpeechRequest message or plain object
* @param {google.cloud.texttospeech.v1.TextToSpeech.SynthesizeSpeechCallback} callback Node-style callback called with the error, if any, and SynthesizeSpeechResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(TextToSpeech.prototype.synthesizeSpeech = function synthesizeSpeech(request, callback) {
return this.rpcCall(synthesizeSpeech, $root.google.cloud.texttospeech.v1.SynthesizeSpeechRequest, $root.google.cloud.texttospeech.v1.SynthesizeSpeechResponse, request, callback);
}, "name", { value: "SynthesizeSpeech" });
/**
* Calls SynthesizeSpeech.
* @function synthesizeSpeech
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @instance
* @param {google.cloud.texttospeech.v1.ISynthesizeSpeechRequest} request SynthesizeSpeechRequest message or plain object
* @returns {Promise<google.cloud.texttospeech.v1.SynthesizeSpeechResponse>} Promise
* @variation 2
*/
/**
* Callback as used by {@link google.cloud.texttospeech.v1.TextToSpeech|streamingSynthesize}.
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @typedef StreamingSynthesizeCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {google.cloud.texttospeech.v1.StreamingSynthesizeResponse} [response] StreamingSynthesizeResponse
*/
/**
* Calls StreamingSynthesize.
* @function streamingSynthesize
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @instance
* @param {google.cloud.texttospeech.v1.IStreamingSynthesizeRequest} request StreamingSynthesizeRequest message or plain object
* @param {google.cloud.texttospeech.v1.TextToSpeech.StreamingSynthesizeCallback} callback Node-style callback called with the error, if any, and StreamingSynthesizeResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(TextToSpeech.prototype.streamingSynthesize = function streamingSynthesize(request, callback) {
return this.rpcCall(streamingSynthesize, $root.google.cloud.texttospeech.v1.StreamingSynthesizeRequest, $root.google.cloud.texttospeech.v1.StreamingSynthesizeResponse, request, callback);
}, "name", { value: "StreamingSynthesize" });
/**
* Calls StreamingSynthesize.
* @function streamingSynthesize
* @memberof google.cloud.texttospeech.v1.TextToSpeech
* @instance
* @param {google.cloud.texttospeech.v1.IStreamingSynthesizeRequest} request StreamingSynthesizeRequest message or plain object
* @returns {Promise<google.cloud.texttospeech.v1.StreamingSynthesizeResponse>} Promise
* @variation 2
*/
return TextToSpeech;
})();
/**
* SsmlVoiceGender enum.
* @name google.cloud.texttospeech.v1.SsmlVoiceGender
* @enum {number}
* @property {number} SSML_VOICE_GENDER_UNSPECIFIED=0 SSML_VOICE_GENDER_UNSPECIFIED value
* @property {number} MALE=1 MALE value
* @property {number} FEMALE=2 FEMALE value
* @property {number} NEUTRAL=3 NEUTRAL value
*/
v1.SsmlVoiceGender = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "SSML_VOICE_GENDER_UNSPECIFIED"] = 0;
values[valuesById[1] = "MALE"] = 1;
values[valuesById[2] = "FEMALE"] = 2;
values[valuesById[3] = "NEUTRAL"] = 3;
return values;
})();
/**
* AudioEncoding enum.
* @name google.cloud.texttospeech.v1.AudioEncoding
* @enum {number}
* @property {number} AUDIO_ENCODING_UNSPECIFIED=0 AUDIO_ENCODING_UNSPECIFIED value
* @property {number} LINEAR16=1 LINEAR16 value
* @property {number} MP3=2 MP3 value
* @property {number} OGG_OPUS=3 OGG_OPUS value
* @property {number} MULAW=5 MULAW value
* @property {number} ALAW=6 ALAW value
* @property {number} PCM=7 PCM value
*/
v1.AudioEncoding = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "AUDIO_ENCODING_UNSPECIFIED"] = 0;
values[valuesById[1] = "LINEAR16"] = 1;
values[valuesById[2] = "MP3"] = 2;
values[valuesById[3] = "OGG_OPUS"] = 3;
values[valuesById[5] = "MULAW"] = 5;
values[valuesById[6] = "ALAW"] = 6;
values[valuesById[7] = "PCM"] = 7;
return values;
})();
v1.ListVoicesRequest = (function() {
/**
* Properties of a ListVoicesRequest.
* @memberof google.cloud.texttospeech.v1
* @interface IListVoicesRequest
* @property {string|null} [languageCode] ListVoicesRequest languageCode
*/
/**
* Constructs a new ListVoicesRequest.
* @memberof google.cloud.texttospeech.v1
* @classdesc Represents a ListVoicesRequest.
* @implements IListVoicesRequest
* @constructor
* @param {google.cloud.texttospeech.v1.IListVoicesRequest=} [properties] Properties to set
*/
function ListVoicesRequest(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* ListVoicesRequest languageCode.
* @member {string} languageCode
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @instance
*/
ListVoicesRequest.prototype.languageCode = "";
/**
* Creates a new ListVoicesRequest instance using the specified properties.
* @function create
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {google.cloud.texttospeech.v1.IListVoicesRequest=} [properties] Properties to set
* @returns {google.cloud.texttospeech.v1.ListVoicesRequest} ListVoicesRequest instance
*/
ListVoicesRequest.create = function create(properties) {
return new ListVoicesRequest(properties);
};
/**
* Encodes the specified ListVoicesRequest message. Does not implicitly {@link google.cloud.texttospeech.v1.ListVoicesRequest.verify|verify} messages.
* @function encode
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {google.cloud.texttospeech.v1.IListVoicesRequest} message ListVoicesRequest message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ListVoicesRequest.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.languageCode);
return writer;
};
/**
* Encodes the specified ListVoicesRequest message, length delimited. Does not implicitly {@link google.cloud.texttospeech.v1.ListVoicesRequest.verify|verify} messages.
* @function encodeDelimited
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {google.cloud.texttospeech.v1.IListVoicesRequest} message ListVoicesRequest message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ListVoicesRequest.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a ListVoicesRequest message from the specified reader or buffer.
* @function decode
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.cloud.texttospeech.v1.ListVoicesRequest} ListVoicesRequest
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ListVoicesRequest.decode = function decode(reader, length) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.texttospeech.v1.ListVoicesRequest();
while (reader.pos < end) {
var tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
message.languageCode = reader.string();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a ListVoicesRequest message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.cloud.texttospeech.v1.ListVoicesRequest} ListVoicesRequest
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ListVoicesRequest.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a ListVoicesRequest message.
* @function verify
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
ListVoicesRequest.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.languageCode != null && message.hasOwnProperty("languageCode"))
if (!$util.isString(message.languageCode))
return "languageCode: string expected";
return null;
};
/**
* Creates a ListVoicesRequest message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.cloud.texttospeech.v1.ListVoicesRequest} ListVoicesRequest
*/
ListVoicesRequest.fromObject = function fromObject(object) {
if (object instanceof $root.google.cloud.texttospeech.v1.ListVoicesRequest)
return object;
var message = new $root.google.cloud.texttospeech.v1.ListVoicesRequest();
if (object.languageCode != null)
message.languageCode = String(object.languageCode);
return message;
};
/**
* Creates a plain object from a ListVoicesRequest message. Also converts values to other types if specified.
* @function toObject
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {google.cloud.texttospeech.v1.ListVoicesRequest} message ListVoicesRequest
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
ListVoicesRequest.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults)
object.languageCode = "";
if (message.languageCode != null && message.hasOwnProperty("languageCode"))
object.languageCode = message.languageCode;
return object;
};
/**
* Converts this ListVoicesRequest to JSON.
* @function toJSON
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @instance
* @returns {Object.<string,*>} JSON object
*/
ListVoicesRequest.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for ListVoicesRequest
* @function getTypeUrl
* @memberof google.cloud.texttospeech.v1.ListVoicesRequest
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
ListVoicesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.cloud.texttospeech.v1.ListVoicesRequest";
};
return ListVoicesRequest;
})();
v1.ListVoicesResponse = (function() {
/**
* Properties of a ListVoicesResponse.
* @memberof google.cloud.texttospeech.v1
* @interface IListVoicesResponse
* @property {Array.<google.cloud.texttospeech.v1.IVoice>|null} [voices] ListVoicesResponse voices
*/
/**
* Constructs a new ListVoicesResponse.
* @memberof google.cloud.texttospeech.v1
* @classdesc Represents a ListVoicesResponse.
* @implements IListVoicesResponse
* @constructor
* @param {google.cloud.texttospeech.v1.IListVoicesResponse=} [properties] Properties to set
*/
function ListVoicesResponse(properties) {
this.voices = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* ListVoicesResponse voices.
* @member {Array.<google.cloud.texttospeech.v1.IVoice>} voices
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @instance
*/
ListVoicesResponse.prototype.voices = $util.emptyArray;
/**
* Creates a new ListVoicesResponse instance using the specified properties.
* @function create
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {google.cloud.texttospeech.v1.IListVoicesResponse=} [properties] Properties to set
* @returns {google.cloud.texttospeech.v1.ListVoicesResponse} ListVoicesResponse instance
*/
ListVoicesResponse.create = function create(properties) {
return new ListVoicesResponse(properties);
};
/**
* Encodes the specified ListVoicesResponse message. Does not implicitly {@link google.cloud.texttospeech.v1.ListVoicesResponse.verify|verify} messages.
* @function encode
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {google.cloud.texttospeech.v1.IListVoicesResponse} message ListVoicesResponse message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ListVoicesResponse.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.voices != null && message.voices.length)
for (var i = 0; i < message.voices.length; ++i)
$root.google.cloud.texttospeech.v1.Voice.encode(message.voices[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
return writer;
};
/**
* Encodes the specified ListVoicesResponse message, length delimited. Does not implicitly {@link google.cloud.texttospeech.v1.ListVoicesResponse.verify|verify} messages.
* @function encodeDelimited
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {google.cloud.texttospeech.v1.IListVoicesResponse} message ListVoicesResponse message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ListVoicesResponse.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a ListVoicesResponse message from the specified reader or buffer.
* @function decode
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.cloud.texttospeech.v1.ListVoicesResponse} ListVoicesResponse
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ListVoicesResponse.decode = function decode(reader, length) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.texttospeech.v1.ListVoicesResponse();
while (reader.pos < end) {
var tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (!(message.voices && message.voices.length))
message.voices = [];
message.voices.push($root.google.cloud.texttospeech.v1.Voice.decode(reader, reader.uint32()));
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a ListVoicesResponse message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.cloud.texttospeech.v1.ListVoicesResponse} ListVoicesResponse
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ListVoicesResponse.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a ListVoicesResponse message.
* @function verify
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
ListVoicesResponse.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.voices != null && message.hasOwnProperty("voices")) {
if (!Array.isArray(message.voices))
return "voices: array expected";
for (var i = 0; i < message.voices.length; ++i) {
var error = $root.google.cloud.texttospeech.v1.Voice.verify(message.voices[i]);
if (error)
return "voices." + error;
}
}
return null;
};
/**
* Creates a ListVoicesResponse message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {Object.<string,*>} object Plain object
* @returns {google.cloud.texttospeech.v1.ListVoicesResponse} ListVoicesResponse
*/
ListVoicesResponse.fromObject = function fromObject(object) {
if (object instanceof $root.google.cloud.texttospeech.v1.ListVoicesResponse)
return object;
var message = new $root.google.cloud.texttospeech.v1.ListVoicesResponse();
if (object.voices) {
if (!Array.isArray(object.voices))
throw TypeError(".google.cloud.texttospeech.v1.ListVoicesResponse.voices: array expected");
message.voices = [];
for (var i = 0; i < object.voices.length; ++i) {
if (typeof object.voices[i] !== "object")
throw TypeError(".google.cloud.texttospeech.v1.ListVoicesResponse.voices: object expected");
message.voices[i] = $root.google.cloud.texttospeech.v1.Voice.fromObject(object.voices[i]);
}
}
return message;
};
/**
* Creates a plain object from a ListVoicesResponse message. Also converts values to other types if specified.
* @function toObject
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {google.cloud.texttospeech.v1.ListVoicesResponse} message ListVoicesResponse
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
ListVoicesResponse.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.voices = [];
if (message.voices && message.voices.length) {
object.voices = [];
for (var j = 0; j < message.voices.length; ++j)
object.voices[j] = $root.google.cloud.texttospeech.v1.Voice.toObject(message.voices[j], options);
}
return object;
};
/**
* Converts this ListVoicesResponse to JSON.
* @function toJSON
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @instance
* @returns {Object.<string,*>} JSON object
*/
ListVoicesResponse.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for ListVoicesResponse
* @function getTypeUrl
* @memberof google.cloud.texttospeech.v1.ListVoicesResponse
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
ListVoicesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/google.cloud.texttospeech.v1.ListVoicesResponse";
};
return ListVoicesResponse;
})();
v1.Voice = (function() {
/**
* Properties of a Voice.
* @memberof google.cloud.texttospeech.v1
* @interface IVoice
* @property {Array.<string>|null} [languageCodes] Voice languageCodes
* @property {string|null} [name] Voice name
* @property {google.cloud.texttospeech.v1.SsmlVoiceGender|null} [ssmlGender] Voice ssmlGender
* @property {number|null} [naturalSampleRateHertz] Voice naturalSampleRateHertz
*/
/**
* Constructs a new Voice.
* @memberof google.cloud.texttospeech.v1
* @classdesc Represents a Voice.
* @implements IVoice
* @constructor
* @param {google.cloud.texttospeech.v1.IVoice=} [properties] Properties to set
*/
function Voice(properties) {
this.languageCodes = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* Voice languageCodes.
* @member {Array.<string>} languageCodes
* @memberof google.cloud.texttospeech.v1.Voice
* @instance
*/
Voice.prototype.languageCodes = $util.emptyArray;
/**
* Voice name.
* @member {string} name
* @memberof google.cloud.texttospeech.v1.Voice
* @instance
*/
Voice.prototype.name = "";
/**
* Voice ssmlGender.
* @member {google.cloud.texttospeech.v1.SsmlVoiceGender} ssmlGender
* @memberof google.cloud.texttospeech.v1.Voice
* @instance
*/
Voice.prototype.ssmlGender = 0;
/**
* Voice naturalSampleRateHertz.
* @member {number} naturalSampleRateHertz
* @memberof google.cloud.texttospeech.v1.Voice
* @instance
*/
Voice.prototype.naturalSampleRateHertz = 0;
/**
* Creates a new Voice instance using the specified properties.
* @function create
* @memberof google.cloud.texttospeech.v1.Voice
* @static
* @param {google.cloud.texttospeech.v1.IVoice=} [properties] Properties to set
* @returns {google.cloud.texttospeech.v1.Voice} Voice instance
*/
Voice.create = function create(properties) {
return new Voice(properties);
};
/**
* Encodes the specified Voice message. Does not implicitly {@link google.cloud.texttospeech.v1.Voice.verify|verify} messages.
* @function encode
* @memberof google.cloud.texttospeech.v1.Voice
* @static
* @param {google.cloud.texttospeech.v1.IVoice} message Voice message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Voice.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.languageCodes != null && message.languageCodes.length)
for (var i = 0; i < message.languageCodes.length; ++i)
writer.uint32(/* id 1, wireType 2 =*/10).string(message.languageCodes[i]);
if (message.name != null && Object.hasOwnProperty.call(message, "name"))
writer.uint32(/* id 2, wireType 2 =*/18).string(message.name);
if (message.ssmlGender != null && Object.hasOwnProperty.call(message, "ssmlGender"))
writer.uint32(/* id 3, wireType 0 =*/24).int32(message.ssmlGender);
if (message.naturalSampleRateHertz != null && Object.hasOwnProperty.call(message, "naturalSampleRateHertz"))
writer.uint32(/* id 4, wireType 0 =*/32).int32(message.naturalSampleRateHertz);
return writer;
};
/**
* Encodes the specified Voice message, length delimited. Does not implicitly {@link google.cloud.texttospeech.v1.Voice.verify|verify} messages.
* @function encodeDelimited
* @memberof google.cloud.texttospeech.v1.Voice
* @static
* @param {google.cloud.texttospeech.v1.IVoice} message Voice message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
Voice.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a Voice message from the specified reader or buffer.
* @function decode
* @memberof google.cloud.texttospeech.v1.Voice
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {google.cloud.texttospeech.v1.Voice} Voice
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Voice.decode = function decode(reader, length) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.texttospeech.v1.Voice();
while (reader.pos < end) {
var tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (!(message.languageCodes && message.languageCodes.length))
message.languageCodes = [];
message.languageCodes.push(reader.string());
break;
}
case 2: {
message.name = reader.string();
break;
}
case 3: {
message.ssmlGender = reader.int32();
break;
}
case 4: {
message.naturalSampleRateHertz = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a Voice message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof google.cloud.texttospeech.v1.Voice
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {google.cloud.texttospeech.v1.Voice} Voice
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
Voice.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a Voice message.
* @function verify
* @memberof google.cloud.texttospeech.v1.Voice
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
Voice.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.languageCodes != null && message