Code Monkey home page Code Monkey logo

android-speech-api-sample's Introduction

Google Cloud Speech API examples

This directory contains Android example that uses the Google Cloud Speech API.

Prerequisites

Enable the Speech API

If you have not already done so, enable the Google Speech API for your project. You must be whitelisted to do this.

Set Up to Authenticate With Your Project's Credentials

This Android app uses JSON credential file locally stored in the resources. You should not do this in your production app. Instead, you should set up your own backend server that authenticates app users. The server should delegate API calls from your client app. This way, you can enforce usage quota per user. Alternatively, you should get the access token on the server side, and supply client app with it. The access token will expire in a short while.

In this sample, we just put the Service Account in the client for ease of use. The app still gets an access token using the service account credential, and use the token to call the API, so you can see how to do so.

In order to try out this sample, visit the Cloud Console, and navigate to: API Manager > Credentials > Create credentials > Service account key > New service account. Create a new service account, and download the JSON credentials file. Put the file in the app resources as app/src/main/res/raw/credential.json.

Again, you should not do this in your production app.

See the Cloud Platform Auth Guide for more information.

Test

Before running tests update the following environment variable with the service account:

GOOGLE_APPLICATION=service-account.json

This environment variable will be used to update the service account used here app/src/main/res/raw/credential.json.

Run tests by using:

gradle test

Build signed release

This step is optional.

This sample uses ProGuard to decrease the number of methods generated by the gRPC library. It is enabled by default for release build. If you want to build it, change the path, alias and passwords of the keystore file specified in gradle.properties.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.