md2slides 0.0.2 → 0.0.4
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/README.md +27 -27
- data/lib/md2slides/presentation.rb +11 -6
- data/lib/md2slides/version.rb +1 -1
- data/lib/md2slides/video.rb +8 -5
- data/lib/md2slides.rb +3 -1
- data/md2slides.gemspec +5 -5
- metadata +10 -10
- data/config/.gitignore +0 -3
- data/config/config.rb +0 -2
- /data/{bin → exe}/md2slides +0 -0
- /data/{bin → exe}/text2mp3 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37da571eb1e048ee8704c95778e990564251cc1dfed86fb0e5c92c8d63378227
|
4
|
+
data.tar.gz: ef0f3367747ea41eb5e0850ac02a6d844a9b69ca9af8fe1395c3c19484f0fd88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b65446aa4824038aa84c4f7f9954ed6986d8ae3e7c8107806b803f4e75df8fd199c10061371075c229d5886f767d725b21430f3d2611cbf268b2d7b8dc779bb
|
7
|
+
data.tar.gz: 9e0a800ed47263fe9fd3b55a226891f987a2bb91f6eb32396bfe8e8bf6eebdbe01790d23e066ea8cb18e0a369e8c4a56f00cab71b69c5ccca978bc855663163c
|
data/README.md
CHANGED
@@ -3,10 +3,27 @@
|
|
3
3
|
A video file of a presentation will be also generated, and it may contains narration if supplied.
|
4
4
|
Narration can be given as notes in slides, and the audio will be generated using Google text-to-speech API and ffmpeg.
|
5
5
|
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
install by gem:
|
9
|
+
|
10
|
+
% gem install md2slides
|
11
|
+
|
12
|
+
Or add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'md2slides'
|
16
|
+
```
|
17
|
+
|
18
|
+
and then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
6
22
|
## Quick start
|
7
23
|
1. Generate your Google API credentials and copy it to credentails.json:
|
8
24
|
```
|
9
|
-
%
|
25
|
+
% mkdir ~/.config/gcloud
|
26
|
+
% cat >> ~/.config/gcloud/credentials.json
|
10
27
|
{
|
11
28
|
"type": "service_account",
|
12
29
|
"project_id": "project-id",
|
@@ -23,14 +40,9 @@ Narration can be given as notes in slides, and the audio will be generated using
|
|
23
40
|
```
|
24
41
|
2. install ffmpeg if necessary (if producing video file).
|
25
42
|
|
26
|
-
3.
|
27
|
-
```
|
28
|
-
% bundle install --path vendor/bundle
|
29
|
-
```
|
30
|
-
|
31
|
-
4. create an empty Google slide.
|
43
|
+
3. create an empty Google slide, share it with **client_email** user, and copy the URL.
|
32
44
|
|
33
|
-
|
45
|
+
4. write a markdown file.
|
34
46
|
```
|
35
47
|
cat >> doc/sample.md
|
36
48
|
---
|
@@ -52,33 +64,21 @@ narration text...
|
|
52
64
|
^D (this means CTRL + D)
|
53
65
|
```
|
54
66
|
|
55
|
-
|
67
|
+
5. run the script.
|
56
68
|
```
|
57
|
-
|
69
|
+
% md2slides sample.md
|
58
70
|
```
|
59
71
|
|
60
|
-
|
61
|
-
|
62
|
-
## Installation
|
63
|
-
|
64
|
-
Add this line to your application's Gemfile:
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
gem 'md2slides'
|
68
|
-
```
|
69
|
-
|
70
|
-
And then execute:
|
71
|
-
|
72
|
-
$ bundle
|
73
|
-
|
74
|
-
Or install it yourself as:
|
75
|
-
|
76
|
-
$ gem install md2slides
|
72
|
+
the Google presentation is updated, and the video is stored in the current directory.
|
77
73
|
|
78
74
|
## Usage
|
79
75
|
|
80
76
|
TODO: Write usage instructions here
|
81
77
|
|
78
|
+
## TODO
|
79
|
+
|
80
|
+
See [TODO.md](https://github.com/ohmori7/md2slides/blob/main/TODO.md "TODO.md")
|
81
|
+
|
82
82
|
## Development
|
83
83
|
|
84
84
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -16,7 +16,7 @@ class Presentation
|
|
16
16
|
attr_reader :id
|
17
17
|
|
18
18
|
def self.filename_sanitize(s)
|
19
|
-
s
|
19
|
+
s&.gsub(/[\/\\:\*\?"<>\|]/, '')
|
20
20
|
end
|
21
21
|
|
22
22
|
def initialize(url = nil)
|
@@ -40,7 +40,14 @@ class Presentation
|
|
40
40
|
@drive_service.authorization = @authorizer
|
41
41
|
|
42
42
|
if @id
|
43
|
-
|
43
|
+
begin
|
44
|
+
@presentation = @slides_service.get_presentation(@id)
|
45
|
+
rescue => e
|
46
|
+
require 'webrick'
|
47
|
+
raise(e, "#{e.message} (#{e.status_code} " +
|
48
|
+
"#{WEBrick::HTTPStatus.reason_phrase(e.status_code)})\n" +
|
49
|
+
"#{e.full_message}")
|
50
|
+
end
|
44
51
|
end
|
45
52
|
|
46
53
|
@requests = []
|
@@ -60,7 +67,7 @@ class Presentation
|
|
60
67
|
|
61
68
|
def existence_check
|
62
69
|
if ! exists?
|
63
|
-
raise("presentation (ID: #{@id})does not exists!!!")
|
70
|
+
raise("presentation (ID: #{@id}) does not exists!!!")
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
@@ -356,9 +363,7 @@ class Presentation
|
|
356
363
|
end
|
357
364
|
|
358
365
|
def __data_path(basedir)
|
359
|
-
if basedir.nil?
|
360
|
-
basedir = File.join(BASEDIR, 'data')
|
361
|
-
end
|
366
|
+
basedir = '.' if basedir.nil?
|
362
367
|
title, subtitle = get_title
|
363
368
|
title = self.class.filename_sanitize(title)
|
364
369
|
subtitle = self.class.filename_sanitize(subtitle)
|
data/lib/md2slides/version.rb
CHANGED
data/lib/md2slides/video.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'open3'
|
2
2
|
|
3
3
|
class Presentation
|
4
|
+
VIDEO_FRAME_RATE = 1
|
5
|
+
VIDEO_ONLY_DURATION = 4
|
6
|
+
|
4
7
|
def generate_slide_video(i, dir)
|
5
8
|
img = __data_slide_path(i, '.png', dir)
|
6
9
|
audio = __data_slide_path(i, '.m4a', dir)
|
@@ -11,11 +14,11 @@ class Presentation
|
|
11
14
|
timeopt = '-shortest'
|
12
15
|
else
|
13
16
|
audioin = "-f lavfi -i aevalsrc=0"
|
14
|
-
timeopt = "-vframes
|
17
|
+
timeopt = "-vframes #{VIDEO_FRAME_RATE * VIDEO_ONLY_DURATION}"
|
15
18
|
end
|
16
19
|
cmd = <<~CMD
|
17
20
|
ffmpeg -hide_banner -y \
|
18
|
-
-framerate
|
21
|
+
-framerate #{VIDEO_FRAME_RATE} -loop 1 -i "#{img}" \
|
19
22
|
#{audioin} -map 0:v:0 -map 1:a:0 \
|
20
23
|
-c:v libx264 -tune stillimage \
|
21
24
|
-c:a aac -ar #{AUDIO_RATE} -ac 1 \
|
@@ -36,13 +39,13 @@ class Presentation
|
|
36
39
|
end
|
37
40
|
|
38
41
|
print "concatenate video files..."
|
39
|
-
videolist =
|
40
|
-
File.open(videolist, 'w') do |f|
|
42
|
+
videolist = 'video-list.txt'
|
43
|
+
File.open(File.join(dir, videolist), 'w') do |f|
|
41
44
|
@presentation.slides.each_with_index do |slide, i|
|
42
45
|
f.puts("file #{__data_slide_path(i, '.mp4')}")
|
43
46
|
end
|
44
47
|
end
|
45
|
-
video =
|
48
|
+
video = 'video.mp4'
|
46
49
|
cmd = <<~CMD
|
47
50
|
cd "#{dir}" && \
|
48
51
|
ffmpeg -hide_banner -y -f concat -safe 0 \
|
data/lib/md2slides.rb
CHANGED
@@ -3,7 +3,9 @@ $:.unshift File.dirname(File.dirname(File.realpath(__FILE__)))
|
|
3
3
|
module Md2slides
|
4
4
|
class Error < StandardError; end
|
5
5
|
|
6
|
-
|
6
|
+
# XXX: platform independent path configuration...
|
7
|
+
ENV['GOOGLE_APPLICATION_CREDENTIALS'] ||= File.join(Dir.home, ".config/gcloud/credentials.json")
|
8
|
+
|
7
9
|
require 'md2slides/md'
|
8
10
|
require 'md2slides/presentation'
|
9
11
|
require 'md2slides/text_to_speech'
|
data/md2slides.gemspec
CHANGED
@@ -35,11 +35,11 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ["lib"]
|
37
37
|
|
38
|
-
spec.
|
39
|
-
# spec.
|
40
|
-
spec.
|
41
|
-
spec.
|
42
|
-
spec.
|
38
|
+
spec.add_dependency "googleauth"
|
39
|
+
# spec.add_dependency "google-apis-people_v1"
|
40
|
+
spec.add_dependency "google-apis-slides_v1"
|
41
|
+
spec.add_dependency "google-apis-drive_v3"
|
42
|
+
spec.add_dependency "google-cloud-text_to_speech", "~>0.7.0"
|
43
43
|
spec.add_development_dependency "bundler", "~> 1.17"
|
44
44
|
spec.add_development_dependency "rake", "~> 10.0"
|
45
45
|
spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: md2slides
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Motoyuki OHMORI
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.7.0
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -111,7 +111,9 @@ dependencies:
|
|
111
111
|
description: Generate Google slides and its video file from a markdown file.
|
112
112
|
email:
|
113
113
|
- ohmori@tottori-u.ac.jp
|
114
|
-
executables:
|
114
|
+
executables:
|
115
|
+
- md2slides
|
116
|
+
- text2mp3
|
115
117
|
extensions: []
|
116
118
|
extra_rdoc_files: []
|
117
119
|
files:
|
@@ -123,11 +125,9 @@ files:
|
|
123
125
|
- Rakefile
|
124
126
|
- TODO.md
|
125
127
|
- bin/console
|
126
|
-
- bin/md2slides
|
127
128
|
- bin/setup
|
128
|
-
-
|
129
|
-
-
|
130
|
-
- config/config.rb
|
129
|
+
- exe/md2slides
|
130
|
+
- exe/text2mp3
|
131
131
|
- lib/md2slides.rb
|
132
132
|
- lib/md2slides/audio.rb
|
133
133
|
- lib/md2slides/md.rb
|
data/config/.gitignore
DELETED
data/config/config.rb
DELETED
/data/{bin → exe}/md2slides
RENAMED
File without changes
|
/data/{bin → exe}/text2mp3
RENAMED
File without changes
|