screenkit 0.0.13 → 0.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c5c78d98545b9e48cef700afe1aada9ea8ec2ff71c1e6245ae6bf7fb6aa32e3
4
- data.tar.gz: 88e66ce7b3936b5298a46718f7ed0851fe609bdaad7337afdeba818b390c8006
3
+ metadata.gz: e300f330550b46c23a90c6433c534bb473f65cc71c49c82a97a6d9dde1a35c61
4
+ data.tar.gz: 8030a806d8daab8ab3df20dfc93b4b315746e330e0c2f11d16ba70725f6f6e21
5
5
  SHA512:
6
- metadata.gz: b8e9a7bb7db412939e9cb41653a24672f69b0e54f8a4cc841116d51c6e6b541507fc36b26473e6f56547d3c9f9edb24f01242944d0021d3646bed4855b769d68
7
- data.tar.gz: 9943a2ef7bb19830590ddc57d50f4a8da5d53cde8751eb79d4956591864e6ad7f72eebc459715f25b116df5de0b484ffbd6eb0d4a94b1d95cfff412ee4a5acba
6
+ metadata.gz: ad8cdfd064da26fff6013df15e41562fb8b9463493dcc26510a5f48ddf4880c1b55bcf566c82c34ff1abd77b8102d93092283b4987ff8f62d19b33249e1e6e8b
7
+ data.tar.gz: 9b9302661f3b0c65a7b4c365a516b2833297d2fc683a2d6d75c84e051bfa70cc1daeeb0b22aa4f53be4aad8597604944100646a4a6d96935092b49f77a2a9b3e
data/CHANGELOG.md CHANGED
@@ -11,6 +11,12 @@ Prefix your message with one of the following:
11
11
  - [Security] in case of vulnerabilities.
12
12
  -->
13
13
 
14
+ ## v0.0.14
15
+
16
+ - [Fixed] Fix file redacting when no API key is defined.
17
+ - [Fixed] Trim transparent pixels from rendered text.
18
+ - [Fixed] Allow concurrency to be specified when generating voiceover.
19
+
14
20
  ## v0.0.13
15
21
 
16
22
  - [Fixed] Redact API key in config log.
data/DOCUMENTATION.md CHANGED
@@ -114,8 +114,6 @@ $ docker run \
114
114
  Notice that Chrome requires a lot of memory, so you need `--shm-size=2g` (or
115
115
  more).
116
116
 
117
- To create a new project:
118
-
119
117
  ---
120
118
 
121
119
  ## Quick Start
@@ -958,7 +956,7 @@ The engine name is camelized (e.g., `custom_engine` → `CustomEngine`,
958
956
 
959
957
  > [!TIP]
960
958
  >
961
- > If you host your TTS engine on Github, use the topic `screekit-tts`, so other
959
+ > If you host your TTS engine on Github, use the topic `screenkit-tts`, so other
962
960
  > people can find it.
963
961
 
964
962
  ---
@@ -1320,9 +1318,10 @@ bundle exec screenkit ...
1320
1318
 
1321
1319
  #### TTS not working
1322
1320
 
1323
- - For ElevenLabs: Set `--tts-api-key`
1324
- - For macOS `say`: Verify voice name with `say -v ?`
1325
- - For `espeak`: Ensure `espeak` is installed and in PATH
1321
+ - For ElevenLabs: set `--tts-api-key` with valid prefixed key, like
1322
+ `eleven_labs:API_KEY`
1323
+ - For macOS `say`: verify voice name with `say -v ?`
1324
+ - For `espeak`: ensure `espeak` is installed and in PATH
1326
1325
 
1327
1326
  #### Playwright scripts not working
1328
1327
 
@@ -69,15 +69,23 @@ module ScreenKit
69
69
  def export
70
70
  puts Banner.banner if options.banner
71
71
 
72
- project_config = if File.file?(options.config)
72
+ episode_config_path = File.join(options.dir, "config.yml")
73
+ has_project_config = File.file?(options.config)
74
+ has_episode_config = File.file?(episode_config_path)
75
+
76
+ if !has_project_config && !has_episode_config
77
+ shell.say "Error: No configuration file found.", :red
78
+ exit 1
79
+ end
80
+
81
+ project_config = if has_project_config
73
82
  Config.load_yaml_file(options.config)
74
83
  else
75
84
  {}
76
85
  end
77
86
 
78
- episode_config = File.join(options.dir, "config.yml")
79
- episode_config = if File.file?(episode_config)
80
- Config.load_yaml_file(episode_config)
87
+ episode_config = if has_episode_config
88
+ Config.load_yaml_file(episode_config_path)
81
89
  else
82
90
  {}
83
91
  end
@@ -95,6 +103,14 @@ module ScreenKit
95
103
  )
96
104
 
97
105
  exporter.export
106
+ ensure
107
+ exporter.output_dir.join("logs").glob("*.txt").each do |path|
108
+ redact_file(path, options.tts_api_key)
109
+ end
110
+ end
111
+
112
+ no_commands do
113
+ include RedactFile
98
114
  end
99
115
  end
100
116
  end
@@ -149,7 +149,8 @@ module ScreenKit
149
149
  spinner:,
150
150
  list: filtered_segments,
151
151
  message: "Exporting voiceovers (%{progress}/%{count})",
152
- log_path: logfile.create("%{prefix}", :voiceover)
152
+ log_path: logfile.create("%{prefix}", :voiceover),
153
+ concurrency: tts_engine.concurrency
153
154
  ).run(&:export_voiceover)
154
155
 
155
156
  log_elapsed("Generated voiceover in %{elapsed}", elapsed)
@@ -189,7 +190,7 @@ module ScreenKit
189
190
  source.search(watermark.path)
190
191
  else
191
192
  ScreenKit.root_dir
192
- .join("screenkit/resources/transparent.png")
193
+ .join("resources/transparent.png")
193
194
  end
194
195
 
195
196
  watermark_width, watermark_height = image_size(watermark_path)
@@ -94,6 +94,8 @@ module ScreenKit
94
94
  image << "-pointsize"
95
95
  image << style.size.to_s
96
96
  image << "#{type}:#{escape_text_for_image(text)}"
97
+ image << "-trim"
98
+ image << "+repage"
97
99
  image << "PNG:#{path}"
98
100
  end
99
101
 
@@ -2,10 +2,11 @@
2
2
 
3
3
  module ScreenKit
4
4
  class ParallelProcessor
5
- attr_reader :spinner, :list, :message, :mutex, :count, :log_path
5
+ attr_reader :spinner, :list, :message, :mutex, :count, :log_path,
6
+ :concurrency
6
7
  attr_accessor :progress
7
8
 
8
- def initialize(spinner:, list:, message:, log_path: nil)
9
+ def initialize(spinner:, list:, message:, log_path: nil, concurrency: nil)
9
10
  @list = list
10
11
  @message = message
11
12
  @spinner = spinner
@@ -13,6 +14,7 @@ module ScreenKit
13
14
  @progress = 0
14
15
  @count = list.size
15
16
  @log_path = log_path
17
+ @concurrency = concurrency || Etc.nprocessors
16
18
  end
17
19
 
18
20
  def run(&block)
@@ -20,7 +22,7 @@ module ScreenKit
20
22
  indexed_list = list.map.with_index {|item, index| [item, index] }
21
23
  arity = block.arity
22
24
 
23
- indexed_list.each_slice(Etc.nprocessors) do |slice|
25
+ indexed_list.each_slice(concurrency) do |slice|
24
26
  threads = slice.map do |args|
25
27
  thread = Thread.new do
26
28
  update_message
@@ -9,6 +9,7 @@ module ScreenKit
9
9
  def redact_file(path, text)
10
10
  return unless path
11
11
  return unless File.file?(path)
12
+ return if text.to_s.strip.empty?
12
13
 
13
14
  content = File.read(path).gsub(text, "[REDACTED]")
14
15
  File.write(path, content)
@@ -55,6 +55,10 @@ module ScreenKit
55
55
 
56
56
  @api_key = api_key.delete_prefix("#{self.class.engine_name}:")
57
57
  end
58
+
59
+ def concurrency
60
+ # to be implemented by subclasses if applicable
61
+ end
58
62
  end
59
63
  end
60
64
  end
@@ -14,6 +14,10 @@ module ScreenKit
14
14
  api_key.to_s.start_with?(api_key_prefix)
15
15
  end
16
16
 
17
+ def concurrency
18
+ 3
19
+ end
20
+
17
21
  def all_texts
18
22
  @all_texts ||= segments.map(&:script_content)
19
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ScreenKit
4
- VERSION = "0.0.13"
4
+ VERSION = "0.0.14"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: screenkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
@@ -421,10 +421,10 @@ metadata:
421
421
  rubygems_mfa_required: 'true'
422
422
  homepage_uri: https://github.com/fnando/screenkit
423
423
  bug_tracker_uri: https://github.com/fnando/screenkit/issues
424
- source_code_uri: https://github.com/fnando/screenkit/tree/v0.0.13
425
- changelog_uri: https://github.com/fnando/screenkit/tree/v0.0.13/CHANGELOG.md
426
- documentation_uri: https://github.com/fnando/screenkit/tree/v0.0.13/README.md
427
- license_uri: https://github.com/fnando/screenkit/tree/v0.0.13/LICENSE.md
424
+ source_code_uri: https://github.com/fnando/screenkit/tree/v0.0.14
425
+ changelog_uri: https://github.com/fnando/screenkit/tree/v0.0.14/CHANGELOG.md
426
+ documentation_uri: https://github.com/fnando/screenkit/tree/v0.0.14/README.md
427
+ license_uri: https://github.com/fnando/screenkit/tree/v0.0.14/LICENSE.md
428
428
  rdoc_options: []
429
429
  require_paths:
430
430
  - lib