ted_talk 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -5
- data/bin/ted_talk +3 -1
- data/lib/ted_talk.rb +6 -3
- data/lib/ted_talk/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -13,13 +13,13 @@ TedTalk requires [FFmpeg](http://ffmpeg.org/) and [SoX](http://sox.sourceforge.n
|
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
-
Basic usage:
|
17
|
-
|
18
|
-
|
16
|
+
Basic usage: ted_talk desc <option> - show TED Talk description(s)
|
17
|
+
ted_talk exec <option> - download and convert a TED Talk video
|
18
|
+
ted_talk delete - delete cache folder
|
19
19
|
|
20
20
|
For details about <option>, type:
|
21
|
-
|
22
|
-
or
|
21
|
+
ted_talk desc -h
|
22
|
+
or ted_talk exec -h
|
23
23
|
|
24
24
|
[global options]:
|
25
25
|
--version, -v: Print version and exit
|
@@ -37,6 +37,7 @@ TedTalk requires [FFmpeg](http://ffmpeg.org/) and [SoX](http://sox.sourceforge.n
|
|
37
37
|
--lang, -l <s>: Language of description (default: en)
|
38
38
|
--rss, -r: Show descriptions of the newest talks from TED Talk RSS
|
39
39
|
--url, -u <s>: URL of a specific TED Talk
|
40
|
+
--video, -v: Save not only audio but also the original video
|
40
41
|
--help, -h: Show this message
|
41
42
|
|
42
43
|
### exec
|
data/bin/ted_talk
CHANGED
@@ -89,6 +89,7 @@ EOS
|
|
89
89
|
opt :outdir, "Directory for file output", :default=> "./"
|
90
90
|
opt :speed, "Speed of output file [0.1 - 100]", :default => 1.0
|
91
91
|
opt :silence, "Length (secondes) of a pause added to each utterance [0.1 - 120]", :default => 0.0
|
92
|
+
opt :video, "Save not only audio but also the original video", :default => false
|
92
93
|
end
|
93
94
|
|
94
95
|
Trollop::die :outdir, "must be an existing directory" unless File::ftype(exec_opts[:outdir]) == "directory"
|
@@ -100,9 +101,10 @@ EOS
|
|
100
101
|
outdir = exec_opts[:outdir]
|
101
102
|
speed = exec_opts[:speed]
|
102
103
|
silence = exec_opts[:silence]
|
104
|
+
video = exec_opts[:video]
|
103
105
|
|
104
106
|
tedtalk = TedTalk::Converter.new(source_url)
|
105
|
-
tedtalk.execute(outdir, lang, speed, silence)
|
107
|
+
tedtalk.execute(outdir, lang, speed, silence, video)
|
106
108
|
when "delete"
|
107
109
|
TedTalk.delete_cache
|
108
110
|
else
|
data/lib/ted_talk.rb
CHANGED
@@ -137,7 +137,7 @@ module TedTalk
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
def execute(outdir = "./", lang = "en", speed = 1, silence = 0)
|
140
|
+
def execute(outdir = "./", lang = "en", speed = 1, silence = 0, video = false)
|
141
141
|
puts "TedTalk is prepararing for the process"
|
142
142
|
@outdir = File.join(outdir, @ted_id + "-" + @basename)
|
143
143
|
Dir.mkdir(@outdir) unless File.exists?(@outdir)
|
@@ -148,12 +148,15 @@ module TedTalk
|
|
148
148
|
get_captions("en")
|
149
149
|
setup_lang(lang)
|
150
150
|
get_captions(lang)
|
151
|
-
video_filepath = get_binary(@video_url)
|
151
|
+
video_filepath = get_binary(@video_url)
|
152
152
|
wav_filepath = get_wav(video_filepath)
|
153
153
|
outfile = @outdir + "/" + @basename + "-result.mp3"
|
154
154
|
speakslow = SpeakSlow::Converter.new(wav_filepath, outfile)
|
155
155
|
speakslow.execute(speed, silence)
|
156
|
-
write_info(outfile)
|
156
|
+
write_info(outfile)
|
157
|
+
if video
|
158
|
+
`cp #{video_filepath} #{@outdir + "/"}`
|
159
|
+
end
|
157
160
|
end
|
158
161
|
|
159
162
|
def get_title(lang)
|
data/lib/ted_talk/version.rb
CHANGED