tts 0.6.0 → 0.7.0
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 +4 -4
- data/.gitignore +48 -0
- data/Gemfile.lock +0 -3
- data/README.rdoc +6 -0
- 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 +3 -2
- data/tts.gemspec +8 -20
- metadata +12 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd79c3c482815e421adeb6aad75167eb9c598897
|
4
|
+
data.tar.gz: 46d8424170b9a33b09c49cc5db7a7a8bec4ccbb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84869551f7719e52b408855d6a30176857476068b613498cc568bcf7428b586b156910beeb93fc1351a518ba062788cf69032d7a6409f99eb9d8d5927135ad6d
|
7
|
+
data.tar.gz: 060090f14501bbb0dafb34a0667a720a2f44d12daf875a569e3c4f56691347a3d0db51299cad98ee61320dda0b2a70e3a7093a2dbd463a56238ba0de32d7af95
|
data/.gitignore
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
#.DS_Store
|
31
|
+
|
32
|
+
# For TextMate
|
33
|
+
#*.tmproj
|
34
|
+
#tmtags
|
35
|
+
|
36
|
+
# For emacs:
|
37
|
+
#*~
|
38
|
+
#\#*
|
39
|
+
#.\#*
|
40
|
+
|
41
|
+
# For vim:
|
42
|
+
#*.swp
|
43
|
+
|
44
|
+
# For redcar:
|
45
|
+
#.redcar
|
46
|
+
|
47
|
+
# For rubinius:
|
48
|
+
#*.rbc
|
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -34,10 +34,16 @@ You need to install `mpg123`
|
|
34
34
|
sudo apt-get install mpg123 #for debain based
|
35
35
|
brew install mpg123 #mac
|
36
36
|
|
37
|
+
== CLI
|
38
|
+
|
39
|
+
tts "ruby is great" # play the string.
|
40
|
+
text2mp3 "中国上海天气不错" "zh" #create mp3 file.
|
41
|
+
|
37
42
|
== Versions
|
38
43
|
|
39
44
|
0.4 fixed issue that long text unable to generated.
|
40
45
|
0.5 added all supported languages, added direct playback feature fixed some broken rspec.
|
46
|
+
0.7 added CLI support
|
41
47
|
|
42
48
|
== Copyright
|
43
49
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
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
@@ -5,6 +5,7 @@ require 'uri'
|
|
5
5
|
module Tts
|
6
6
|
@@default_url = "http://translate.google.com/translate_tts"
|
7
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
|
+
@@referer = "http://translate.google.com/"
|
8
9
|
|
9
10
|
def self.server_url url=nil
|
10
11
|
return @@default_url if url.nil?
|
@@ -57,12 +58,12 @@ module Tts
|
|
57
58
|
def to_url lang
|
58
59
|
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
60
|
raise "Not accepted language, accpeted are #{langs * ","}" unless langs.include? lang
|
60
|
-
base = "#{Tts.server_url}?tl=#{lang}&q=#{URI.escape self}"
|
61
|
+
base = "#{Tts.server_url}?tl=#{lang}&ie=UTF-8&client=t&q=#{URI.escape self}"
|
61
62
|
end
|
62
63
|
|
63
64
|
def fetch_mp3 url, file_name
|
64
65
|
begin
|
65
|
-
content = open(url, "User-Agent" => @@user_agent).read
|
66
|
+
content = open(url, "User-Agent" => @@user_agent, "Referer" => @@referer).read
|
66
67
|
|
67
68
|
File.open("temp.mp3", "wb") do |f|
|
68
69
|
f.puts content
|
data/tts.gemspec
CHANGED
@@ -6,50 +6,38 @@
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "tts"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.7.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Yiling Cao"]
|
14
|
-
s.date = "2015-
|
15
|
-
s.description = "
|
14
|
+
s.date = "2015-08-18"
|
15
|
+
s.description = "easy way to generate a voice file based on text prvoided."
|
16
|
+
s.summary = "a text to speech file tool"
|
16
17
|
s.email = "yiling.cao@gmail.com"
|
17
18
|
s.extra_rdoc_files = [
|
18
19
|
"LICENSE.txt",
|
19
20
|
"README.rdoc"
|
20
21
|
]
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"lib/tts.rb",
|
29
|
-
"spec/tts_spec.rb",
|
30
|
-
"tts.gemspec"
|
31
|
-
]
|
22
|
+
|
23
|
+
s.executables = ["tts", "text2mp3"]
|
24
|
+
s.files = `git ls-files`.split($/)
|
25
|
+
|
32
26
|
s.homepage = "http://github.com/c2h2/tts"
|
33
27
|
s.licenses = ["MIT"]
|
34
28
|
s.rubygems_version = "2.4.8"
|
35
|
-
s.summary = "Ruby convert text to mp3"
|
36
29
|
|
37
30
|
if s.respond_to? :specification_version then
|
38
31
|
s.specification_version = 4
|
39
32
|
|
40
33
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
34
|
s.add_development_dependency(%q<rspec>, ["~> 2.6"])
|
42
|
-
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
43
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
44
35
|
else
|
45
36
|
s.add_dependency(%q<rspec>, ["~> 2.6"])
|
46
|
-
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
47
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
48
37
|
end
|
49
38
|
else
|
50
39
|
s.add_dependency(%q<rspec>, ["~> 2.6"])
|
51
40
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
52
|
-
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
53
41
|
end
|
54
42
|
end
|
55
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yiling Cao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,48 +24,27 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.6'
|
27
|
-
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: jeweler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.6.2
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.6.2
|
55
|
-
description: "(tts) Text -> Mp3 made easy."
|
27
|
+
description: easy way to generate a voice file based on text prvoided.
|
56
28
|
email: yiling.cao@gmail.com
|
57
|
-
executables:
|
29
|
+
executables:
|
30
|
+
- tts
|
31
|
+
- text2mp3
|
58
32
|
extensions: []
|
59
33
|
extra_rdoc_files:
|
60
34
|
- LICENSE.txt
|
61
35
|
- README.rdoc
|
62
36
|
files:
|
37
|
+
- ".gitignore"
|
63
38
|
- Gemfile
|
64
39
|
- Gemfile.lock
|
65
40
|
- LICENSE.txt
|
66
41
|
- README.rdoc
|
67
42
|
- Rakefile
|
68
43
|
- VERSION
|
44
|
+
- bin/text2mp3
|
45
|
+
- bin/tts
|
46
|
+
- example/gen_hello_world_en.rb
|
47
|
+
- example/play_hello_world_en.rb
|
69
48
|
- lib/tts.rb
|
70
49
|
- spec/tts_spec.rb
|
71
50
|
- tts.gemspec
|
@@ -92,5 +71,5 @@ rubyforge_project:
|
|
92
71
|
rubygems_version: 2.4.8
|
93
72
|
signing_key:
|
94
73
|
specification_version: 4
|
95
|
-
summary:
|
74
|
+
summary: a text to speech file tool
|
96
75
|
test_files: []
|