Project

ispeech

0.01
No commit activity in last 3 years
No release in over 3 years
Ruby interface to Ispeech's API for generating speech from text. More info at http://www.ispeech.org/api/
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.9.0
>= 2.6.0
>= 1.8.0

Runtime

 Project Readme

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.