@aristech-org/stt-client
Version:
A Node.js client library for the Aristech Speech-to-Text API
1,358 lines (1,357 loc) • 103 kB
JavaScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.8.3
// protoc v6.33.1
// source: stt_service.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { makeGenericClientConstructor, } from "@grpc/grpc-js";
import { Duration } from "./google/protobuf/duration.js";
export const protobufPackage = "ari.stt.v1";
export var LanguageSelectionMode;
(function (LanguageSelectionMode) {
/** FIXED - The model is fixed to a specific language and does not perform any language selection. */
LanguageSelectionMode[LanguageSelectionMode["FIXED"] = 0] = "FIXED";
/** OPTIONAL_OR_AUTO - The model can either be used with a specified locale or it can perform automatic language selection. */
LanguageSelectionMode[LanguageSelectionMode["OPTIONAL_OR_AUTO"] = 1] = "OPTIONAL_OR_AUTO";
/** AUTO_ONLY - The model performs automatic language selection and does not allow to specify a locale. */
LanguageSelectionMode[LanguageSelectionMode["AUTO_ONLY"] = 2] = "AUTO_ONLY";
/**
* REQUIRED - The model requires a locale to be specified and does not perform any language selection.
* If no locale is specified, the server will choose the first locale from the list of supported locales for the model.
*/
LanguageSelectionMode[LanguageSelectionMode["REQUIRED"] = 3] = "REQUIRED";
LanguageSelectionMode[LanguageSelectionMode["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(LanguageSelectionMode || (LanguageSelectionMode = {}));
export function languageSelectionModeFromJSON(object) {
switch (object) {
case 0:
case "FIXED":
return LanguageSelectionMode.FIXED;
case 1:
case "OPTIONAL_OR_AUTO":
return LanguageSelectionMode.OPTIONAL_OR_AUTO;
case 2:
case "AUTO_ONLY":
return LanguageSelectionMode.AUTO_ONLY;
case 3:
case "REQUIRED":
return LanguageSelectionMode.REQUIRED;
case -1:
case "UNRECOGNIZED":
default:
return LanguageSelectionMode.UNRECOGNIZED;
}
}
export function languageSelectionModeToJSON(object) {
switch (object) {
case LanguageSelectionMode.FIXED:
return "FIXED";
case LanguageSelectionMode.OPTIONAL_OR_AUTO:
return "OPTIONAL_OR_AUTO";
case LanguageSelectionMode.AUTO_ONLY:
return "AUTO_ONLY";
case LanguageSelectionMode.REQUIRED:
return "REQUIRED";
case LanguageSelectionMode.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var EndpointingType;
(function (EndpointingType) {
/** LM - Endpointing that considers the language model. */
EndpointingType[EndpointingType["LM"] = 0] = "LM";
/** VAD - VAD based endpointing. */
EndpointingType[EndpointingType["VAD"] = 1] = "VAD";
EndpointingType[EndpointingType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(EndpointingType || (EndpointingType = {}));
export function endpointingTypeFromJSON(object) {
switch (object) {
case 0:
case "LM":
return EndpointingType.LM;
case 1:
case "VAD":
return EndpointingType.VAD;
case -1:
case "UNRECOGNIZED":
default:
return EndpointingType.UNRECOGNIZED;
}
}
export function endpointingTypeToJSON(object) {
switch (object) {
case EndpointingType.LM:
return "LM";
case EndpointingType.VAD:
return "VAD";
case EndpointingType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var ModelType;
(function (ModelType) {
/** CORE_STT - STT-Core models */
ModelType[ModelType["CORE_STT"] = 0] = "CORE_STT";
/** GRAMMAR_STT - Grammar only models */
ModelType[ModelType["GRAMMAR_STT"] = 1] = "GRAMMAR_STT";
/** MULTITASK_STT - Multitask models */
ModelType[ModelType["MULTITASK_STT"] = 2] = "MULTITASK_STT";
/** AUDIO_LLM - Audio-capable multimodal LLMs */
ModelType[ModelType["AUDIO_LLM"] = 4] = "AUDIO_LLM";
/** DIARIZATION - Speaker diarization model type. */
ModelType[ModelType["DIARIZATION"] = 3] = "DIARIZATION";
ModelType[ModelType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(ModelType || (ModelType = {}));
export function modelTypeFromJSON(object) {
switch (object) {
case 0:
case "CORE_STT":
return ModelType.CORE_STT;
case 1:
case "GRAMMAR_STT":
return ModelType.GRAMMAR_STT;
case 2:
case "MULTITASK_STT":
return ModelType.MULTITASK_STT;
case 4:
case "AUDIO_LLM":
return ModelType.AUDIO_LLM;
case 3:
case "DIARIZATION":
return ModelType.DIARIZATION;
case -1:
case "UNRECOGNIZED":
default:
return ModelType.UNRECOGNIZED;
}
}
export function modelTypeToJSON(object) {
switch (object) {
case ModelType.CORE_STT:
return "CORE_STT";
case ModelType.GRAMMAR_STT:
return "GRAMMAR_STT";
case ModelType.MULTITASK_STT:
return "MULTITASK_STT";
case ModelType.AUDIO_LLM:
return "AUDIO_LLM";
case ModelType.DIARIZATION:
return "DIARIZATION";
case ModelType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var GrammarType;
(function (GrammarType) {
/**
* JSGF - JSGF grammar type.
* Example grammar: `jsgf:<yes_no> = yes | no;`
*/
GrammarType[GrammarType["JSGF"] = 0] = "JSGF";
/**
* SRGS - SRGS grammar type.
* Example grammar: `srgs:$yes_no = yes | no;`
*/
GrammarType[GrammarType["SRGS"] = 3] = "SRGS";
/**
* KWS - Keyword / Keyphrase spotting grammar type.
* Example grammar: `kws:oh mighty computer|hey computer`
*/
GrammarType[GrammarType["KWS"] = 1] = "KWS";
/**
* PHRASE_LIST - A simple json phrase list grammar type.
* Example grammar: `["yes", "yeah", "yep", "why not", "no", "nope"]`
*/
GrammarType[GrammarType["PHRASE_LIST"] = 2] = "PHRASE_LIST";
/**
* GBNF - GBNF grammar type.
* Example grammar: `gbnf:root ::= "yes" | "no"`
*/
GrammarType[GrammarType["GBNF"] = 4] = "GBNF";
GrammarType[GrammarType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(GrammarType || (GrammarType = {}));
export function grammarTypeFromJSON(object) {
switch (object) {
case 0:
case "JSGF":
return GrammarType.JSGF;
case 3:
case "SRGS":
return GrammarType.SRGS;
case 1:
case "KWS":
return GrammarType.KWS;
case 2:
case "PHRASE_LIST":
return GrammarType.PHRASE_LIST;
case 4:
case "GBNF":
return GrammarType.GBNF;
case -1:
case "UNRECOGNIZED":
default:
return GrammarType.UNRECOGNIZED;
}
}
export function grammarTypeToJSON(object) {
switch (object) {
case GrammarType.JSGF:
return "JSGF";
case GrammarType.SRGS:
return "SRGS";
case GrammarType.KWS:
return "KWS";
case GrammarType.PHRASE_LIST:
return "PHRASE_LIST";
case GrammarType.GBNF:
return "GBNF";
case GrammarType.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var RecognitionSpec_AudioEncoding;
(function (RecognitionSpec_AudioEncoding) {
/** AUDIO_ENCODING_UNSPECIFIED - If not specified, defaults to LINEAR16_PCM. */
RecognitionSpec_AudioEncoding[RecognitionSpec_AudioEncoding["AUDIO_ENCODING_UNSPECIFIED"] = 0] = "AUDIO_ENCODING_UNSPECIFIED";
/** LINEAR16_PCM - 16-bit signed little-endian (Linear PCM) */
RecognitionSpec_AudioEncoding[RecognitionSpec_AudioEncoding["LINEAR16_PCM"] = 1] = "LINEAR16_PCM";
RecognitionSpec_AudioEncoding[RecognitionSpec_AudioEncoding["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(RecognitionSpec_AudioEncoding || (RecognitionSpec_AudioEncoding = {}));
export function recognitionSpec_AudioEncodingFromJSON(object) {
switch (object) {
case 0:
case "AUDIO_ENCODING_UNSPECIFIED":
return RecognitionSpec_AudioEncoding.AUDIO_ENCODING_UNSPECIFIED;
case 1:
case "LINEAR16_PCM":
return RecognitionSpec_AudioEncoding.LINEAR16_PCM;
case -1:
case "UNRECOGNIZED":
default:
return RecognitionSpec_AudioEncoding.UNRECOGNIZED;
}
}
export function recognitionSpec_AudioEncodingToJSON(object) {
switch (object) {
case RecognitionSpec_AudioEncoding.AUDIO_ENCODING_UNSPECIFIED:
return "AUDIO_ENCODING_UNSPECIFIED";
case RecognitionSpec_AudioEncoding.LINEAR16_PCM:
return "LINEAR16_PCM";
case RecognitionSpec_AudioEncoding.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var NLPSpec_NlpInputField;
(function (NLPSpec_NlpInputField) {
/** UNSPECIFIED - If not specified, defaults to TEXT. */
NLPSpec_NlpInputField[NLPSpec_NlpInputField["UNSPECIFIED"] = 0] = "UNSPECIFIED";
/** TEXT - The text field is used as input for the nlp processing. */
NLPSpec_NlpInputField[NLPSpec_NlpInputField["TEXT"] = 1] = "TEXT";
/** TAGGED_TEXT - Use the tagged_text field as input for the nlp processing. */
NLPSpec_NlpInputField[NLPSpec_NlpInputField["TAGGED_TEXT"] = 2] = "TAGGED_TEXT";
/** SLOTTED_TEXT - Use the slotted_text field as input for the nlp processing. */
NLPSpec_NlpInputField[NLPSpec_NlpInputField["SLOTTED_TEXT"] = 3] = "SLOTTED_TEXT";
NLPSpec_NlpInputField[NLPSpec_NlpInputField["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(NLPSpec_NlpInputField || (NLPSpec_NlpInputField = {}));
export function nLPSpec_NlpInputFieldFromJSON(object) {
switch (object) {
case 0:
case "UNSPECIFIED":
return NLPSpec_NlpInputField.UNSPECIFIED;
case 1:
case "TEXT":
return NLPSpec_NlpInputField.TEXT;
case 2:
case "TAGGED_TEXT":
return NLPSpec_NlpInputField.TAGGED_TEXT;
case 3:
case "SLOTTED_TEXT":
return NLPSpec_NlpInputField.SLOTTED_TEXT;
case -1:
case "UNRECOGNIZED":
default:
return NLPSpec_NlpInputField.UNRECOGNIZED;
}
}
export function nLPSpec_NlpInputFieldToJSON(object) {
switch (object) {
case NLPSpec_NlpInputField.UNSPECIFIED:
return "UNSPECIFIED";
case NLPSpec_NlpInputField.TEXT:
return "TEXT";
case NLPSpec_NlpInputField.TAGGED_TEXT:
return "TAGGED_TEXT";
case NLPSpec_NlpInputField.SLOTTED_TEXT:
return "SLOTTED_TEXT";
case NLPSpec_NlpInputField.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
function createBaseStreamingRecognitionRequest() {
return { config: undefined, audioContent: undefined };
}
export const StreamingRecognitionRequest = {
encode(message, writer = new BinaryWriter()) {
if (message.config !== undefined) {
RecognitionConfig.encode(message.config, writer.uint32(10).fork()).join();
}
if (message.audioContent !== undefined) {
writer.uint32(18).bytes(message.audioContent);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStreamingRecognitionRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.config = RecognitionConfig.decode(reader, reader.uint32());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.audioContent = reader.bytes();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
config: isSet(object.config) ? RecognitionConfig.fromJSON(object.config) : undefined,
audioContent: isSet(object.audioContent) ? bytesFromBase64(object.audioContent) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.config !== undefined) {
obj.config = RecognitionConfig.toJSON(message.config);
}
if (message.audioContent !== undefined) {
obj.audioContent = base64FromBytes(message.audioContent);
}
return obj;
},
create(base) {
return StreamingRecognitionRequest.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseStreamingRecognitionRequest();
message.config = (object.config !== undefined && object.config !== null)
? RecognitionConfig.fromPartial(object.config)
: undefined;
message.audioContent = object.audioContent ?? undefined;
return message;
},
};
function createBaseStreamingRecognitionResponse() {
return { chunks: [], clientId: "", language: "", metrics: {} };
}
export const StreamingRecognitionResponse = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.chunks) {
SpeechRecognitionChunk.encode(v, writer.uint32(10).fork()).join();
}
if (message.clientId !== "") {
writer.uint32(26).string(message.clientId);
}
if (message.language !== "") {
writer.uint32(34).string(message.language);
}
Object.entries(message.metrics).forEach(([key, value]) => {
StreamingRecognitionResponse_MetricsEntry.encode({ key: key, value }, writer.uint32(42).fork()).join();
});
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStreamingRecognitionResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.chunks.push(SpeechRecognitionChunk.decode(reader, reader.uint32()));
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.clientId = reader.string();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.language = reader.string();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
const entry5 = StreamingRecognitionResponse_MetricsEntry.decode(reader, reader.uint32());
if (entry5.value !== undefined) {
message.metrics[entry5.key] = entry5.value;
}
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
chunks: globalThis.Array.isArray(object?.chunks)
? object.chunks.map((e) => SpeechRecognitionChunk.fromJSON(e))
: [],
clientId: isSet(object.clientId) ? globalThis.String(object.clientId) : "",
language: isSet(object.language) ? globalThis.String(object.language) : "",
metrics: isObject(object.metrics)
? Object.entries(object.metrics).reduce((acc, [key, value]) => {
acc[key] = StreamingRecognitionResponse_PerformanceMetric.fromJSON(value);
return acc;
}, {})
: {},
};
},
toJSON(message) {
const obj = {};
if (message.chunks?.length) {
obj.chunks = message.chunks.map((e) => SpeechRecognitionChunk.toJSON(e));
}
if (message.clientId !== "") {
obj.clientId = message.clientId;
}
if (message.language !== "") {
obj.language = message.language;
}
if (message.metrics) {
const entries = Object.entries(message.metrics);
if (entries.length > 0) {
obj.metrics = {};
entries.forEach(([k, v]) => {
obj.metrics[k] = StreamingRecognitionResponse_PerformanceMetric.toJSON(v);
});
}
}
return obj;
},
create(base) {
return StreamingRecognitionResponse.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseStreamingRecognitionResponse();
message.chunks = object.chunks?.map((e) => SpeechRecognitionChunk.fromPartial(e)) || [];
message.clientId = object.clientId ?? "";
message.language = object.language ?? "";
message.metrics = Object.entries(object.metrics ?? {}).reduce((acc, [key, value]) => {
if (value !== undefined) {
acc[key] = StreamingRecognitionResponse_PerformanceMetric.fromPartial(value);
}
return acc;
}, {});
return message;
},
};
function createBaseStreamingRecognitionResponse_PerformanceMetric() {
return { number: undefined, duration: undefined };
}
export const StreamingRecognitionResponse_PerformanceMetric = {
encode(message, writer = new BinaryWriter()) {
if (message.number !== undefined) {
writer.uint32(9).double(message.number);
}
if (message.duration !== undefined) {
Duration.encode(message.duration, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStreamingRecognitionResponse_PerformanceMetric();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 9) {
break;
}
message.number = reader.double();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.duration = Duration.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
number: isSet(object.number) ? globalThis.Number(object.number) : undefined,
duration: isSet(object.duration) ? Duration.fromJSON(object.duration) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.number !== undefined) {
obj.number = message.number;
}
if (message.duration !== undefined) {
obj.duration = Duration.toJSON(message.duration);
}
return obj;
},
create(base) {
return StreamingRecognitionResponse_PerformanceMetric.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseStreamingRecognitionResponse_PerformanceMetric();
message.number = object.number ?? undefined;
message.duration = (object.duration !== undefined && object.duration !== null)
? Duration.fromPartial(object.duration)
: undefined;
return message;
},
};
function createBaseStreamingRecognitionResponse_MetricsEntry() {
return { key: "", value: undefined };
}
export const StreamingRecognitionResponse_MetricsEntry = {
encode(message, writer = new BinaryWriter()) {
if (message.key !== "") {
writer.uint32(10).string(message.key);
}
if (message.value !== undefined) {
StreamingRecognitionResponse_PerformanceMetric.encode(message.value, writer.uint32(18).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStreamingRecognitionResponse_MetricsEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.key = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.value = StreamingRecognitionResponse_PerformanceMetric.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
key: isSet(object.key) ? globalThis.String(object.key) : "",
value: isSet(object.value) ? StreamingRecognitionResponse_PerformanceMetric.fromJSON(object.value) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.key !== "") {
obj.key = message.key;
}
if (message.value !== undefined) {
obj.value = StreamingRecognitionResponse_PerformanceMetric.toJSON(message.value);
}
return obj;
},
create(base) {
return StreamingRecognitionResponse_MetricsEntry.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseStreamingRecognitionResponse_MetricsEntry();
message.key = object.key ?? "";
message.value = (object.value !== undefined && object.value !== null)
? StreamingRecognitionResponse_PerformanceMetric.fromPartial(object.value)
: undefined;
return message;
},
};
function createBaseRecognitionConfig() {
return { specification: undefined };
}
export const RecognitionConfig = {
encode(message, writer = new BinaryWriter()) {
if (message.specification !== undefined) {
RecognitionSpec.encode(message.specification, writer.uint32(10).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRecognitionConfig();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.specification = RecognitionSpec.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return { specification: isSet(object.specification) ? RecognitionSpec.fromJSON(object.specification) : undefined };
},
toJSON(message) {
const obj = {};
if (message.specification !== undefined) {
obj.specification = RecognitionSpec.toJSON(message.specification);
}
return obj;
},
create(base) {
return RecognitionConfig.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseRecognitionConfig();
message.specification = (object.specification !== undefined && object.specification !== null)
? RecognitionSpec.fromPartial(object.specification)
: undefined;
return message;
},
};
function createBaseRecognitionSpec() {
return {
audioEncoding: 0,
sampleRateHertz: 0,
locale: "",
graph: "",
grammar: "",
partialResults: false,
singleUtterance: false,
normalization: undefined,
phones: false,
model: "",
endpointing: undefined,
vad: undefined,
prompt: "",
};
}
export const RecognitionSpec = {
encode(message, writer = new BinaryWriter()) {
if (message.audioEncoding !== 0) {
writer.uint32(8).int32(message.audioEncoding);
}
if (message.sampleRateHertz !== 0) {
writer.uint32(16).int64(message.sampleRateHertz);
}
if (message.locale !== "") {
writer.uint32(26).string(message.locale);
}
if (message.graph !== "") {
writer.uint32(42).string(message.graph);
}
if (message.grammar !== "") {
writer.uint32(50).string(message.grammar);
}
if (message.partialResults !== false) {
writer.uint32(56).bool(message.partialResults);
}
if (message.singleUtterance !== false) {
writer.uint32(64).bool(message.singleUtterance);
}
if (message.normalization !== undefined) {
NormalizationSpec.encode(message.normalization, writer.uint32(74).fork()).join();
}
if (message.phones !== false) {
writer.uint32(80).bool(message.phones);
}
if (message.model !== "") {
writer.uint32(90).string(message.model);
}
if (message.endpointing !== undefined) {
EndpointSpec.encode(message.endpointing, writer.uint32(98).fork()).join();
}
if (message.vad !== undefined) {
VadSpec.encode(message.vad, writer.uint32(106).fork()).join();
}
if (message.prompt !== "") {
writer.uint32(114).string(message.prompt);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRecognitionSpec();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.audioEncoding = reader.int32();
continue;
}
case 2: {
if (tag !== 16) {
break;
}
message.sampleRateHertz = longToNumber(reader.int64());
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.locale = reader.string();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.graph = reader.string();
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.grammar = reader.string();
continue;
}
case 7: {
if (tag !== 56) {
break;
}
message.partialResults = reader.bool();
continue;
}
case 8: {
if (tag !== 64) {
break;
}
message.singleUtterance = reader.bool();
continue;
}
case 9: {
if (tag !== 74) {
break;
}
message.normalization = NormalizationSpec.decode(reader, reader.uint32());
continue;
}
case 10: {
if (tag !== 80) {
break;
}
message.phones = reader.bool();
continue;
}
case 11: {
if (tag !== 90) {
break;
}
message.model = reader.string();
continue;
}
case 12: {
if (tag !== 98) {
break;
}
message.endpointing = EndpointSpec.decode(reader, reader.uint32());
continue;
}
case 13: {
if (tag !== 106) {
break;
}
message.vad = VadSpec.decode(reader, reader.uint32());
continue;
}
case 14: {
if (tag !== 114) {
break;
}
message.prompt = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
audioEncoding: isSet(object.audioEncoding) ? recognitionSpec_AudioEncodingFromJSON(object.audioEncoding) : 0,
sampleRateHertz: isSet(object.sampleRateHertz) ? globalThis.Number(object.sampleRateHertz) : 0,
locale: isSet(object.locale) ? globalThis.String(object.locale) : "",
graph: isSet(object.graph) ? globalThis.String(object.graph) : "",
grammar: isSet(object.grammar) ? globalThis.String(object.grammar) : "",
partialResults: isSet(object.partialResults) ? globalThis.Boolean(object.partialResults) : false,
singleUtterance: isSet(object.singleUtterance) ? globalThis.Boolean(object.singleUtterance) : false,
normalization: isSet(object.normalization) ? NormalizationSpec.fromJSON(object.normalization) : undefined,
phones: isSet(object.phones) ? globalThis.Boolean(object.phones) : false,
model: isSet(object.model) ? globalThis.String(object.model) : "",
endpointing: isSet(object.endpointing) ? EndpointSpec.fromJSON(object.endpointing) : undefined,
vad: isSet(object.vad) ? VadSpec.fromJSON(object.vad) : undefined,
prompt: isSet(object.prompt) ? globalThis.String(object.prompt) : "",
};
},
toJSON(message) {
const obj = {};
if (message.audioEncoding !== 0) {
obj.audioEncoding = recognitionSpec_AudioEncodingToJSON(message.audioEncoding);
}
if (message.sampleRateHertz !== 0) {
obj.sampleRateHertz = Math.round(message.sampleRateHertz);
}
if (message.locale !== "") {
obj.locale = message.locale;
}
if (message.graph !== "") {
obj.graph = message.graph;
}
if (message.grammar !== "") {
obj.grammar = message.grammar;
}
if (message.partialResults !== false) {
obj.partialResults = message.partialResults;
}
if (message.singleUtterance !== false) {
obj.singleUtterance = message.singleUtterance;
}
if (message.normalization !== undefined) {
obj.normalization = NormalizationSpec.toJSON(message.normalization);
}
if (message.phones !== false) {
obj.phones = message.phones;
}
if (message.model !== "") {
obj.model = message.model;
}
if (message.endpointing !== undefined) {
obj.endpointing = EndpointSpec.toJSON(message.endpointing);
}
if (message.vad !== undefined) {
obj.vad = VadSpec.toJSON(message.vad);
}
if (message.prompt !== "") {
obj.prompt = message.prompt;
}
return obj;
},
create(base) {
return RecognitionSpec.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseRecognitionSpec();
message.audioEncoding = object.audioEncoding ?? 0;
message.sampleRateHertz = object.sampleRateHertz ?? 0;
message.locale = object.locale ?? "";
message.graph = object.graph ?? "";
message.grammar = object.grammar ?? "";
message.partialResults = object.partialResults ?? false;
message.singleUtterance = object.singleUtterance ?? false;
message.normalization = (object.normalization !== undefined && object.normalization !== null)
? NormalizationSpec.fromPartial(object.normalization)
: undefined;
message.phones = object.phones ?? false;
message.model = object.model ?? "";
message.endpointing = (object.endpointing !== undefined && object.endpointing !== null)
? EndpointSpec.fromPartial(object.endpointing)
: undefined;
message.vad = (object.vad !== undefined && object.vad !== null) ? VadSpec.fromPartial(object.vad) : undefined;
message.prompt = object.prompt ?? "";
return message;
},
};
function createBaseNormalizationSpec() {
return { stripUnk: false, nlp: undefined };
}
export const NormalizationSpec = {
encode(message, writer = new BinaryWriter()) {
if (message.stripUnk !== false) {
writer.uint32(16).bool(message.stripUnk);
}
if (message.nlp !== undefined) {
NLPSpec.encode(message.nlp, writer.uint32(34).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseNormalizationSpec();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 2: {
if (tag !== 16) {
break;
}
message.stripUnk = reader.bool();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.nlp = NLPSpec.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
stripUnk: isSet(object.stripUnk) ? globalThis.Boolean(object.stripUnk) : false,
nlp: isSet(object.nlp) ? NLPSpec.fromJSON(object.nlp) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.stripUnk !== false) {
obj.stripUnk = message.stripUnk;
}
if (message.nlp !== undefined) {
obj.nlp = NLPSpec.toJSON(message.nlp);
}
return obj;
},
create(base) {
return NormalizationSpec.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseNormalizationSpec();
message.stripUnk = object.stripUnk ?? false;
message.nlp = (object.nlp !== undefined && object.nlp !== null) ? NLPSpec.fromPartial(object.nlp) : undefined;
return message;
},
};
function createBaseNLPSpec() {
return { serverConfig: "", functions: [], partialResults: false, args: "", inputField: 0 };
}
export const NLPSpec = {
encode(message, writer = new BinaryWriter()) {
if (message.serverConfig !== "") {
writer.uint32(10).string(message.serverConfig);
}
for (const v of message.functions) {
NLPFunctionSpec.encode(v, writer.uint32(18).fork()).join();
}
if (message.partialResults !== false) {
writer.uint32(24).bool(message.partialResults);
}
if (message.args !== "") {
writer.uint32(34).string(message.args);
}
if (message.inputField !== 0) {
writer.uint32(40).int32(message.inputField);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseNLPSpec();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.serverConfig = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.functions.push(NLPFunctionSpec.decode(reader, reader.uint32()));
continue;
}
case 3: {
if (tag !== 24) {
break;
}
message.partialResults = reader.bool();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.args = reader.string();
continue;
}
case 5: {
if (tag !== 40) {
break;
}
message.inputField = reader.int32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
serverConfig: isSet(object.serverConfig) ? globalThis.String(object.serverConfig) : "",
functions: globalThis.Array.isArray(object?.functions)
? object.functions.map((e) => NLPFunctionSpec.fromJSON(e))
: [],
partialResults: isSet(object.partialResults) ? globalThis.Boolean(object.partialResults) : false,
args: isSet(object.args) ? globalThis.String(object.args) : "",
inputField: isSet(object.inputField) ? nLPSpec_NlpInputFieldFromJSON(object.inputField) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.serverConfig !== "") {
obj.serverConfig = message.serverConfig;
}
if (message.functions?.length) {
obj.functions = message.functions.map((e) => NLPFunctionSpec.toJSON(e));
}
if (message.partialResults !== false) {
obj.partialResults = message.partialResults;
}
if (message.args !== "") {
obj.args = message.args;
}
if (message.inputField !== 0) {
obj.inputField = nLPSpec_NlpInputFieldToJSON(message.inputField);
}
return obj;
},
create(base) {
return NLPSpec.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseNLPSpec();
message.serverConfig = object.serverConfig ?? "";
message.functions = object.functions?.map((e) => NLPFunctionSpec.fromPartial(e)) || [];
message.partialResults = object.partialResults ?? false;
message.args = object.args ?? "";
message.inputField = object.inputField ?? 0;
return message;
},
};
function createBaseNLPFunctionSpec() {
return { id: "", args: [] };
}
export const NLPFunctionSpec = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
for (const v of message.args) {
writer.uint32(18).string(v);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseNLPFunctionSpec();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.args.push(reader.string());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
args: globalThis.Array.isArray(object?.args) ? object.args.map((e) => globalThis.String(e)) : [],
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.args?.length) {
obj.args = message.args;
}
return obj;
},
create(base) {
return NLPFunctionSpec.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseNLPFunctionSpec();
message.id = object.id ?? "";
message.args = object.args?.map((e) => e) || [];
return message;
},
};
function createBaseEndpointSpec() {
return {
silenceTimeout: 0,
trailingSilenceHighProbability: 0,
trailingSilenceOkProbability: 0,
trailingSilenceNoEndpoint: 0,
utteranceTimeout: 0,
};
}
export const EndpointSpec = {
encode(message, writer = new BinaryWriter()) {
if (message.silenceTimeout !== 0) {
writer.uint32(13).float(message.silenceTimeout);
}
if (message.trailingSilenceHighProbability !== 0) {
writer.uint32(21).float(message.trailingSilenceHighProbability);
}
if (message.trailingSilenceOkProbability !== 0) {
writer.uint32(29).float(message.trailingSilenceOkProbability);
}
if (message.trailingSilenceNoEndpoint !== 0) {
writer.uint32(37).float(message.trailingSilenceNoEndpoint);
}
if (message.utteranceTimeout !== 0) {
writer.uint32(45).float(message.utteranceTimeout);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseEndpointSpec();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 13) {
break;
}
message.silenceTimeout = reader.float();
continue;
}
case 2: {
if (tag !== 21) {
break;
}
message.trailingSilenceHighProbability = reader.float();
continue;
}
case 3: {
if (tag !== 29) {
break;
}
message.trailingSilenceOkProbability = reader.float();
continue;
}
case 4: {
if (tag !== 37) {
break;
}
message.trailingSilenceNoEndpoint = reader.float();
continue;
}
case 5: {
if (tag !== 45) {
break;
}
message.utteranceTimeout = reader.float();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
silenceTimeout: isSet(object.silenceTimeout) ? globalThis.Number(object.silenceTimeout) : 0,
trailingSilenceHighProbability: isSet(object.trailingSilenceHighProbability)
? globalThis.Number(object.trailingSilenceHighProbability)
: 0,
trailingSilenceOkProbability: isSet(object.trailingSilenceOkProbability)
? globalThis.Number(object.trailingSilenceOkProbability)
: 0,
trailingSilenceNoEndpoint: isSet(object.trailingSilenceNoEndpoint)
? globalThis.Number(object.trailingSilenceNoEndpoint)
: 0,
utteranceTimeout: isSet(object.utteranceTimeout) ? globalThis.Number(object.utteranceTimeout) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.silenceTimeout !== 0) {
obj.silenceTimeout = message.silenceTimeout;
}
if (message.trailingSilenceHighProbability !== 0) {
obj.trailingSilenceHighProbability = message.trailingSilenceHighProbability;
}
if (message.trailingSilenceOkProbability !== 0) {
obj.trailingSilenceOkProbability = message.trailingSilenceOkProbability;
}
if (message.trailingSilenceNoEndpoint !== 0) {
obj.trailingSilenceNoEndpoint = message.trailingSilenceNoEndpoint;
}
if (message.utteranceTimeout !== 0) {
obj.utteranceTimeout = message.utteranceTimeout;
}
return obj;
},
create(base) {
return EndpointSpec.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseEndpointSpec();
message.silenceTimeout = object.silenceTimeout ?? 0;
message.trailingSilenceHighProbability = object.trailingSilenceHighProbability ?? 0;
message.trailingSilenceOkProbability = object.trailingSilenceOkProbability ?? 0;
message.trailingSilenceNoEndpoint = object.trailingSilenceNoEndpoint ?? 0;
message.utteranceTimeout = object.utteranceTimeout ?? 0;
return message;
},
};
function createBaseVadSpec() {
return { threshold: 0, trailingSilence: 0, minSpeech: 0, utteranceTimeout: 0 };
}
export const VadSpec = {
encode(message, writer = new BinaryWriter()) {
if (message.threshold !== 0) {
writer.uint32(13).float(message.threshold);
}
if (message.trailingSilence !== 0) {
writer.uint32(21).float(message.trailingSilence);
}
if (message.minSpeech !== 0) {
writer.uint32(29).float(message.minSpeech);
}
if (message.utteranceTimeout !== 0) {
writer.uint32(37).float(message.utteranceTimeout);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseVadSpec();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 13) {
break;
}
message.threshold = reader.float();
continue;
}
case 2: {
if (tag !== 21) {
break;
}
message.trailingSilence = reader.float();
continue;
}
case 3: {
if (tag !== 29) {
break;
}
message.minSpeech = reader.float();
continue;
}
case 4: {
if (tag !== 37) {
break;
}
message.utteranceTimeout = reader.float();