/universal-translator

Demo app using Firebase and Google Cloud products to implement a "universal translator"

Primary LanguageKotlinApache License 2.0Apache-2.0

BabelFire - a universal translator

This is a Firebase and Google Cloud powered app used for demo purposes. It implements a "universal translator", where an Android client app records some speech, uploads it to Google Cloud, and receives translations in a variety of languages. A client web app also receives the translates and speaks them out loud using the browser's speech synthesis API.

This is a rewrite of Jen Tong's similar project.

What's here

At the top level, you'll find:

  • android - Android app that receives speech and uploads it to Google Cloud for processing
  • backend - TypeScript for Cloud Functions on the backend
  • web - and the JS / HTML translation viewer

Setup

This setup assumes you are already familiar with how Firebase and Google Cloud projects work.

Project setup

  1. Create a Firebase project in the Firebase console
  2. Go to the Authentication product tab and enable Google authentication.
  3. Go to the Database product tab and enable Cloud Firestore.
  4. Go to the Storage product tab and enable Cloud Storage.
  5. Enable Blaze plan billing on the project (required for the Google Cloud APIs used here)
  6. In the Cloud console for the same project, enable both the Cloud Translation API and the Cloud Speech-to-Text API.
  7. Install the Firebase CLI
  8. Clone this repo.

Backend project setup

  1. cd backend
  2. firebase use --add, then select the newly created project, and give it the alias "default"
  3. cd functions; npm install to set up the Cloud Functions node project.
  4. firebase deploy to deploy Cloud Functions code, Firestore security rules, and Cloud Storage security rules
  5. Optional - if you want to run the scripts in functions/dev, download a service account and place it in service-account-credentials.json in the functions folder.

Web app setup

  1. cd web
  2. firebase use --add, then select the newly created project, and give it the alias "default"
  3. firebase deploy to deploy the web app to Firebase Hosting
  4. Note the given URL for the web site

Android app setup

  1. cd android
  2. Add the app to your project in the Firebase console, and be sure to provide the SHA-1 of your debug signing key
  3. Download the google-services.json file for your project from the Firebase console, move it to the app folder
  4. ./gradlew assembleDebug
  5. Install the APK on your emulator or device

Use the demo app

  1. Open the web app using the URL given after it was deployed (*.firebaseapp.com)
  2. Select the language in which you want to hear a translation
  3. Launch the Android app
  4. Select the language you want to translate from the dropdown
  5. Push the record button, speak in that language, then push the button again
  6. Wait for the translations to appear in both the Android app and the web app. The web app will also speak it out loud in the selected language

Firebase and Google Cloud products used

Contributing

Please read and follow the steps in the CONTRIBUTING.md

License

The code in this project is licensed under the Apache License 2.0.

Copyright 2018 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Disclaimer

This is not an officially supported Google product.