Code Monkey home page Code Monkey logo

ispeech's Introduction

Ruby interface to Ispeech's API for generating speech from text. More info on their API at http://www.ispeech.org/api/

Installation

gem install ispeech

Loading

require 'ispeech'

Config

Automatically looks for a config/ispeech.yml file. Configuration only requires the 'api_key'

Manual configuration

Ispeech.config = Ispeech::Config.new('some_api_key_hash')

or

Ispeech.config = Ispeech::Config.read(path_to_my_own_yaml_config_file)

Usage

Get the voice service object:

service = Ispeech.voice_service 

or

service = Ispeech::VoiceService.new(my_config_object)

Generate sounds

response = service.generate_sound('speak this text', language_or_voice_options)

or

response = service.generate_with_voice('speak this text', my_voice_object)

Language and voice options

All available voices are defined in voices/default.rb

You can specificy language, gender, voice name in any combination

response = service.generate_sound('speak this text', {:language => :en, :gender => :male, :speaker => :usenglishfemale})

If you have access to different set of voice there are rake tasks to generate a different voice map and any customization of the voice map should be easy. Refer to the spec for details of that.

Saving generated sounds

The response is saved to a tempfile which can be moved, copied or otherwise streamed.

response = service.generate_sound('speak this text')
tempfile = response.download_to_tempfile

FileUtils.mv(tempfile.path, 'speak_this_text.mp3')

Mocking

For convinence purposes you can use an inbuilt mock to avoid web request while testing.

require 'ispeech/mock'
Ispeech::Mock.enable!

Turning off

Ispeech::Mock.disable!

Expectations

Only two expectations can be set

Ispeech::VoiceService.expect_ok_response

or

Ispeech::VoiceService.expect_error_response

Copyright

Copyright (c) 2012 Birkir A. Barkarson. See LICENSE for details.

ispeech's People

Contributors

birkirb avatar

Watchers

James Cloos avatar Tatiana Tylosky 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.