tts 0.4.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +65 -18
- data/README.rdoc +30 -2
- data/Rakefile +4 -12
- data/VERSION +1 -1
- data/bin/text2mp3 +14 -0
- data/bin/tts +14 -0
- data/example/gen_hello_world_en.rb +4 -0
- data/example/play_hello_world_en.rb +4 -0
- data/lib/tts.rb +35 -16
- data/spec/tts_spec.rb +37 -21
- data/tts.gemspec +28 -25
- metadata +26 -47
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: af37e331b198df603972e4c07d19daa4ccc7d55a
         | 
| 4 | 
            +
              data.tar.gz: 66f98e3464b6225dd47952d761a68d70997cdfae
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 0fdc70780ba7e6192dac717c8b1a100a8725505c7b926fb23b57ad61e3388e1fb8b01db7f4b059c4d6e2b646c4269d9b2f6d96747f1169b0e9902f1bbba95c0e
         | 
| 7 | 
            +
              data.tar.gz: 926c6d1505b967c7de629e198d4ece847729fc5ccdb1711e5d4f955198421ec907e223eab6d5aa4baa89c83682795bef1cd0e18cb0fa3d8b74292c67598d677d
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,28 +1,75 @@ | |
| 1 1 | 
             
            GEM
         | 
| 2 2 | 
             
              remote: http://rubygems.org/
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                 | 
| 5 | 
            -
                 | 
| 6 | 
            -
                 | 
| 7 | 
            -
                   | 
| 4 | 
            +
                addressable (2.4.0)
         | 
| 5 | 
            +
                builder (3.2.3)
         | 
| 6 | 
            +
                descendants_tracker (0.0.4)
         | 
| 7 | 
            +
                  thread_safe (~> 0.3, >= 0.3.1)
         | 
| 8 | 
            +
                diff-lcs (1.3)
         | 
| 9 | 
            +
                faraday (0.9.2)
         | 
| 10 | 
            +
                  multipart-post (>= 1.2, < 3)
         | 
| 11 | 
            +
                git (1.5.0)
         | 
| 12 | 
            +
                github_api (0.16.0)
         | 
| 13 | 
            +
                  addressable (~> 2.4.0)
         | 
| 14 | 
            +
                  descendants_tracker (~> 0.0.4)
         | 
| 15 | 
            +
                  faraday (~> 0.8, < 0.10)
         | 
| 16 | 
            +
                  hashie (>= 3.4)
         | 
| 17 | 
            +
                  mime-types (>= 1.16, < 3.0)
         | 
| 18 | 
            +
                  oauth2 (~> 1.0)
         | 
| 19 | 
            +
                hashie (3.6.0)
         | 
| 20 | 
            +
                highline (2.0.2)
         | 
| 21 | 
            +
                jeweler (2.3.9)
         | 
| 22 | 
            +
                  builder
         | 
| 23 | 
            +
                  bundler
         | 
| 8 24 | 
             
                  git (>= 1.2.5)
         | 
| 25 | 
            +
                  github_api (~> 0.16.0)
         | 
| 26 | 
            +
                  highline (>= 1.6.15)
         | 
| 27 | 
            +
                  nokogiri (>= 1.5.10)
         | 
| 28 | 
            +
                  psych
         | 
| 9 29 | 
             
                  rake
         | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                 | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
                 | 
| 17 | 
            -
                 | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 30 | 
            +
                  rdoc
         | 
| 31 | 
            +
                  semver2
         | 
| 32 | 
            +
                jwt (2.1.0)
         | 
| 33 | 
            +
                mime-types (2.99.3)
         | 
| 34 | 
            +
                mini_portile2 (2.4.0)
         | 
| 35 | 
            +
                multi_json (1.13.1)
         | 
| 36 | 
            +
                multi_xml (0.6.0)
         | 
| 37 | 
            +
                multipart-post (2.1.0)
         | 
| 38 | 
            +
                nokogiri (1.10.3)
         | 
| 39 | 
            +
                  mini_portile2 (~> 2.4.0)
         | 
| 40 | 
            +
                oauth2 (1.4.1)
         | 
| 41 | 
            +
                  faraday (>= 0.8, < 0.16.0)
         | 
| 42 | 
            +
                  jwt (>= 1.0, < 3.0)
         | 
| 43 | 
            +
                  multi_json (~> 1.3)
         | 
| 44 | 
            +
                  multi_xml (~> 0.5)
         | 
| 45 | 
            +
                  rack (>= 1.2, < 3)
         | 
| 46 | 
            +
                psych (3.1.0)
         | 
| 47 | 
            +
                rack (2.0.7)
         | 
| 48 | 
            +
                rake (12.3.2)
         | 
| 49 | 
            +
                rdoc (6.1.1)
         | 
| 50 | 
            +
                rspec (3.8.0)
         | 
| 51 | 
            +
                  rspec-core (~> 3.8.0)
         | 
| 52 | 
            +
                  rspec-expectations (~> 3.8.0)
         | 
| 53 | 
            +
                  rspec-mocks (~> 3.8.0)
         | 
| 54 | 
            +
                rspec-core (3.8.0)
         | 
| 55 | 
            +
                  rspec-support (~> 3.8.0)
         | 
| 56 | 
            +
                rspec-expectations (3.8.3)
         | 
| 57 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 58 | 
            +
                  rspec-support (~> 3.8.0)
         | 
| 59 | 
            +
                rspec-mocks (3.8.0)
         | 
| 60 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 61 | 
            +
                  rspec-support (~> 3.8.0)
         | 
| 62 | 
            +
                rspec-support (3.8.0)
         | 
| 63 | 
            +
                semver2 (3.4.2)
         | 
| 64 | 
            +
                thread_safe (0.3.6)
         | 
| 20 65 |  | 
| 21 66 | 
             
            PLATFORMS
         | 
| 22 67 | 
             
              ruby
         | 
| 23 68 |  | 
| 24 69 | 
             
            DEPENDENCIES
         | 
| 25 | 
            -
              bundler (~>  | 
| 26 | 
            -
              jeweler | 
| 27 | 
            -
               | 
| 28 | 
            -
             | 
| 70 | 
            +
              bundler (~> 2.0)
         | 
| 71 | 
            +
              jeweler
         | 
| 72 | 
            +
              rspec
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            BUNDLED WITH
         | 
| 75 | 
            +
               2.0.1
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -3,7 +3,8 @@ | |
| 3 3 | 
             
            Using the Google Translate service as the speech engine, this gem generates a .mp3 voice file from any given string.
         | 
| 4 4 |  | 
| 5 5 | 
             
            == Usage
         | 
| 6 | 
            -
             | 
| 6 | 
            +
             | 
| 7 | 
            +
                 require 'tts'
         | 
| 7 8 | 
             
                 # Will download "Hello World!.mp3" to your current directory
         | 
| 8 9 | 
             
                 # Supported languages: ["zh", "en", "it", "fr"] 
         | 
| 9 10 | 
             
                 "Hello World!".to_file "en"
         | 
| @@ -18,6 +19,33 @@ Using the Google Translate service as the speech engine, this gem generates a .m | |
| 18 19 | 
             
                 text = "People living on the east coast of England have been warned to stay away from their homes because of further high tides expected later. The tidal surge that hit the UK is said to have been the worst for 60 years, with thousands abandoning their homes."
         | 
| 19 20 | 
             
                 text.to_file "en"
         | 
| 20 21 |  | 
| 22 | 
            +
                 #Direct playback (require mpg123 installed and in PATH with a POSIX system)
         | 
| 23 | 
            +
                 "Established in 1853, the University of Melbourne is a public-spirited institution that makes distinctive contributions to society in research, learning and teaching and engagement.".play
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                 #Direct playback in other language (2 times)
         | 
| 26 | 
            +
                  "Oggi il tempo è buono, andiamo in gita di esso.".play("it", 2)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                 #RTL Arabic language
         | 
| 29 | 
            +
                 "اليوم كان الطقس جيدا، ونحن نذهب في نزهة منه.".play("ar")
         | 
| 30 | 
            +
                 
         | 
| 31 | 
            +
            == Direct play dependencies 
         | 
| 32 | 
            +
            You need to install `mpg123`
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                sudo apt-get install mpg123 #for debain based
         | 
| 35 | 
            +
                brew install mpg123 #mac
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            == CLI
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                tts "ruby is great"   # play the string.
         | 
| 40 | 
            +
                text2mp3 "中国上海天气不错" "zh" #create mp3 file.
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            == Versions
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            * 0.4 fixed issue that long text unable to generated.
         | 
| 45 | 
            +
            * 0.5 added all supported languages, added direct playback feature fixed some broken rspec.
         | 
| 46 | 
            +
            * 0.7 added CLI support
         | 
| 47 | 
            +
            * 0.7.1 fixed new google API
         | 
| 48 | 
            +
             | 
| 21 49 | 
             
            == Copyright
         | 
| 22 50 |  | 
| 23 | 
            -
            Copyright (c) 2011 Yiling Cao /  | 
| 51 | 
            +
            Copyright (c) 2011 Yiling Cao / and other supporters! Check LICENSE.txt
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem| | |
| 17 17 | 
             
              gem.name = "tts"
         | 
| 18 18 | 
             
              gem.homepage = "http://github.com/c2h2/tts"
         | 
| 19 19 | 
             
              gem.license = "MIT"
         | 
| 20 | 
            -
              gem.summary = " | 
| 21 | 
            -
              gem.description = " | 
| 20 | 
            +
              gem.summary = "Ruby convert text to mp3"
         | 
| 21 | 
            +
              gem.description = "(tts) Text -> Mp3 made easy."
         | 
| 22 22 | 
             
              gem.email = "yiling.cao@gmail.com"
         | 
| 23 23 | 
             
              gem.authors = ["Yiling Cao"]
         | 
| 24 24 | 
             
              # dependencies defined in Gemfile
         | 
| @@ -34,16 +34,8 @@ RSpec::Core::RakeTask.new(:spec) do |t| | |
| 34 34 | 
             
              t.rspec_opts = '--format progress -c'
         | 
| 35 35 | 
             
            end
         | 
| 36 36 |  | 
| 37 | 
            -
            require ' | 
| 38 | 
            -
             | 
| 39 | 
            -
              test.libs << 'test'
         | 
| 40 | 
            -
              test.pattern = 'test/**/test_*.rb'
         | 
| 41 | 
            -
              test.verbose = true
         | 
| 42 | 
            -
              test.rcov_opts << '--exclude "gems/*"'
         | 
| 43 | 
            -
            end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
            require 'rake/rdoctask'
         | 
| 46 | 
            -
            Rake::RDocTask.new do |rdoc|
         | 
| 37 | 
            +
            require 'rdoc/task'
         | 
| 38 | 
            +
            RDoc::Task.new do |rdoc|
         | 
| 47 39 | 
             
              version = File.exist?('VERSION') ? File.read('VERSION') : ""
         | 
| 48 40 |  | 
| 49 41 | 
             
              rdoc.rdoc_dir = 'rdoc'
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.7.1
         | 
    
        data/bin/text2mp3
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            require 'tts'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            if ARGV.size == 1
         | 
| 5 | 
            +
              ARGV[0].to_file "en"
         | 
| 6 | 
            +
              exit 0
         | 
| 7 | 
            +
            elsif ARGV.size == 2
         | 
| 8 | 
            +
              ARGV[0].to_file ARGV[1]
         | 
| 9 | 
            +
              exit 0
         | 
| 10 | 
            +
            else
         | 
| 11 | 
            +
              puts 'Usage: text2mp3 "Your Text"'
         | 
| 12 | 
            +
              puts 'OR: text2mp3 "Your Text" "Language Code"'
         | 
| 13 | 
            +
              exit 1
         | 
| 14 | 
            +
            end
         | 
    
        data/bin/tts
    ADDED
    
    
    
        data/lib/tts.rb
    CHANGED
    
    | @@ -1,10 +1,12 @@ | |
| 1 1 | 
             
            # encoding: utf-8
         | 
| 2 2 | 
             
            require 'open-uri'
         | 
| 3 3 | 
             
            require 'uri'
         | 
| 4 | 
            +
            require 'tempfile'
         | 
| 4 5 |  | 
| 5 6 | 
             
            module Tts
         | 
| 6 7 | 
             
              @@default_url = "http://translate.google.com/translate_tts"
         | 
| 7 | 
            -
              @@user_agent  = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24" | 
| 8 | 
            +
              @@user_agent  = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24"
         | 
| 9 | 
            +
              @@referer     = "http://translate.google.com/"
         | 
| 8 10 |  | 
| 9 11 | 
             
              def self.server_url url=nil
         | 
| 10 12 | 
             
                return @@default_url if url.nil?
         | 
| @@ -13,17 +15,17 @@ module Tts | |
| 13 15 |  | 
| 14 16 | 
             
              def to_file lang, file_name=nil
         | 
| 15 17 | 
             
                parts = validate_text_length(self)
         | 
| 16 | 
            -
                file_name =  | 
| 18 | 
            +
                file_name = self[0..20].generate_file_name if file_name.nil?
         | 
| 17 19 | 
             
                parts.each do |part|
         | 
| 18 20 | 
             
                  url = part.to_url(lang)
         | 
| 19 | 
            -
                  fetch_mp3(url, file_name) | 
| 21 | 
            +
                  fetch_mp3(url, file_name)
         | 
| 20 22 | 
             
                end
         | 
| 21 23 | 
             
              end
         | 
| 22 | 
            -
             | 
| 24 | 
            +
             | 
| 23 25 | 
             
              def validate_text_length text
         | 
| 24 26 | 
             
                if text.length > 100
         | 
| 25 27 | 
             
                  chunk_text(text)
         | 
| 26 | 
            -
                else | 
| 28 | 
            +
                else
         | 
| 27 29 | 
             
                  [text]
         | 
| 28 30 | 
             
                end
         | 
| 29 31 | 
             
              end
         | 
| @@ -46,25 +48,25 @@ module Tts | |
| 46 48 | 
             
                text.gsub(/\s+/m, ' ').strip.split(" ")
         | 
| 47 49 | 
             
              end
         | 
| 48 50 |  | 
| 49 | 
            -
              def generate_file_name | 
| 50 | 
            -
                to_valid_fn | 
| 51 | 
            +
              def generate_file_name
         | 
| 52 | 
            +
                to_valid_fn + ".mp3"
         | 
| 51 53 | 
             
              end
         | 
| 52 54 |  | 
| 53 | 
            -
              def to_valid_fn | 
| 54 | 
            -
                 | 
| 55 | 
            +
              def to_valid_fn
         | 
| 56 | 
            +
                gsub(/[\x00\/\\:\*\?\"<>\|]/, '_')
         | 
| 55 57 | 
             
              end
         | 
| 56 58 |  | 
| 57 59 | 
             
              def to_url lang
         | 
| 58 | 
            -
                langs = [ | 
| 60 | 
            +
                langs = ['af', 'ar', 'az', 'be', 'bg', 'bn', 'ca', 'cs', 'cy', 'da', 'de', 'el', 'en', 'en_us', 'en_gb', 'en_au', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fr', 'ga', 'gl', 'gu', 'hi', 'hr', 'ht', 'hu', 'id', 'is', 'it', 'iw', 'ja', 'ka', 'kn', 'ko', 'la', 'lt', 'lv', 'mk', 'ms', 'mt', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sv', 'sw', 'ta', 'te', 'th', 'tl', 'tr', 'uk', 'ur', 'vi', 'yi', 'zh', 'zh-CN', 'zh-TW']
         | 
| 59 61 | 
             
                raise "Not accepted language, accpeted are #{langs * ","}" unless langs.include? lang
         | 
| 60 | 
            -
                base = "#{Tts.server_url}?tl=#{lang}&q=#{URI.escape self}"
         | 
| 62 | 
            +
                base = "#{Tts.server_url}?tl=#{lang}&ie=UTF-8&client=tw-ob&q=#{URI.escape self}"
         | 
| 61 63 | 
             
              end
         | 
| 62 64 |  | 
| 63 65 | 
             
              def fetch_mp3 url, file_name
         | 
| 64 | 
            -
                begin | 
| 65 | 
            -
                  content = open(url, "User-Agent" => @@user_agent).read
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                  File.open( | 
| 66 | 
            +
                begin
         | 
| 67 | 
            +
                  content = open(url, "User-Agent" => @@user_agent, "Referer" => @@referer).read
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  File.open(temp_file_name, "wb") do |f|
         | 
| 68 70 | 
             
                    f.puts content
         | 
| 69 71 | 
             
                  end
         | 
| 70 72 | 
             
                  merge_mp3_file(file_name)
         | 
| @@ -74,8 +76,25 @@ module Tts | |
| 74 76 | 
             
                end
         | 
| 75 77 | 
             
              end
         | 
| 76 78 |  | 
| 79 | 
            +
              def temp_file_name
         | 
| 80 | 
            +
                @@temp_file ||= Tempfile.new.path
         | 
| 81 | 
            +
              end
         | 
| 82 | 
            +
             | 
| 77 83 | 
             
              def merge_mp3_file file_name
         | 
| 78 | 
            -
                `cat  | 
| 84 | 
            +
                `cat #{temp_file_name} >> "#{file_name}" && rm #{temp_file_name}`
         | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
              def play lang="en", times=1, pause_gap = 1
         | 
| 88 | 
            +
                #test if mpg123 exists?
         | 
| 89 | 
            +
                `which mpg123`
         | 
| 90 | 
            +
                if $?.to_i != 0
         | 
| 91 | 
            +
                  puts "mpg123 executable NOT found. This function only work with POSIX systems.\n Install mpg123 with `brew install mpg123` or `apt-get install mpg123`"
         | 
| 92 | 
            +
                  exit 1
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
                fn = "tts_playonce"
         | 
| 95 | 
            +
                self.to_file(lang, fn)
         | 
| 96 | 
            +
                times.times{|i| `mpg123 --no-control -q #{fn}`}
         | 
| 97 | 
            +
                File.delete(fn)
         | 
| 79 98 | 
             
              end
         | 
| 80 99 |  | 
| 81 100 | 
             
            end
         | 
    
        data/spec/tts_spec.rb
    CHANGED
    
    | @@ -3,43 +3,41 @@ require File.expand_path("../../lib/tts", __FILE__) | |
| 3 3 | 
             
            require "rspec"
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe "to_valid_fn method" do
         | 
| 6 | 
            -
              # Tts.server_url  "http://127.0.0.1:3001/translate_tts"
         | 
| 7 | 
            -
             | 
| 8 6 | 
             
              # fn.gsub(/[\x00\/\\:\*\?\"<>\|]/, '_')
         | 
| 9 7 | 
             
              it "should replace * with _" do
         | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 8 | 
            +
                expect("hello*nice".to_valid_fn).to eq "hello_nice"
         | 
| 9 | 
            +
                expect("hello*nice*hello".to_valid_fn).to eq "hello_nice_hello"
         | 
| 12 10 | 
             
              end
         | 
| 13 11 |  | 
| 14 12 | 
             
              it "should replace / with _" do
         | 
| 15 | 
            -
                 | 
| 16 | 
            -
                 | 
| 13 | 
            +
                expect("hello/nice".to_valid_fn).to eq "hello_nice"
         | 
| 14 | 
            +
                expect("hello/nice/hello".to_valid_fn).to eq "hello_nice_hello"
         | 
| 17 15 | 
             
              end
         | 
| 18 16 |  | 
| 19 17 | 
             
              it "should replace / with _" do
         | 
| 20 | 
            -
                 | 
| 21 | 
            -
                 | 
| 18 | 
            +
                expect("hello:nice".to_valid_fn).to eq "hello_nice"
         | 
| 19 | 
            +
                expect("hello:nice:hello".to_valid_fn).to eq "hello_nice_hello"
         | 
| 22 20 | 
             
              end
         | 
| 23 21 |  | 
| 24 22 | 
             
              it "should replace / with _" do
         | 
| 25 | 
            -
                 | 
| 26 | 
            -
                 | 
| 23 | 
            +
                expect("hello?nice".to_valid_fn).to eq "hello_nice"
         | 
| 24 | 
            +
                expect("hello?nice?hello".to_valid_fn).to eq "hello_nice_hello"
         | 
| 27 25 | 
             
              end
         | 
| 28 26 |  | 
| 29 27 | 
             
              it "should replace / with _" do
         | 
| 30 | 
            -
                 | 
| 31 | 
            -
                 | 
| 28 | 
            +
                expect("hello|nice".to_valid_fn).to eq "hello_nice"
         | 
| 29 | 
            +
                expect("hello|nice?hello".to_valid_fn).to eq "hello_nice_hello"
         | 
| 32 30 | 
             
              end
         | 
| 33 31 |  | 
| 34 32 | 
             
            end
         | 
| 35 33 |  | 
| 36 34 | 
             
            describe 'to_url method' do
         | 
| 37 35 | 
             
              it "to_url should return a correct string" do
         | 
| 38 | 
            -
                "hello".to_url("en"). | 
| 36 | 
            +
                expect("hello".to_url("en")).to eq "http://translate.google.com/translate_tts?tl=en&ie=UTF-8&client=tw-ob&q=hello"
         | 
| 39 37 | 
             
              end
         | 
| 40 38 |  | 
| 41 39 | 
             
              it "to_url should return a correct string with chinese char" do
         | 
| 42 | 
            -
                "人民广场".to_url("zh"). | 
| 40 | 
            +
                expect("人民广场".to_url("zh")).to eq "http://translate.google.com/translate_tts?tl=zh&ie=UTF-8&client=tw-ob&q=%E4%BA%BA%E6%B0%91%E5%B9%BF%E5%9C%BA"
         | 
| 43 41 | 
             
              end
         | 
| 44 42 |  | 
| 45 43 | 
             
            end
         | 
| @@ -47,22 +45,43 @@ end | |
| 47 45 | 
             
            describe 'to_file method' do
         | 
| 48 46 | 
             
              it "to_file should generate a mp3 file for a correct string" do
         | 
| 49 47 | 
             
                "hello".to_file("en")
         | 
| 50 | 
            -
                File.exist?("hello.mp3"). | 
| 48 | 
            +
                expect(File.exist?("hello.mp3")).to be true
         | 
| 51 49 | 
             
                File.delete("hello.mp3")
         | 
| 52 50 | 
             
              end
         | 
| 53 51 |  | 
| 54 52 | 
             
              it "to_file should generate a mp3 file with given name for a correct string" do
         | 
| 55 53 | 
             
                "hello".to_file("en", "my_hello.mp3")
         | 
| 56 | 
            -
                File.exist?("my_hello.mp3"). | 
| 54 | 
            +
                expect(File.exist?("my_hello.mp3")).to be true
         | 
| 57 55 | 
             
                File.delete("my_hello.mp3")
         | 
| 58 56 | 
             
              end
         | 
| 59 57 |  | 
| 60 58 | 
             
              it "to_file should generate a mp3 file for a correct chinese string" do
         | 
| 61 59 | 
             
                "人民广场到了".to_file("zh")
         | 
| 62 | 
            -
                File.exist?("人民广场到了.mp3"). | 
| 60 | 
            +
                expect(File.exist?("人民广场到了.mp3")).to be true
         | 
| 63 61 | 
             
                File.delete("人民广场到了.mp3")
         | 
| 64 62 | 
             
              end
         | 
| 65 63 |  | 
| 64 | 
            +
              it "to_file should generate a mp3 file for a correct simplified chinese string" do
         | 
| 65 | 
            +
                "人民广场马上到了".to_file("zh-CN")
         | 
| 66 | 
            +
                expect(File.exist?("人民广场马上到了.mp3")).to be true
         | 
| 67 | 
            +
                File.delete("人民广场马上到了.mp3")
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              it "to_file should fail a non-exist language" do
         | 
| 71 | 
            +
                expect{"人民广场马上到了".to_file("dummy")}.to raise_error(RuntimeError)
         | 
| 72 | 
            +
                expect(File.exist?("人民广场马上到了.mp3")).to be false
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            describe 'generate a correct mp3 file with long text and play via mpg123' do
         | 
| 78 | 
            +
              it "should playback a correct test mp3 file" do
         | 
| 79 | 
            +
                "Testing sound with the ruby gem TTS... if you hear the sound correctly, This single test is passed. Thank you very much for you patience...".play
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              it "should playback a correct Chinese test mp3 file" do
         | 
| 83 | 
            +
                "谢谢测试。测试通过".play("zh")
         | 
| 84 | 
            +
              end
         | 
| 66 85 | 
             
            end
         | 
| 67 86 |  | 
| 68 87 | 
             
            describe 'set a server url' do
         | 
| @@ -71,9 +90,6 @@ describe 'set a server url' do | |
| 71 90 | 
             
              end
         | 
| 72 91 |  | 
| 73 92 | 
             
              it "to_url should return a correct string" do
         | 
| 74 | 
            -
                "hello".to_url("en"). | 
| 93 | 
            +
                expect("hello".to_url("en")).to eq "http://127.0.0.1:3001/translate_tts?tl=en&ie=UTF-8&client=tw-ob&q=hello"
         | 
| 75 94 | 
             
              end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 95 | 
             
            end
         | 
    
        data/tts.gemspec
    CHANGED
    
    | @@ -2,16 +2,19 @@ | |
| 2 2 | 
             
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 3 | 
             
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 4 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 5 | 
            +
            # stub: tts 0.7.1 ruby lib
         | 
| 5 6 |  | 
| 6 7 | 
             
            Gem::Specification.new do |s|
         | 
| 7 | 
            -
              s.name = "tts"
         | 
| 8 | 
            -
              s.version = "0. | 
| 8 | 
            +
              s.name = "tts".freeze
         | 
| 9 | 
            +
              s.version = "0.8.1"
         | 
| 9 10 |  | 
| 10 | 
            -
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            -
              s. | 
| 12 | 
            -
              s. | 
| 13 | 
            -
              s. | 
| 14 | 
            -
              s. | 
| 11 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
         | 
| 12 | 
            +
              s.require_paths = ["lib".freeze]
         | 
| 13 | 
            +
              s.authors = ["Yiling Cao".freeze]
         | 
| 14 | 
            +
              s.date = "2019-05-11"
         | 
| 15 | 
            +
              s.description = "(tts) Text -> Mp3 made easy.".freeze
         | 
| 16 | 
            +
              s.email = "yiling.cao@gmail.com".freeze
         | 
| 17 | 
            +
              s.executables = ["text2mp3".freeze, "tts".freeze]
         | 
| 15 18 | 
             
              s.extra_rdoc_files = [
         | 
| 16 19 | 
             
                "LICENSE.txt",
         | 
| 17 20 | 
             
                "README.rdoc"
         | 
| @@ -23,35 +26,35 @@ Gem::Specification.new do |s| | |
| 23 26 | 
             
                "README.rdoc",
         | 
| 24 27 | 
             
                "Rakefile",
         | 
| 25 28 | 
             
                "VERSION",
         | 
| 29 | 
            +
                "bin/text2mp3",
         | 
| 30 | 
            +
                "bin/tts",
         | 
| 31 | 
            +
                "example/gen_hello_world_en.rb",
         | 
| 32 | 
            +
                "example/play_hello_world_en.rb",
         | 
| 26 33 | 
             
                "lib/tts.rb",
         | 
| 27 34 | 
             
                "spec/tts_spec.rb",
         | 
| 28 35 | 
             
                "tts.gemspec"
         | 
| 29 36 | 
             
              ]
         | 
| 30 | 
            -
              s.homepage = "http://github.com/c2h2/tts"
         | 
| 31 | 
            -
              s.licenses = ["MIT"]
         | 
| 32 | 
            -
              s. | 
| 33 | 
            -
              s. | 
| 34 | 
            -
              s.summary = "a text to speech file tool"
         | 
| 37 | 
            +
              s.homepage = "http://github.com/c2h2/tts".freeze
         | 
| 38 | 
            +
              s.licenses = ["MIT".freeze]
         | 
| 39 | 
            +
              s.rubygems_version = "3.0.3".freeze
         | 
| 40 | 
            +
              s.summary = "Ruby convert text to mp3".freeze
         | 
| 35 41 |  | 
| 36 42 | 
             
              if s.respond_to? :specification_version then
         | 
| 37 | 
            -
                s.specification_version =  | 
| 43 | 
            +
                s.specification_version = 4
         | 
| 38 44 |  | 
| 39 45 | 
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 40 | 
            -
                  s.add_development_dependency(%q<rspec | 
| 41 | 
            -
                  s.add_development_dependency(%q<bundler | 
| 42 | 
            -
                  s.add_development_dependency(%q<jeweler | 
| 43 | 
            -
                  s.add_development_dependency(%q<rcov>, [">= 0"])
         | 
| 46 | 
            +
                  s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
         | 
| 47 | 
            +
                  s.add_development_dependency(%q<bundler>.freeze, ["~> 2.0"])
         | 
| 48 | 
            +
                  s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
         | 
| 44 49 | 
             
                else
         | 
| 45 | 
            -
                  s.add_dependency(%q<rspec | 
| 46 | 
            -
                  s.add_dependency(%q<bundler | 
| 47 | 
            -
                  s.add_dependency(%q<jeweler | 
| 48 | 
            -
                  s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 50 | 
            +
                  s.add_dependency(%q<rspec>.freeze, [">= 0"])
         | 
| 51 | 
            +
                  s.add_dependency(%q<bundler>.freeze, ["~> 2.0"])
         | 
| 52 | 
            +
                  s.add_dependency(%q<jeweler>.freeze, [">= 0"])
         | 
| 49 53 | 
             
                end
         | 
| 50 54 | 
             
              else
         | 
| 51 | 
            -
                s.add_dependency(%q<rspec | 
| 52 | 
            -
                s.add_dependency(%q<bundler | 
| 53 | 
            -
                s.add_dependency(%q<jeweler | 
| 54 | 
            -
                s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 55 | 
            +
                s.add_dependency(%q<rspec>.freeze, [">= 0"])
         | 
| 56 | 
            +
                s.add_dependency(%q<bundler>.freeze, ["~> 2.0"])
         | 
| 57 | 
            +
                s.add_dependency(%q<jeweler>.freeze, [">= 0"])
         | 
| 55 58 | 
             
              end
         | 
| 56 59 | 
             
            end
         | 
| 57 60 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,83 +1,62 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: tts
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 0.8.1
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - Yiling Cao
         | 
| 9 8 | 
             
            autorequire: 
         | 
| 10 9 | 
             
            bindir: bin
         | 
| 11 10 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 11 | 
            +
            date: 2019-05-11 00:00:00.000000000 Z
         | 
| 13 12 | 
             
            dependencies:
         | 
| 14 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 14 | 
             
              name: rspec
         | 
| 16 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                none: false
         | 
| 18 16 | 
             
                requirements:
         | 
| 19 | 
            -
                - -  | 
| 17 | 
            +
                - - ">="
         | 
| 20 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: ' | 
| 19 | 
            +
                    version: '0'
         | 
| 22 20 | 
             
              type: :development
         | 
| 23 21 | 
             
              prerelease: false
         | 
| 24 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            -
                none: false
         | 
| 26 23 | 
             
                requirements:
         | 
| 27 | 
            -
                - -  | 
| 24 | 
            +
                - - ">="
         | 
| 28 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: ' | 
| 26 | 
            +
                    version: '0'
         | 
| 30 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 28 | 
             
              name: bundler
         | 
| 32 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            -
                none: false
         | 
| 34 30 | 
             
                requirements:
         | 
| 35 | 
            -
                - - ~>
         | 
| 31 | 
            +
                - - "~>"
         | 
| 36 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            -
                    version:  | 
| 33 | 
            +
                    version: '2.0'
         | 
| 38 34 | 
             
              type: :development
         | 
| 39 35 | 
             
              prerelease: false
         | 
| 40 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            -
                none: false
         | 
| 42 37 | 
             
                requirements:
         | 
| 43 | 
            -
                - - ~>
         | 
| 38 | 
            +
                - - "~>"
         | 
| 44 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version:  | 
| 40 | 
            +
                    version: '2.0'
         | 
| 46 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 42 | 
             
              name: jeweler
         | 
| 48 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            -
                none: false
         | 
| 50 | 
            -
                requirements:
         | 
| 51 | 
            -
                - - ~>
         | 
| 52 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                    version: 1.6.2
         | 
| 54 | 
            -
              type: :development
         | 
| 55 | 
            -
              prerelease: false
         | 
| 56 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            -
                none: false
         | 
| 58 | 
            -
                requirements:
         | 
| 59 | 
            -
                - - ~>
         | 
| 60 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: 1.6.2
         | 
| 62 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            -
              name: rcov
         | 
| 64 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            -
                none: false
         | 
| 66 44 | 
             
                requirements:
         | 
| 67 | 
            -
                - -  | 
| 45 | 
            +
                - - ">="
         | 
| 68 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 69 47 | 
             
                    version: '0'
         | 
| 70 48 | 
             
              type: :development
         | 
| 71 49 | 
             
              prerelease: false
         | 
| 72 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            -
                none: false
         | 
| 74 51 | 
             
                requirements:
         | 
| 75 | 
            -
                - -  | 
| 52 | 
            +
                - - ">="
         | 
| 76 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 77 54 | 
             
                    version: '0'
         | 
| 78 | 
            -
            description:  | 
| 55 | 
            +
            description: "(tts) Text -> Mp3 made easy."
         | 
| 79 56 | 
             
            email: yiling.cao@gmail.com
         | 
| 80 | 
            -
            executables: | 
| 57 | 
            +
            executables:
         | 
| 58 | 
            +
            - text2mp3
         | 
| 59 | 
            +
            - tts
         | 
| 81 60 | 
             
            extensions: []
         | 
| 82 61 | 
             
            extra_rdoc_files:
         | 
| 83 62 | 
             
            - LICENSE.txt
         | 
| @@ -89,35 +68,35 @@ files: | |
| 89 68 | 
             
            - README.rdoc
         | 
| 90 69 | 
             
            - Rakefile
         | 
| 91 70 | 
             
            - VERSION
         | 
| 71 | 
            +
            - bin/text2mp3
         | 
| 72 | 
            +
            - bin/tts
         | 
| 73 | 
            +
            - example/gen_hello_world_en.rb
         | 
| 74 | 
            +
            - example/play_hello_world_en.rb
         | 
| 92 75 | 
             
            - lib/tts.rb
         | 
| 93 76 | 
             
            - spec/tts_spec.rb
         | 
| 94 77 | 
             
            - tts.gemspec
         | 
| 95 78 | 
             
            homepage: http://github.com/c2h2/tts
         | 
| 96 79 | 
             
            licenses:
         | 
| 97 80 | 
             
            - MIT
         | 
| 81 | 
            +
            metadata: {}
         | 
| 98 82 | 
             
            post_install_message: 
         | 
| 99 83 | 
             
            rdoc_options: []
         | 
| 100 84 | 
             
            require_paths:
         | 
| 101 85 | 
             
            - lib
         | 
| 102 86 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 103 | 
            -
              none: false
         | 
| 104 87 | 
             
              requirements:
         | 
| 105 | 
            -
              - -  | 
| 88 | 
            +
              - - ">="
         | 
| 106 89 | 
             
                - !ruby/object:Gem::Version
         | 
| 107 90 | 
             
                  version: '0'
         | 
| 108 | 
            -
                  segments:
         | 
| 109 | 
            -
                  - 0
         | 
| 110 | 
            -
                  hash: -3856335745292823926
         | 
| 111 91 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 112 | 
            -
              none: false
         | 
| 113 92 | 
             
              requirements:
         | 
| 114 | 
            -
              - -  | 
| 93 | 
            +
              - - ">="
         | 
| 115 94 | 
             
                - !ruby/object:Gem::Version
         | 
| 116 95 | 
             
                  version: '0'
         | 
| 117 96 | 
             
            requirements: []
         | 
| 118 97 | 
             
            rubyforge_project: 
         | 
| 119 | 
            -
            rubygems_version:  | 
| 98 | 
            +
            rubygems_version: 2.6.12
         | 
| 120 99 | 
             
            signing_key: 
         | 
| 121 | 
            -
            specification_version:  | 
| 122 | 
            -
            summary:  | 
| 100 | 
            +
            specification_version: 4
         | 
| 101 | 
            +
            summary: Ruby convert text to mp3
         | 
| 123 102 | 
             
            test_files: []
         |