From d691e0dec2f07739901d39bcdc2c8433ab722ee7 Mon Sep 17 00:00:00 2001 From: Justin Rosenthal Date: Thu, 6 Apr 2017 16:04:47 +0200 Subject: [PATCH 1/2] Fix typo: credentails --> credentials --- js/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/README.md b/js/README.md index 7e06fc4..2c64ea9 100644 --- a/js/README.md +++ b/js/README.md @@ -15,7 +15,7 @@ 0. Log in to the [Cloud Console](https://console.cloud.google.com). 0. Go to **API Manager** -> **Library** and enable both the Google Cloud Translation API and the Google Cloud Speech API. 0. Go to **IAM & Admin** -> **Service Accounts**. -0. Create a new service account with **Project -> Viewer** role. Furnish a new private key, with key type json. A credential file will download. Rename it to `service-account-credentails.json` and copy it to `/functions`. +0. Create a new service account with **Project -> Viewer** role. Furnish a new private key, with key type json. A credential file will download. Rename it to `service-account-credentials.json` and copy it to `/functions`. 0. Deploy the Cloud Functions [with the Firebase CLI](https://firebase.google.com/docs/functions/get-started) ## Files @@ -28,4 +28,4 @@ - [Firebase Database](https://firebase.google.com/docs/database) - [Firebase Storage](https://firebase.google.com/docs/storage/) -- [Cloud Functions for Firebase](https://firebase.google.com/docs/functions/) \ No newline at end of file +- [Cloud Functions for Firebase](https://firebase.google.com/docs/functions/) From 7a0c0f2d8685f31556349d903daef3b90ef42614 Mon Sep 17 00:00:00 2001 From: Justin Rosenthal Date: Thu, 6 Apr 2017 16:12:47 +0200 Subject: [PATCH 2/2] Replace hardcoded bucket with value from functions.config --- js/functions/index.done.js | 3 ++- js/functions/index.js | 3 ++- js/functions/index.livecode.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/js/functions/index.done.js b/js/functions/index.done.js index bc6b728..f233c93 100644 --- a/js/functions/index.done.js +++ b/js/functions/index.done.js @@ -33,8 +33,9 @@ exports.onUpload = functions.database var language = data.language ? data.language : "en"; var encoding = data.encoding ? data.encoding : "FLAC"; var sampleRate = data.sampleRate ? data.sampleRate : 16000; + var storageBucket = functions.config().firebase.storageBucket; - return speech.recognize(`gs://mimming-babelfire.appspot.com/${data.fullPath}`, { + return speech.recognize(`gs://${storageBucket}/${data.fullPath}`, { encoding: encoding, sampleRate: sampleRate, languageCode: language diff --git a/js/functions/index.js b/js/functions/index.js index bc6b728..f233c93 100644 --- a/js/functions/index.js +++ b/js/functions/index.js @@ -33,8 +33,9 @@ exports.onUpload = functions.database var language = data.language ? data.language : "en"; var encoding = data.encoding ? data.encoding : "FLAC"; var sampleRate = data.sampleRate ? data.sampleRate : 16000; + var storageBucket = functions.config().firebase.storageBucket; - return speech.recognize(`gs://mimming-babelfire.appspot.com/${data.fullPath}`, { + return speech.recognize(`gs://${storageBucket}/${data.fullPath}`, { encoding: encoding, sampleRate: sampleRate, languageCode: language diff --git a/js/functions/index.livecode.js b/js/functions/index.livecode.js index b0a1904..57ea052 100644 --- a/js/functions/index.livecode.js +++ b/js/functions/index.livecode.js @@ -20,9 +20,10 @@ exports.onUpload = functions.database var language = data.language ? data.language : "en"; var encoding = data.encoding ? data.encoding : "FLAC"; var sampleRate = data.sampleRate ? data.sampleRate : 16000; + var storageBucket = functions.config().firebase.storageBucket; // Send the file to the Cloud Speech API to get the transcript - return speech.recognize(`gs://mimming-babelfire.appspot.com/${data.fullPath}`, { + return speech.recognize(`gs://${storageBucket}/${data.fullPath}`, { encoding: encoding, sampleRate: sampleRate, languageCode : language