This is ruby gem of Open JTalk.
This ruby gem has "Battery Included" philosophy. You don't need extra gems or libs except writing a result as mp3.
Add this line to your application's Gemfile:
gem 'open_jtalk-ruby', git: 'git://github.com/sunny4381/open_jtalk-ruby.git'
And then execute:
$ bundle install
Or install it yourself as:
$ git clone git://github.com/sunny4381/open_jtalk-ruby.git
$ cd open_jtalk-ruby
$ gem build open_jtalk-ruby.gemspec
$ gem install open_jtalk-ruby-0.4.gem
require 'open_jtalk'
text = "こんにちは。".encode("UTF-8")
OpenJtalk.load(OpenJtalk::Config::Mei::NORMAL) do |openjtalk|
header, data = openjtalk.synthesis(openjtalk.normalize_text(text))
OpenJtalk::WaveFileWriter.save("a.wav", header, data)
end
open_jtalk-ruby contains these configurations:
- OpenJtalk::Config::Mei::NORMAL: this is default configuration of female model.
- OpenJtalk::Config::Mei::ANGRY
- OpenJtalk::Config::Mei::BASHFUL
- OpenJtalk::Config::Mei::HAPPY
- OpenJtalk::Config::Mei::SAD
- OpenJtalk::Config::Mei::FAST
- OpenJtalk::Config::Mei::SLOW
- OpenJtalk::Config::Mei::HIGH
- OpenJtalk::Config::Mei::LOW
- OpenJtalk::Config::Nitech::NORMAL: this is default configuration of male model.
- OpenJtalk::Config::Nitech::FAST
- OpenJtalk::Config::Nitech::SLOW
- OpenJtalk::Config::Nitech::HIGH
- OpenJtalk::Config::Nitech::LOW
open_jtalk-ruby contains these writers:
- OpenJtalk::WaveFileWriter: WAV File Writer.
- OpenJtalk::Mp3FileWriter: MP3 File Writer. this writer requires 'lame'(>= 0.0.3) and
libmp3lame.so
.
You can simply set OpenJtalk::Mp3StreamingSynthesizer
instance to your controller's response_body
if you are developing rails application.
response.headers['Content-Type'] = 'audio/mp3'
response_body = OpenJtalk::Mp3StreamingSynthesizer.new(config, text)
A controller responds mp3 data stream in chunked encoding.
open_jtalk-ruby supports only UTF-8.
Platforma | Support |
---|---|
Windows | NO |
Linux | YES |
Mac | YES |
Other Unix | Meybe YES |
- Fork it ( https://github.com/sunny4381/open_jtalk-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
open_jtalk-ruby contains several sub modules, and each module has released under its own license.
- open_jtalk-ruby is released under BSD 2 Clause.
- open_jtalk is released under Modified BSD license.
- hts_engine_api is released under Modified BSD license.
- MeCab is released under New BSD License.