diff --git a/src/v1/text_to_speech_client.ts b/src/v1/text_to_speech_client.ts index ddb64e62..19666a89 100644 --- a/src/v1/text_to_speech_client.ts +++ b/src/v1/text_to_speech_client.ts @@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1/text_to_speech_client_config.json`. @@ -135,22 +136,7 @@ export class TextToSpeechClient { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( diff --git a/src/v1beta1/text_to_speech_client.ts b/src/v1beta1/text_to_speech_client.ts index 6fc96d6c..db341d99 100644 --- a/src/v1beta1/text_to_speech_client.ts +++ b/src/v1beta1/text_to_speech_client.ts @@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; import * as path from 'path'; import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); /** * Client JSON configuration object, loaded from * `src/v1beta1/text_to_speech_client_config.json`. @@ -135,22 +136,7 @@ export class TextToSpeechClient { clientHeader.push(`${opts.libName}/${opts.libVersion}`); } // Load the applicable protos. - // For Node.js, pass the path to JSON proto file. - // For browsers, pass the JSON content. - - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); - this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath - ); + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings(