Coder Social home page Coder Social logo

libtts's Introduction

libTTS

libTTS is portable and simple text-to-speech library powered by Google Translate's Text-To-Speech service.

Google Translate already provides a full-fledged text-to-speech service for dynamically creating short text-to-speech files. However, due to restrictions of the service, it is not possible to play these files on external websites; a request to the text-to-speech API will give you a 404. More information on these restrictions can be found here.

This library encapsulates an <iframe> that loads the Google Translate Text-To-Speech url directly.

It looks like there are definitely some bugs with this (due to the way referers work) but it does appear to work on Chrome. In case you weren't aware, this project is a hack around Google's referer exclusion.

Examples

Check out http://christhebrews.github.io/libTTS/ for use!

Docs

libTTS creates a global variable TTS. Please check you namespaces!

TTS.say()

TTS.say(text) - pass a string to the text-to-speech engine.

TTS.say("Hello, World!");
// [TTS] Said: "Hello, World!"

Successfully spoken phrases will be printed to the console. Calling TTS.say() while another phrase is being spoken will abort the previous audio playback. There is a currently a 100-character limit on the text string (imposed by Google). Text strings that exceed this limit will print a warning in the console.

TTS.maxLength

integer - the allowed max length of a string passed to TTS.say()

TTS.maxLength;
// 100

Please use TTS.maxLength for validation checks against string lengths before passing them to TTS.say()

TTS.el

jQuery element - the iframe element that plays the audio.

TTS.el;
// jQuery <iframe> element

Dependencies

libTTS currently requires jQuery.

libtts's People

Contributors

cbrews avatar

Watchers

 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.