@audc/salute-tts
Version:
Synthesis client for Node.js
898 lines (827 loc) • 1 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._audc_salute_tts_protos || ($protobuf.roots._audc_salute_tts_protos = {});
$root.smartspeech = (function() {
/**
* Namespace smartspeech.
* @exports smartspeech
* @namespace
*/
var smartspeech = {};
smartspeech.synthesis = (function() {
/**
* Namespace synthesis.
* @memberof smartspeech
* @namespace
*/
var synthesis = {};
synthesis.v1 = (function() {
/**
* Namespace v1.
* @memberof smartspeech.synthesis
* @namespace
*/
var v1 = {};
v1.SmartSpeech = (function() {
/**
* Constructs a new SmartSpeech service.
* @memberof smartspeech.synthesis.v1
* @classdesc Represents a SmartSpeech
* @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 SmartSpeech(rpcImpl, requestDelimited, responseDelimited) {
$protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited);
}
(SmartSpeech.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = SmartSpeech;
/**
* Creates new SmartSpeech service using the specified rpc implementation.
* @function create
* @memberof smartspeech.synthesis.v1.SmartSpeech
* @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 {SmartSpeech} RPC service. Useful where requests and/or responses are streamed.
*/
SmartSpeech.create = function create(rpcImpl, requestDelimited, responseDelimited) {
return new this(rpcImpl, requestDelimited, responseDelimited);
};
/**
* Callback as used by {@link smartspeech.synthesis.v1.SmartSpeech|synthesize}.
* @memberof smartspeech.synthesis.v1.SmartSpeech
* @typedef SynthesizeCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {smartspeech.synthesis.v1.SynthesisResponse} [response] SynthesisResponse
*/
/**
* Calls Synthesize.
* @function synthesize
* @memberof smartspeech.synthesis.v1.SmartSpeech
* @instance
* @param {smartspeech.synthesis.v1.ISynthesisRequest} request SynthesisRequest message or plain object
* @param {smartspeech.synthesis.v1.SmartSpeech.SynthesizeCallback} callback Node-style callback called with the error, if any, and SynthesisResponse
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(SmartSpeech.prototype.synthesize = function synthesize(request, callback) {
return this.rpcCall(synthesize, $root.smartspeech.synthesis.v1.SynthesisRequest, $root.smartspeech.synthesis.v1.SynthesisResponse, request, callback);
}, "name", { value: "Synthesize" });
/**
* Calls Synthesize.
* @function synthesize
* @memberof smartspeech.synthesis.v1.SmartSpeech
* @instance
* @param {smartspeech.synthesis.v1.ISynthesisRequest} request SynthesisRequest message or plain object
* @returns {Promise<smartspeech.synthesis.v1.SynthesisResponse>} Promise
* @variation 2
*/
/**
* Callback as used by {@link smartspeech.synthesis.v1.SmartSpeech|asyncSynthesize}.
* @memberof smartspeech.synthesis.v1.SmartSpeech
* @typedef AsyncSynthesizeCallback
* @type {function}
* @param {Error|null} error Error, if any
* @param {smartspeech.task.v1.Task} [response] Task
*/
/**
* Calls AsyncSynthesize.
* @function asyncSynthesize
* @memberof smartspeech.synthesis.v1.SmartSpeech
* @instance
* @param {smartspeech.synthesis.v1.IAsyncSynthesisRequest} request AsyncSynthesisRequest message or plain object
* @param {smartspeech.synthesis.v1.SmartSpeech.AsyncSynthesizeCallback} callback Node-style callback called with the error, if any, and Task
* @returns {undefined}
* @variation 1
*/
Object.defineProperty(SmartSpeech.prototype.asyncSynthesize = function asyncSynthesize(request, callback) {
return this.rpcCall(asyncSynthesize, $root.smartspeech.synthesis.v1.AsyncSynthesisRequest, $root.smartspeech.task.v1.Task, request, callback);
}, "name", { value: "AsyncSynthesize" });
/**
* Calls AsyncSynthesize.
* @function asyncSynthesize
* @memberof smartspeech.synthesis.v1.SmartSpeech
* @instance
* @param {smartspeech.synthesis.v1.IAsyncSynthesisRequest} request AsyncSynthesisRequest message or plain object
* @returns {Promise<smartspeech.task.v1.Task>} Promise
* @variation 2
*/
return SmartSpeech;
})();
v1.SynthesisRequest = (function() {
/**
* Properties of a SynthesisRequest.
* @memberof smartspeech.synthesis.v1
* @interface ISynthesisRequest
* @property {string|null} [text] SynthesisRequest text
* @property {smartspeech.synthesis.v1.SynthesisRequest.AudioEncoding|null} [audioEncoding] SynthesisRequest audioEncoding
* @property {string|null} [language] SynthesisRequest language
* @property {smartspeech.synthesis.v1.SynthesisRequest.ContentType|null} [contentType] SynthesisRequest contentType
* @property {string|null} [voice] SynthesisRequest voice
* @property {boolean|null} [rebuildCache] SynthesisRequest rebuildCache
*/
/**
* Constructs a new SynthesisRequest.
* @memberof smartspeech.synthesis.v1
* @classdesc Represents a SynthesisRequest.
* @implements ISynthesisRequest
* @constructor
* @param {smartspeech.synthesis.v1.ISynthesisRequest=} [properties] Properties to set
*/
function SynthesisRequest(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]];
}
/**
* SynthesisRequest text.
* @member {string} text
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @instance
*/
SynthesisRequest.prototype.text = "";
/**
* SynthesisRequest audioEncoding.
* @member {smartspeech.synthesis.v1.SynthesisRequest.AudioEncoding} audioEncoding
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @instance
*/
SynthesisRequest.prototype.audioEncoding = 0;
/**
* SynthesisRequest language.
* @member {string} language
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @instance
*/
SynthesisRequest.prototype.language = "";
/**
* SynthesisRequest contentType.
* @member {smartspeech.synthesis.v1.SynthesisRequest.ContentType} contentType
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @instance
*/
SynthesisRequest.prototype.contentType = 0;
/**
* SynthesisRequest voice.
* @member {string} voice
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @instance
*/
SynthesisRequest.prototype.voice = "";
/**
* SynthesisRequest rebuildCache.
* @member {boolean} rebuildCache
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @instance
*/
SynthesisRequest.prototype.rebuildCache = false;
/**
* Creates a new SynthesisRequest instance using the specified properties.
* @function create
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {smartspeech.synthesis.v1.ISynthesisRequest=} [properties] Properties to set
* @returns {smartspeech.synthesis.v1.SynthesisRequest} SynthesisRequest instance
*/
SynthesisRequest.create = function create(properties) {
return new SynthesisRequest(properties);
};
/**
* Encodes the specified SynthesisRequest message. Does not implicitly {@link smartspeech.synthesis.v1.SynthesisRequest.verify|verify} messages.
* @function encode
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {smartspeech.synthesis.v1.ISynthesisRequest} message SynthesisRequest message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SynthesisRequest.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.text != null && Object.hasOwnProperty.call(message, "text"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.text);
if (message.audioEncoding != null && Object.hasOwnProperty.call(message, "audioEncoding"))
writer.uint32(/* id 2, wireType 0 =*/16).int32(message.audioEncoding);
if (message.language != null && Object.hasOwnProperty.call(message, "language"))
writer.uint32(/* id 3, wireType 2 =*/26).string(message.language);
if (message.contentType != null && Object.hasOwnProperty.call(message, "contentType"))
writer.uint32(/* id 4, wireType 0 =*/32).int32(message.contentType);
if (message.voice != null && Object.hasOwnProperty.call(message, "voice"))
writer.uint32(/* id 5, wireType 2 =*/42).string(message.voice);
if (message.rebuildCache != null && Object.hasOwnProperty.call(message, "rebuildCache"))
writer.uint32(/* id 6, wireType 0 =*/48).bool(message.rebuildCache);
return writer;
};
/**
* Encodes the specified SynthesisRequest message, length delimited. Does not implicitly {@link smartspeech.synthesis.v1.SynthesisRequest.verify|verify} messages.
* @function encodeDelimited
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {smartspeech.synthesis.v1.ISynthesisRequest} message SynthesisRequest message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SynthesisRequest.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a SynthesisRequest message from the specified reader or buffer.
* @function decode
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {smartspeech.synthesis.v1.SynthesisRequest} SynthesisRequest
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SynthesisRequest.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.smartspeech.synthesis.v1.SynthesisRequest();
while (reader.pos < end) {
var tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
message.text = reader.string();
break;
}
case 2: {
message.audioEncoding = reader.int32();
break;
}
case 3: {
message.language = reader.string();
break;
}
case 4: {
message.contentType = reader.int32();
break;
}
case 5: {
message.voice = reader.string();
break;
}
case 6: {
message.rebuildCache = reader.bool();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a SynthesisRequest message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {smartspeech.synthesis.v1.SynthesisRequest} SynthesisRequest
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SynthesisRequest.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a SynthesisRequest message.
* @function verify
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
SynthesisRequest.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.text != null && message.hasOwnProperty("text"))
if (!$util.isString(message.text))
return "text: string expected";
if (message.audioEncoding != null && message.hasOwnProperty("audioEncoding"))
switch (message.audioEncoding) {
default:
return "audioEncoding: enum value expected";
case 0:
case 1:
case 2:
case 3:
break;
}
if (message.language != null && message.hasOwnProperty("language"))
if (!$util.isString(message.language))
return "language: string expected";
if (message.contentType != null && message.hasOwnProperty("contentType"))
switch (message.contentType) {
default:
return "contentType: enum value expected";
case 0:
case 1:
break;
}
if (message.voice != null && message.hasOwnProperty("voice"))
if (!$util.isString(message.voice))
return "voice: string expected";
if (message.rebuildCache != null && message.hasOwnProperty("rebuildCache"))
if (typeof message.rebuildCache !== "boolean")
return "rebuildCache: boolean expected";
return null;
};
/**
* Creates a SynthesisRequest message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {Object.<string,*>} object Plain object
* @returns {smartspeech.synthesis.v1.SynthesisRequest} SynthesisRequest
*/
SynthesisRequest.fromObject = function fromObject(object) {
if (object instanceof $root.smartspeech.synthesis.v1.SynthesisRequest)
return object;
var message = new $root.smartspeech.synthesis.v1.SynthesisRequest();
if (object.text != null)
message.text = String(object.text);
switch (object.audioEncoding) {
default:
if (typeof object.audioEncoding === "number") {
message.audioEncoding = object.audioEncoding;
break;
}
break;
case "AUDIO_ENCODING_UNSPECIFIED":
case 0:
message.audioEncoding = 0;
break;
case "PCM_S16LE":
case 1:
message.audioEncoding = 1;
break;
case "OPUS":
case 2:
message.audioEncoding = 2;
break;
case "WAV":
case 3:
message.audioEncoding = 3;
break;
}
if (object.language != null)
message.language = String(object.language);
switch (object.contentType) {
default:
if (typeof object.contentType === "number") {
message.contentType = object.contentType;
break;
}
break;
case "TEXT":
case 0:
message.contentType = 0;
break;
case "SSML":
case 1:
message.contentType = 1;
break;
}
if (object.voice != null)
message.voice = String(object.voice);
if (object.rebuildCache != null)
message.rebuildCache = Boolean(object.rebuildCache);
return message;
};
/**
* Creates a plain object from a SynthesisRequest message. Also converts values to other types if specified.
* @function toObject
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {smartspeech.synthesis.v1.SynthesisRequest} message SynthesisRequest
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
SynthesisRequest.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.text = "";
object.audioEncoding = options.enums === String ? "AUDIO_ENCODING_UNSPECIFIED" : 0;
object.language = "";
object.contentType = options.enums === String ? "TEXT" : 0;
object.voice = "";
object.rebuildCache = false;
}
if (message.text != null && message.hasOwnProperty("text"))
object.text = message.text;
if (message.audioEncoding != null && message.hasOwnProperty("audioEncoding"))
object.audioEncoding = options.enums === String ? $root.smartspeech.synthesis.v1.SynthesisRequest.AudioEncoding[message.audioEncoding] === undefined ? message.audioEncoding : $root.smartspeech.synthesis.v1.SynthesisRequest.AudioEncoding[message.audioEncoding] : message.audioEncoding;
if (message.language != null && message.hasOwnProperty("language"))
object.language = message.language;
if (message.contentType != null && message.hasOwnProperty("contentType"))
object.contentType = options.enums === String ? $root.smartspeech.synthesis.v1.SynthesisRequest.ContentType[message.contentType] === undefined ? message.contentType : $root.smartspeech.synthesis.v1.SynthesisRequest.ContentType[message.contentType] : message.contentType;
if (message.voice != null && message.hasOwnProperty("voice"))
object.voice = message.voice;
if (message.rebuildCache != null && message.hasOwnProperty("rebuildCache"))
object.rebuildCache = message.rebuildCache;
return object;
};
/**
* Converts this SynthesisRequest to JSON.
* @function toJSON
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @instance
* @returns {Object.<string,*>} JSON object
*/
SynthesisRequest.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for SynthesisRequest
* @function getTypeUrl
* @memberof smartspeech.synthesis.v1.SynthesisRequest
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
SynthesisRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/smartspeech.synthesis.v1.SynthesisRequest";
};
/**
* AudioEncoding enum.
* @name smartspeech.synthesis.v1.SynthesisRequest.AudioEncoding
* @enum {number}
* @property {number} AUDIO_ENCODING_UNSPECIFIED=0 AUDIO_ENCODING_UNSPECIFIED value
* @property {number} PCM_S16LE=1 PCM_S16LE value
* @property {number} OPUS=2 OPUS value
* @property {number} WAV=3 WAV value
*/
SynthesisRequest.AudioEncoding = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "AUDIO_ENCODING_UNSPECIFIED"] = 0;
values[valuesById[1] = "PCM_S16LE"] = 1;
values[valuesById[2] = "OPUS"] = 2;
values[valuesById[3] = "WAV"] = 3;
return values;
})();
/**
* ContentType enum.
* @name smartspeech.synthesis.v1.SynthesisRequest.ContentType
* @enum {number}
* @property {number} TEXT=0 TEXT value
* @property {number} SSML=1 SSML value
*/
SynthesisRequest.ContentType = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "TEXT"] = 0;
values[valuesById[1] = "SSML"] = 1;
return values;
})();
return SynthesisRequest;
})();
v1.SynthesisResponse = (function() {
/**
* Properties of a SynthesisResponse.
* @memberof smartspeech.synthesis.v1
* @interface ISynthesisResponse
* @property {Uint8Array|null} [data] SynthesisResponse data
* @property {google.protobuf.IDuration|null} [audioDuration] SynthesisResponse audioDuration
*/
/**
* Constructs a new SynthesisResponse.
* @memberof smartspeech.synthesis.v1
* @classdesc Represents a SynthesisResponse.
* @implements ISynthesisResponse
* @constructor
* @param {smartspeech.synthesis.v1.ISynthesisResponse=} [properties] Properties to set
*/
function SynthesisResponse(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]];
}
/**
* SynthesisResponse data.
* @member {Uint8Array} data
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @instance
*/
SynthesisResponse.prototype.data = $util.newBuffer([]);
/**
* SynthesisResponse audioDuration.
* @member {google.protobuf.IDuration|null|undefined} audioDuration
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @instance
*/
SynthesisResponse.prototype.audioDuration = null;
/**
* Creates a new SynthesisResponse instance using the specified properties.
* @function create
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {smartspeech.synthesis.v1.ISynthesisResponse=} [properties] Properties to set
* @returns {smartspeech.synthesis.v1.SynthesisResponse} SynthesisResponse instance
*/
SynthesisResponse.create = function create(properties) {
return new SynthesisResponse(properties);
};
/**
* Encodes the specified SynthesisResponse message. Does not implicitly {@link smartspeech.synthesis.v1.SynthesisResponse.verify|verify} messages.
* @function encode
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {smartspeech.synthesis.v1.ISynthesisResponse} message SynthesisResponse message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SynthesisResponse.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.data != null && Object.hasOwnProperty.call(message, "data"))
writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.data);
if (message.audioDuration != null && Object.hasOwnProperty.call(message, "audioDuration"))
$root.google.protobuf.Duration.encode(message.audioDuration, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
return writer;
};
/**
* Encodes the specified SynthesisResponse message, length delimited. Does not implicitly {@link smartspeech.synthesis.v1.SynthesisResponse.verify|verify} messages.
* @function encodeDelimited
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {smartspeech.synthesis.v1.ISynthesisResponse} message SynthesisResponse message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
SynthesisResponse.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a SynthesisResponse message from the specified reader or buffer.
* @function decode
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {smartspeech.synthesis.v1.SynthesisResponse} SynthesisResponse
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SynthesisResponse.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.smartspeech.synthesis.v1.SynthesisResponse();
while (reader.pos < end) {
var tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
message.data = reader.bytes();
break;
}
case 2: {
message.audioDuration = $root.google.protobuf.Duration.decode(reader, reader.uint32());
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a SynthesisResponse message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {smartspeech.synthesis.v1.SynthesisResponse} SynthesisResponse
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
SynthesisResponse.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a SynthesisResponse message.
* @function verify
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
SynthesisResponse.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.data != null && message.hasOwnProperty("data"))
if (!(message.data && typeof message.data.length === "number" || $util.isString(message.data)))
return "data: buffer expected";
if (message.audioDuration != null && message.hasOwnProperty("audioDuration")) {
var error = $root.google.protobuf.Duration.verify(message.audioDuration);
if (error)
return "audioDuration." + error;
}
return null;
};
/**
* Creates a SynthesisResponse message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {Object.<string,*>} object Plain object
* @returns {smartspeech.synthesis.v1.SynthesisResponse} SynthesisResponse
*/
SynthesisResponse.fromObject = function fromObject(object) {
if (object instanceof $root.smartspeech.synthesis.v1.SynthesisResponse)
return object;
var message = new $root.smartspeech.synthesis.v1.SynthesisResponse();
if (object.data != null)
if (typeof object.data === "string")
$util.base64.decode(object.data, message.data = $util.newBuffer($util.base64.length(object.data)), 0);
else if (object.data.length >= 0)
message.data = object.data;
if (object.audioDuration != null) {
if (typeof object.audioDuration !== "object")
throw TypeError(".smartspeech.synthesis.v1.SynthesisResponse.audioDuration: object expected");
message.audioDuration = $root.google.protobuf.Duration.fromObject(object.audioDuration);
}
return message;
};
/**
* Creates a plain object from a SynthesisResponse message. Also converts values to other types if specified.
* @function toObject
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {smartspeech.synthesis.v1.SynthesisResponse} message SynthesisResponse
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
SynthesisResponse.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
if (options.bytes === String)
object.data = "";
else {
object.data = [];
if (options.bytes !== Array)
object.data = $util.newBuffer(object.data);
}
object.audioDuration = null;
}
if (message.data != null && message.hasOwnProperty("data"))
object.data = options.bytes === String ? $util.base64.encode(message.data, 0, message.data.length) : options.bytes === Array ? Array.prototype.slice.call(message.data) : message.data;
if (message.audioDuration != null && message.hasOwnProperty("audioDuration"))
object.audioDuration = $root.google.protobuf.Duration.toObject(message.audioDuration, options);
return object;
};
/**
* Converts this SynthesisResponse to JSON.
* @function toJSON
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @instance
* @returns {Object.<string,*>} JSON object
*/
SynthesisResponse.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for SynthesisResponse
* @function getTypeUrl
* @memberof smartspeech.synthesis.v1.SynthesisResponse
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
SynthesisResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/smartspeech.synthesis.v1.SynthesisResponse";
};
return SynthesisResponse;
})();
v1.AsyncSynthesisRequest = (function() {
/**
* Properties of an AsyncSynthesisRequest.
* @memberof smartspeech.synthesis.v1
* @interface IAsyncSynthesisRequest
* @property {string|null} [requestFileId] AsyncSynthesisRequest requestFileId
* @property {smartspeech.synthesis.v1.SynthesisRequest.AudioEncoding|null} [audioEncoding] AsyncSynthesisRequest audioEncoding
* @property {string|null} [voice] AsyncSynthesisRequest voice
*/
/**
* Constructs a new AsyncSynthesisRequest.
* @memberof smartspeech.synthesis.v1
* @classdesc Represents an AsyncSynthesisRequest.
* @implements IAsyncSynthesisRequest
* @constructor
* @param {smartspeech.synthesis.v1.IAsyncSynthesisRequest=} [properties] Properties to set
*/
function AsyncSynthesisRequest(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]];
}
/**
* AsyncSynthesisRequest requestFileId.
* @member {string} requestFileId
* @memberof smartspeech.synthesis.v1.AsyncSynthesisRequest
* @instance
*/
AsyncSynthesisRequest.prototype.requestFileId = "";
/**
* AsyncSynthesisRequest audioEncoding.
* @member {smartspeech.synthesis.v1.SynthesisRequest.AudioEncoding} audioEncoding
* @memberof smartspeech.synthesis.v1.AsyncSynthesisRequest
* @instance
*/
AsyncSynthesisRequest.prototype.audioEncoding = 0;
/**
* AsyncSynthesisRequest voice.
* @member {string} voice
* @memberof smartspeech.synthesis.v1.AsyncSynthesisRequest
* @instance
*/
AsyncSynthesisRequest.prototype.voice = "";
/**
* Creates a new AsyncSynthesisRequest instance using the specified properties.
* @function create
* @memberof smartspeech.synthesis.v1.AsyncSynthesisRequest
* @static
* @param {smartspeech.synthesis.v1.IAsyncSynthesisRequest=} [properties] Properties to set
* @returns {smartspeech.synthesis.v1.AsyncSynthesisRequest} AsyncSynthesisRequest instance
*/
AsyncSynthesisRequest.create = function create(properties) {
return new AsyncSynthesisRequest(properties);
};
/**
* Encodes the specified AsyncSynthesisRequest message. Does not implicitly {@link smartspeech.synthesis.v1.AsyncSynthesisRequest.verify|verify} messages.
* @function encode
* @memberof smartspeech.synthesis.v1.AsyncSynthesisRequest
* @static
* @param {smartspeech.synthesis.v1.IAsyncSynthesisRequest} message AsyncSynthesisRequest message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
AsyncSynthesisRequest.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.requestFileId != null && Object.hasOwnProperty.call(message, "requestFileId"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.requestFileId);
if (message.audioEncoding != null && Object.hasOwnProperty.call(message, "audioEncoding"))
writer.uint32(/* id 2, wireType 0 =*/16).int32(message.audioEncoding);
if (message.voice != null && Object.hasOwnProperty.call(message, "voice"))
writer.uint32(/* id 3, wireType 2 =*/26).string(message.voice);
return writer;
};
/**
* Encodes the specified AsyncSynthesisRequest message, length delimited. Does not implicitly {@link smartspeech.synthesis.v1.AsyncSynthesisRequest.verify|verify} messages.
* @function encodeDelimited
* @memberof smartspeech.synthesis.v1.AsyncSynthesisRequest
* @static
* @param {smartspeech.synthesis.v1.IAsyncSynthesisRequest} message AsyncSynthesisRequest message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
AsyncSynthesisRequest.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes an AsyncSynthesisRequest message from the specif