Coder Social home page Coder Social logo

google-cloud-tts-android's Introduction

Google Cloud Platform TTS use API-KEY on Android.

How to use it?

Step 1: Download file

git clone https://github.com/changemyminds/Google-Cloud-TTS-Android.git

Step 2: Set up API Key

Go to here and change "YOUR_API_KEY" to your Google Cloud API Key.

debug{
    buildConfigField "String", "API_KEY", "\"YOUR_API_KEY\""
}

p.s If you want test your API key by JUnit, go to here and change "YOUR_API_KEY" to test.

Note
If you don't know the Google API Key, please see Google document.

Here prompt the Google API KEY setting.
(1) Got to google console cloud dashboard
(2) Click upper left corner menu and select 'APIs & Services' choose the Credentials.
image
(3) Add CREATE CREDENTIALS and select API Key that will create the no restrict key.
image
(4) Don't forget your API-Key Application restrictions and API restrictions must select None and Don't restrict key.
image

Step 3: Run app

image

Google-Cloud-TTS-Android libs

How to install it ?

Step 1. Add the JitPack repository in your root build.gradle

buildscript {
    ...
}

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency in your app build.gradle

android {
    ...
}

dependencies {
    implementation 'com.github.changemyminds:Google-Cloud-TTS-Android:1.0.2'
}

How to use it ?

See the below sample.

// Set the ApiKey and create GoogleCloudTTS.
GoogleCloudTTS googleCloudTTS = GoogleCloudTTSFactory.create("YOUR_API_KEY");

// Load google cloud VoicesList and select the languageCode and voiceName with index (0 ~ N).
VoicesList voicesList = googleCloudTTS.load();
String languageCode = voicesList.getLanguageCodes()[0];
String voiceName = voicesList.getVoiceNames(languageCode)[0];

// Set languageCode and voiceName, Rate and pitch parameter.
googleCloudTTS.setVoiceSelectionParams(new VoiceSelectionParams(languageCode, voiceName))
    .setAudioConfig(new AudioConfig(AudioEncoding.MP3, 0.35f , 10f));
    
// start speak
googleCloudTTS.start("you want speak something");

// stop speak
googleCloudTTS.stop();

// pause speak
googleCloudTTS.pause();

// resume speak
googleCloudTTS.resume();

Support Language

Test language and voice

If you want to test voice or find support language, you can go here to test online.

Reference

Google Cloud Java Issue
Google Cloud Text-to-speech
OkHttp
Gson

google-cloud-tts-android's People

Contributors

changemyminds avatar

Watchers

James Cloos avatar

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.