如何将 Google Cloud Text-to-Speech 与 Meteor 集成
How to integrate Google Cloud Text-to-Speech with Meteor
我正在尝试在 Meteor 应用程序中使用 Google Cloud Text-to-Speech API,但是在 Meteor 控制台上出现错误并在尝试使用中描述的导入功能时崩溃说明:
("Uncaught TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>)")
这是我在启动 meteor 之前所做的(在应用程序目录中):
meteor npm install google-tts-api
导出 GOOGLE_APPLICATION_CREDENTIALS="/data/authenticationinfo.json"
问题与我的 js 文件顶部包含这一行有关:
import textToSpeech from '@google-cloud/text-to-speech';
此行导致控制台出现以下 Meteor 启动错误:
"Unable to resolve some modules: "http2" 在 /app/node_modules/@grpc/grpc-js/build/src/channel.js (web.browser)
If you notice problems related to these missing modules, consider running:
meteor npm install --save meteor-node-stubs
其实我运行上面的命令,但是没有效果。当我 运行 启动应用程序时,它很快崩溃并出现错误:
未捕获类型错误:无法将未定义或 null 转换为对象
在 Function.getPrototypeOf ()
在 module.exports (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:91277)
在 index.js (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:86991)
在 fileEvaluate (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:346)
在 Module.require(模块-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:248)
在需要时(模块-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:268)
在 jwtclient.js (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:79821)
在 fileEvaluate (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:346)
在 Module.require(模块-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:248)
在 require (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:268)
我已经在准系统节点应用程序上对其进行了测试,我的 Google 身份验证 json 文件工作正常,所以这绝对不是问题所在。
我知道有一些用于 Google TTS 的 Meteor 包,但它们真的很旧并且使用 Google T运行slate(不会长期工作)而不是新的云服务。
所以,事实证明导入必须发生在服务器端,而不是客户端。
我正在尝试在 Meteor 应用程序中使用 Google Cloud Text-to-Speech API,但是在 Meteor 控制台上出现错误并在尝试使用中描述的导入功能时崩溃说明:
("Uncaught TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>)")
这是我在启动 meteor 之前所做的(在应用程序目录中):
meteor npm install google-tts-api
导出 GOOGLE_APPLICATION_CREDENTIALS="/data/authenticationinfo.json"
问题与我的 js 文件顶部包含这一行有关:
import textToSpeech from '@google-cloud/text-to-speech';
此行导致控制台出现以下 Meteor 启动错误: "Unable to resolve some modules: "http2" 在 /app/node_modules/@grpc/grpc-js/build/src/channel.js (web.browser)
If you notice problems related to these missing modules, consider running:
meteor npm install --save meteor-node-stubs
其实我运行上面的命令,但是没有效果。当我 运行 启动应用程序时,它很快崩溃并出现错误:
未捕获类型错误:无法将未定义或 null 转换为对象 在 Function.getPrototypeOf () 在 module.exports (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:91277) 在 index.js (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:86991) 在 fileEvaluate (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:346) 在 Module.require(模块-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:248) 在需要时(模块-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:268) 在 jwtclient.js (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:79821) 在 fileEvaluate (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:346) 在 Module.require(模块-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:248) 在 require (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:268)
我已经在准系统节点应用程序上对其进行了测试,我的 Google 身份验证 json 文件工作正常,所以这绝对不是问题所在。
我知道有一些用于 Google TTS 的 Meteor 包,但它们真的很旧并且使用 Google T运行slate(不会长期工作)而不是新的云服务。
所以,事实证明导入必须发生在服务器端,而不是客户端。