How to integrate Google Cloud Text-to-Speech with Meteor - meteor

I'm trying to use Google Cloud Text-to-Speech API in Meteor app, but get an error on the Meteor console and crash when trying to use the import function described in the instructions:
("Uncaught TypeError: Cannot convert undefined or null to object at Function.getPrototypeOf (<anonymous>)")
Here's what I've done (in app directory) before starting meteor:
meteor npm install google-tts-api
export GOOGLE_APPLICATION_CREDENTIALS="/data/authenticationinfo.json"
The problems are related to the inclusion of this line at the top of my js file:
import textToSpeech from '#google-cloud/text-to-speech';
This line cause the following Meteor startup error on the console:
"Unable to resolve some modules: "http2" in /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
Actually, I ran the above command, but it has no effect. When I run start the app, it crashes quickly with the error :
Uncaught TypeError: Cannot convert undefined or null to object
at Function.getPrototypeOf ()
at module.exports (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:91277)
at index.js (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:86991)
at fileEvaluate (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:346)
at Module.require (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:248)
at require (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:268)
at jwtclient.js (modules.js?hash=59a3378abff937a73bf3a9865d654fce71b9583a:79821)
at fileEvaluate (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:346)
at Module.require (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:248)
at require (modules-runtime.js?hash=b819d45cbf32aff410d740fac0364cb4088cd3f2:268)
I have tested it on a barebones node app, and my Google authentication json file works fine, so that's definitely not the problem.
I realize there are are some Meteor packages for Google TTS, but they're really old and use Google Translate (which won't work for long) instead of the new cloud services.

So, it turns out the import has to happen on the server side, NOT the client side.

Related

How to add Firebase SDK version 9 to a Service Worker Chrome Extension Manifest Version MV3?

I found this video How to add Firebase to a Service Worker - Chrome Extension Manifest Version MV3 created at 26 Jan 2021
Importing the files in the same way he did in the video I got the following error:
"SyntaxError: Unexpected token 'export'"
To try solve this I changed manifest.json to include "type"="module" (because firebase SDK version 9 uses es module)
"background": {
"service_worker": "firebase.js",
"type": "module"
},
And now the error is:
"importScripts() of new scripts after service worker installation is not allowed"
So I dowloaded to the extension https://www.gstatic.com/firebasejs/9.10.0/firebase-app.js to include Firebase static js files in the extension in a folder called firebase and try to import as follows.
import * as firebase from "../firebase/firebase-app.js";
...
firebase.initializeApp(firebaseConfig);
Also tried:
import { initializeApp } from "../firebase/firebase-app.js";
...
initializeApp(firebaseConfig);
But in both cases I get the following errors:
FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
DevTools failed to load source map: Could not load content for chrome-extension://hoopapahcqwsdaerotpablmamhgdbhga/firebase/firebase-app.js.map: System error: net::ERR_FILE_NOT_FOUND
Any advice?
I think I found the solution to the issue, at the end of firebase-app.js is the following:
//# sourceMappingURL=firebase-app.js.map
So I went to https://www.gstatic.com/firebasejs/9.10.0/firebase-app.js.map and copy its content in a file named firebase-app.js.map and place it in the same folder that firebase-app.js and now the code works ok.

Cannot read property 'manifest' of undefined Error in Ionic

I am trying to login Facebook with Firebase. I have installed all the libraries required and completed the required configuration. Still, whenever I try to start my app it is giving me this error:
(node:11160) UnhandledPromiseRejectionWarning: TypeError: Cannot read
property 'manifest' of undefined
at removeOldOptions (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova- universal-links-plugin\hooks\lib\android\manifestWriter.js:48:32)ished in 37.33 s
at Object.writePreferences
(C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-
plugin\hooks\lib\android\manifestWriter.js:27:19)
at activateUniversalLinksInAndroid
(C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:65:25)
at C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:45:11
at Array.forEach (<anonymous>)
at run (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:41:17)
at module.exports (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:18:3)
at runScriptViaModuleLoader (C:\Users\Dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:188:18)
at runScript (C:\Users\Dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:164:16)
(node:11160) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Able to solve this with below changes :
Just go to the below file in Ionic
plugins/cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js
I fixed issue by changing pathToManifest as below:
var pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'cordovaLib', 'AndroidManifest.xml');
to
var pathToManifest = path.join(
cordovaContext.opts.projectRoot,
'platforms',
'android',
'app',
'src',
'main',
'AndroidManifest.xml');
For anyone that's looking into this these days, the actual fix for this was published by someone which you can pull in as a cordova plugin https://github.com/nordnet/cordova-universal-links-plugin/issues/133#issuecomment-369260863
#okaufmann you can use the changed version of the plugin. since it's not merged in the nordnet repository, you must remove the plugin and install again using:
cordova plugin add https://github.com/walteram/cordova-universal-links-plugin
After doing...
cordova plugin rm cordova-universal-links-plugin
cordova plugin add https://github.com/walteram/cordova-universal-links-plugin
.. my project was able to build successfully.
You need to update the AndroidManifest path in the plugin, which seems to be outdated. Check out this:
https://github.com/nordnet/cordova-universal-links-plugin/issues/146

Vuejs2 firebase with electron error

I have configured electron with vuejs and i would like to add firebae to my project so i have
In my main.js
import * as firebase from 'firebase'
let firebasconfig = {
//config from firebase project
};
Vue.prototype.$firebase = firebase.initializeApp(firebasconfig);
But now am getting an error
Error: Failed to load gRPC binary module because it was not installed
for the current system
Expected directory: electron-v1.8-linux-x64-glibc
Found: [node-v59-linux-x64-glibc]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module
I have tried running rebuild but still fails
What elese do i need to do for this to work
I encouter the same issue with
vue-electron 1.0.6
firebase 5.4.2
vuefire 1.4.5
node 6.10.3
The following manipulation has worked for me. I have downgraded :
firebase to 4.6.0
vuefire to 1.4.4
Then ran npm rebuild and yarn and now it works.
I'm not sure all the things I have done are necessary. But for sure it looks like a problem with firebase.

functions: Error from emulator. Error occurred while parsing your function triggers

I'm testing firebase functions locally in my existing project in typescript. When i run following command, i always get typeerror even though i can upload it to firebase project. the error always occured after typescript compile to js
firebase serve --only functions
TypeError: Cannot read property 'username' of undefined
at Object. (C:\Users\phone\Desktop\VMS\mynewvm_functions\functions\lib\email\index.js:8:52)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\phone\Desktop\VMS\mynewvm_functions\functions\lib\index.js:19:15)
at Module._compile (module.js:635:30)
import * as functions from 'firebase-functions';
import * as nodemailer from 'nodemailer';
const accountname = functions.config().emailaccount.username;
const accountpassword = functions.config().emailaccount.password;
/* smtp configuration */
I already set emailaccount in my project, below is my code.
firebase functions:config:set emailaccount.username="email#domain.com"
emailaccount.password="mypassword"
Please note that it is working fine when uploaded to firebase functions but it's not when serving locally. what can i do to make it work locally?
Finally, I just replace all my credentials with actual values instead of getting from firebase config. And I cd to functions folder and type 'npm start'. it look like when i run 'firebase serve --only functions', it doesn't apply with recent changes so give me the same error until I type 'npm start' which will run tsc and firebase shell, stop it (ctrl+c) then type 'firebase serve --only functions' again. Fyi, I created my current firebase functions project using firebase cli and typescript.
firebase cli - 3.18.4
firebase functions - ^1.0.1
firebase admin - 5.12.0
#google-cloud/storage - 1.6
After testing for long period of time, I decided to put username, password and tokens directly in my functions for local testing although I don't really like this idea and I change back to functions.config().. when i deploy to firebase. Thanks for #Frank for answers
There is no built-in config parameter called emailaccount, so it seems you defined it yourself.
The local environment does not automatically contain these variables. You will actually have to define them in a file called runtimeconfig.json. An easy way to do that is shown here:
cd functions
firebase functions:config:get > .runtimeconfig.json

Install of Iron Router for Meteor 1.0.2.1 just does not work

So I've done the todo and leaderboard tutorials and now am excited to begin routing - seems like iron router is the way to go so I install it to my project using
mrt add iron-router
Seems to install ok so I start meteor and navigate to localhost:3000 and my console lights up with:
Uncaught TypeError: undefined is not a function
helpers.js:141 Uncaught TypeError: Cannot read property 'prototype' of undefined
router.js:61 Uncaught TypeError: undefined is not a function
global-imports.js?784bc180a149e4c10dff977a7f114df67d9952c6:3 Uncaught TypeError: Cannot read property 'RouteController' of undefined
template.tutorialexample.js?e119ff8df948cfe8167f49eb28794995a594841c:2 Uncaught ReferenceError: Template is not defined
tutorialexample.js?a4ef596255404350be2cc45303caea02f934cd17:1 Uncaught ReferenceError: Meteor is not defined
Mind you this is a default app, haven't touched a thing.
So if someone could point me in the right direction that would be great. I did read somewhere that I should be using 0.8.2 version of iron router - and I then did change my smart.json file to contain:
{
"packages": {
"iron-router": "0.8.2"
}
}
and then did meteor update etc but still no luck. So any help anyone could provide would be great.
Meteor has changed quite a bit & the instructions/tutorial you've been following is a bit dated.
Previously mrt was part of the meteorite packaging system, from Meteor 0.9.0 it has been integrated directly into meteor.
So now you do:
meteor add iron:router
To add it to your project. Once you start your app up it should present a basic template on how to use it.

Resources