0.3.2 • Published 4 years ago

google-cloud-text-to-speech v0.3.2

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

google-cloud-text-to-speech: React JS

A simple Google Cloud Text-to-Speech integration for ReactJS

New Features!

  • Enter the text or state defined text gives voice audio of the entered text.
  • Supports all voices and languages which avilables in cloud text to speech. (Link)

Tech

  • ReactJs - The component integration and run on the web app.

Installation

npm install google-cloud-text-to-speech --save

Demo

Try it on CodeSandbox

Usage

import TextToSpeech from 'google-cloud-text-to-speech';

Example Code

import React from 'react';
import TextToSpeech from 'google-cloud-text-to-speech';

class App extends React.Component {

  constructor() {
    super();
    this.state = {
      text: 'Enter text to convert in to speech',
      voiceList: [
        { name: 'English (US) Male', value: 'en-US-Wavenet-A' },
        { name: 'English (US) Female', value: 'en-US-Wavenet-E' },
      ],
      defaultVoice: 'en-US-Wavenet-E',
      secretKey: '' // get your google cloud access key to text-to-speech
    }
  }

  render() {
    return (<div>
        <TextToSpeech
          text={this.state.text}
          voiceList={this.state.voiceList}
          defaultVoice={this.state.defaultVoice}
          secretKey={this.state.secretKey}
          showAudioControl={false}
          showSettings={false}
          type="Page"
        >
      </TextToSpeech>
    </div>
  );
  }
}

export default App;

Input Parameters

ParameterTypeRequiredDescription
textStringYesThis is the text that will get converted into Audio
voiceListArrayNoIf not provided then the feature takes up the default array provided
defaultVoiceStringNoIf not provided then the feature takes up the default voice provided
secretkeyStringYesThis is the google cloud key required to call the google cloud API
showAudioControlBooleanYesTakes 'false' as default , if 'false' then shows only play/pause, if 'true' shows an audio player
typeStringYesTakes two values, "Modal" and "Page", "Page" as default, "Page" takes up 50% width while "Modal" takes up 100% width
toolTipNameStringNoButton data-tooltip name
removeToolTip()FunctionNoTo perform operations of tooltip remove
stopReadOutPlaying()FunctionnoTo manage button play and stop
readOutIconStyleStringnoTo add custome css classes
buttonIconString / IconyesPass button text Play or pass font icon
showSettingsBooleanYesTo display custom select voice and adjust voice settings
autoPlayBooleanYesTo autoplay the voice once compoment loads

Adding VoiceList Example

voiceList: [
        { name: 'English (US) Male', value: 'en-US-Wavenet-A' },
        { name: 'English (US) Female', value: 'en-US-Wavenet-E' },
      ]

VoiceList Parameters

ParameterTypeRequiredDescription
nameStringYesThis is the name of the voice that shows up in the options for voices, can be changed as per user wants to display
valueStringYesActual name of voice type which is called in the google cloud, cannot be other than the given voices

Reference

License

MIT

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago