Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .kokoro/functions/speech-to-speech.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Set the folder in which the tests are run
env_vars: {
key: "PROJECT"
value: "functions/speech-to-speech"
value: "functions/speech-to-speech/functions/"
}

# Tell the trampoline which build file to use.
Expand Down
5 changes: 5 additions & 0 deletions functions/speech-to-speech/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": ""
}
}
65 changes: 65 additions & 0 deletions functions/speech-to-speech/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*

# Firebase cache
.firebase/

# Firebase config

# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
1 change: 1 addition & 0 deletions functions/speech-to-speech/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@

// This sample uses the UUID library to generate the output filename.
const uuid = require('uuid/v4');
const functions = require('firebase-functions');

const googleCloudProject = process.env.GOOGLE_CLOUD_PROJECT;
const supportedLanguageCodes = process.env.SUPPORTED_LANGUAGE_CODES.split(',');
const outputBucket = process.env.OUTPUT_BUCKET;
// The supportedLanguageCodes and outputBucket parameters take the value from
// environment variables by default.
const firebaseConfigured = typeof functions.config().playchat !== 'undefined';
const languageCodesParam = firebaseConfigured
? functions.config().playchat.supported_language_codes
: process.env.SUPPORTED_LANGUAGE_CODES;
const supportedLanguageCodes = languageCodesParam.split(',');
const outputBucket = firebaseConfigured
? functions.config().playchat.output_bucket
: process.env.OUTPUT_BUCKET;
const outputAudioEncoding = 'MP3';
const voiceSsmlGender = 'NEUTRAL';
// Declare the API clients as global variables to allow them to initiaze at cold start.
Expand All @@ -29,7 +38,7 @@ const textTranslationClient = getTextTranslationClient();
const textToSpeechClient = getTextToSpeechClient();
const storageClient = getStorageClient();

exports.speechTranslate = (request, response) => {
exports.speechTranslate = functions.https.onRequest((request, response) => {
let responseBody = {};

validateRequest(request)
Expand Down Expand Up @@ -105,7 +114,7 @@ exports.speechTranslate = (request, response) => {
console.error(error);
response.status(400).send(error.message);
});
};
});

// [START call_speech_to_text]
function callSpeechToText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
"homepage": "https://cloud.google.com/solutions/mobile/",
"license": "Apache-2.0",
"author": "Google LLC",
"private": true,
"node": "6",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"npm": ">= 4.0.0"
},
"files": [
"index.js"
],
Expand All @@ -27,14 +26,21 @@
"local-test": "mocha test/index.test.js",
"system-test": "mocha --timeout 20000 test/sample.integration.http.test.js",
"pretest": "sh test/updateFunctions.sh",
"test": "npm run local-test && npm run system-test"
"test": "npm run local-test && npm run system-test",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"@google-cloud/speech": "^2.1.0",
"@google-cloud/storage": "^2.0.3",
"@google-cloud/text-to-speech": "^0.4.0",
"@google-cloud/translate": "^2.1.2",
"uuid": "^3.3.2"
"uuid": "^3.3.2",
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.1.0"
},
"devDependencies": {
"@google-cloud/functions-emulator": "^1.0.0-beta.5",
Expand Down