google_tts2 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,6 +29,14 @@ or
29
29
  google_tts.save("FileName", "Texto em Portugês")
30
30
  # => "out/FileName.mp3"
31
31
 
32
+ ##Auto-proxy selection
33
+ Use with caution, the selection is totally ramdom base on lists of public proxies, they may have very high latency and result on time out.
34
+ The suggestion is to use when you start receiving 302 responses from google - manually it means you face a captcha input form - because you made too many requests for the day.
35
+
36
+ google_tts = GoogleTts.with_random_proxy.instantiate({ :output => "out", :lang => :pt })
37
+ google_tts.save "file2", "Olá, tudo bem com você?"
38
+ # => "out/file2.mp3"
39
+
32
40
 
33
41
  #Development
34
42
 
@@ -5,7 +5,7 @@ require 'google_tts/mp3writer'
5
5
  require 'google_tts/proxy_fetcher'
6
6
 
7
7
  module GoogleTts
8
- VERSION = "0.0.5"
8
+ VERSION = "0.1.0"
9
9
 
10
10
  class Client
11
11
  include GoogleTts
@@ -30,16 +30,16 @@ module GoogleTts
30
30
  end
31
31
 
32
32
  def self.instantiate(params = {})
33
- proxy = params[:proxy]
33
+ proxy = params[:proxy] || @proxy
34
34
  connection = proxy ? Net::HTTP::Proxy(proxy[:host], proxy[:port]) : Net::HTTP
35
35
  lang = params[:lang] || :en
36
36
  output = params[:output] || "out"
37
37
  Client.new(Connector.new(connection), QueryBuilder.new(lang), Mp3Writer.new(output))
38
38
  end
39
39
 
40
- def self.with_proxy(params = {})
41
- params[:proxy] = ProxyFetcher.random_proxy
42
- instantiate params
40
+ def self.with_random_proxy(params = {})
41
+ @proxy = ProxyFetcher.random_proxy
42
+ self
43
43
  end
44
44
 
45
45
  end
@@ -3,22 +3,27 @@ require 'spec_helper'
3
3
 
4
4
  describe GoogleTts do
5
5
 
6
- context GoogleTts::Client do
7
- DIR = "out"
6
+ describe 'integration test' do
7
+ context GoogleTts::Client do
8
+ DIR = "out"
9
+
10
+ it 'save a mp3' do
11
+ subject = GoogleTts.instantiate({ :output => DIR, :lang => :pt })
12
+ subject.save "file1", "Olá, tudo bem com você?"
13
+ expect(File.exists?("out/file1.mp3")).to be_true
14
+ end
15
+
16
+ it 'uses proxy' do
17
+ subject = GoogleTts.with_random_proxy.instantiate({ :output => DIR, :lang => :pt })
18
+ subject.save "file2", "Olá, tudo bem com você?"
19
+ expect(File.exists?("out/file2.mp3")).to be_true
20
+ end
21
+
22
+ after(:each) do
23
+ FileUtils.rm_r "out"
24
+ end
8
25
 
9
- subject do
10
- GoogleTts.instantiate({ :output => DIR, :lang => :pt })
11
26
  end
12
-
13
- it 'save a mp3' do
14
- subject.save "file1", "Olá, tudo bem com você?"
15
- expect(File.exists?("out/file1.mp3")).to be_true
16
- end
17
-
18
- after do
19
- FileUtils.rm_r "out"
20
- end
21
-
22
27
  end
23
28
 
24
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_tts2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-14 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec