screenkit-tts-google 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 952e3cde239735a34fcfd0d3a8868768d10e386d685d919edd1b6bcd6de762e4
4
+ data.tar.gz: b6feb84d1ac3a2843035bde8838d45c2d10f0620355038343df94d99ac92dc4d
5
+ SHA512:
6
+ metadata.gz: a77b03558ea94e850f0ca8e80aca239169070ade34c301c2bd5cc4c7d8ea8b6323c2b7e87758320be95bd4040193766cf9471f8114e27f338bf006850222e37a
7
+ data.tar.gz: e02c216cab1757251468b55c86f352905351ee3dc2ef35707531aae4ad435b18f0b3b6c86f58e7ec979a296a32691135d141ee546d82b8ca6a23a5ec58fdc9a5
@@ -0,0 +1,4 @@
1
+ # You can read more about CODEOWNERS at
2
+ # https://help.github.com/github/creating-cloning-and-archiving-repositories/about-code-owners
3
+
4
+ * @fnando
@@ -0,0 +1,4 @@
1
+ # These are supported funding model platforms
2
+ ---
3
+ github: [fnando]
4
+ custom: ["https://paypal.me/nandovieira/๐Ÿ•"]
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: "๐Ÿ› Bug Report"
3
+ about: Report a reproducible bug or regression.
4
+ title: 'Bug: '
5
+ labels: 'Status: Unconfirmed'
6
+
7
+ ---
8
+
9
+ <!--
10
+ - Please provide a clear and concise description of what the bug is.
11
+ - If possible, add an example reproducing your issue.
12
+ - Please test using the latest version of screen_kit
13
+ to make sure your issue has not already been fixed.
14
+ -->
15
+
16
+ ## Description
17
+
18
+ [Add bug description here]
19
+
20
+ ## How to reproduce
21
+
22
+ [Add steps on how to reproduce this issue]
23
+
24
+ ## What do you expect
25
+
26
+ [Describe what do you expect to happen]
27
+
28
+ ## What happened instead
29
+
30
+ [Describe the actual results]
31
+
32
+ ## Software:
33
+
34
+ - Gem version: [Add gem version here]
35
+ - Ruby version: [Add version here]
36
+
37
+ ## Full backtrace
38
+
39
+ ```text
40
+ [Paste full backtrace here]
41
+ ```
@@ -0,0 +1,5 @@
1
+ ---
2
+ contact_links:
3
+ - name: "๐Ÿคจ Q&A"
4
+ url: https://github.com/fnando/screen_kit/discussions/new?category=q-a
5
+ about: Have a question? Ask it away here!
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: "๐Ÿ’ก Feature request"
3
+ about: Have an idea that may be useful? Make a suggestion!
4
+ title: 'Feature Request: '
5
+ labels: 'Feature request'
6
+
7
+ ---
8
+
9
+ ## Description
10
+
11
+ _A clear and concise description of what the problem is._
12
+
13
+ ## Describe the solution
14
+
15
+ _A clear and concise description of what you want to happen._
16
+
17
+ ## Alternatives you considered
18
+
19
+ _A clear and concise description of any alternative solutions or features you've considered._
20
+
21
+ ## Additional context
22
+
23
+ _Add any other context, screenshots, links, etc about the feature request here._
@@ -0,0 +1,38 @@
1
+ <!--
2
+ If you're making a doc PR or something tiny where the below is irrelevant,
3
+ delete this template and use a short description, but in your description aim to
4
+ include both what the change is, and why it is being made, with enough context
5
+ for anyone to understand.
6
+ -->
7
+
8
+ <details>
9
+ <summary>PR Checklist</summary>
10
+
11
+ ### PR Structure
12
+
13
+ - [ ] This PR has reasonably narrow scope (if not, break it down into smaller
14
+ PRs).
15
+ - [ ] This PR avoids mixing refactoring changes with feature changes (split into
16
+ two PRs otherwise).
17
+ - [ ] This PR's title starts is concise and descriptive.
18
+
19
+ ### Thoroughness
20
+
21
+ - [ ] This PR adds tests for the most critical parts of the new functionality or
22
+ fixes.
23
+ - [ ] I've updated any docs, `.md` files, etcโ€ฆ affected by this change.
24
+
25
+ </details>
26
+
27
+ ### What
28
+
29
+ [TODO: Short statement about what is changing.]
30
+
31
+ ### Why
32
+
33
+ [TODO: Why this change is being made. Include any context required to understand
34
+ the why.]
35
+
36
+ ### Known limitations
37
+
38
+ [TODO or N/A]
@@ -0,0 +1,15 @@
1
+ ---
2
+ # Documentation:
3
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
4
+
5
+ version: 2
6
+ updates:
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
11
+
12
+ - package-ecosystem: bundler
13
+ directory: "/"
14
+ schedule:
15
+ interval: "daily"
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: ruby-tests
3
+
4
+ on:
5
+ pull_request_target:
6
+ push:
7
+ branches:
8
+ - main
9
+ workflow_dispatch:
10
+ inputs: {}
11
+
12
+ jobs:
13
+ build:
14
+ name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
15
+ runs-on: "ubuntu-latest"
16
+ if: |
17
+ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
18
+ github.actor != 'dependabot[bot]'
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ ruby: ["3.4"]
23
+ gemfile:
24
+ - Gemfile
25
+
26
+ steps:
27
+ - uses: actions/checkout@v1
28
+
29
+ - uses: actions/cache@v2
30
+ with:
31
+ path: vendor/bundle
32
+ key: >
33
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles(matrix.gemfile) }}
34
+
35
+ - name: Set up Ruby
36
+ uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby }}
39
+
40
+ - name: Install gem dependencies
41
+ env:
42
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
43
+ run: |
44
+ gem install bundler
45
+ bundle config path vendor/bundle
46
+ bundle update --jobs 4 --retry 3
47
+
48
+ - name: Run Tests
49
+ env:
50
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
51
+ run: |
52
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/
10
+ *.log
11
+ *.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ ---
2
+ inherit_gem:
3
+ rubocop-fnando: .rubocop.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 3.4
7
+ NewCops: enable
8
+ Exclude:
9
+ - vendor/**/*
10
+ - gemfiles/**/*
11
+
12
+ Gemspec/AttributeAssignment:
13
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ <!--
4
+ Prefix your message with one of the following:
5
+
6
+ - [Added] for new features.
7
+ - [Changed] for changes in existing functionality.
8
+ - [Deprecated] for soon-to-be removed features.
9
+ - [Removed] for now removed features.
10
+ - [Fixed] for any bug fixes.
11
+ - [Security] in case of vulnerabilities.
12
+ -->
13
+
14
+ ## v0.0.1
15
+
16
+ - Initial release.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at me@fnando.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,81 @@
1
+ # Contributing to screenkit-tts-google
2
+
3
+ ๐Ÿ‘๐ŸŽ‰ First off, thanks for taking the time to contribute! ๐ŸŽ‰๐Ÿ‘
4
+
5
+ The following is a set of guidelines for contributing to this project. These are
6
+ mostly guidelines, not rules. Use your best judgment, and feel free to propose
7
+ changes to this document in a pull request.
8
+
9
+ ## Code of Conduct
10
+
11
+ Everyone interacting in this project's codebases, issue trackers, chat rooms and
12
+ mailing lists is expected to follow the
13
+ [code of conduct](https://github.com/fnando/screenkit-tts-google/blob/main/CODE_OF_CONDUCT.md).
14
+
15
+ ## Reporting bugs
16
+
17
+ This section guides you through submitting a bug report. Following these
18
+ guidelines helps maintainers and the community understand your report, reproduce
19
+ the behavior, and find related reports.
20
+
21
+ - Before creating bug reports, please check the open issues; somebody may
22
+ already have submitted something similar, and you may not need to create a new
23
+ one.
24
+ - When you are creating a bug report, please include as many details as
25
+ possible, with an example reproducing the issue.
26
+
27
+ ## Contributing with code
28
+
29
+ Before making any radicals changes, please make sure you discuss your intention
30
+ by
31
+ [opening an issue on Github](https://github.com/fnando/screenkit-tts-google/issues).
32
+
33
+ When you're ready to make your pull request, follow checklist below to make sure
34
+ your contribution is according to how this project works.
35
+
36
+ 1. [Fork](https://help.github.com/forking/) screenkit-tts-google
37
+ 2. Create a topic branch - `git checkout -b my_branch`
38
+ 3. Make your changes using [descriptive commit messages](#commit-messages)
39
+ 4. Update CHANGELOG.md describing your changes by adding an entry to the
40
+ "Unreleased" section. If this section is not available, create one right
41
+ before the last version.
42
+ 5. Push to your branch - `git push origin my_branch`
43
+ 6. [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
44
+ 7. That's it!
45
+
46
+ ## Styleguides
47
+
48
+ ### Commit messages
49
+
50
+ - Use the present tense ("Add feature" not "Added feature")
51
+ - Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
52
+ - Limit the first line to 72 characters or less
53
+ - Reference issues and pull requests liberally after the first line
54
+
55
+ ### Changelog
56
+
57
+ - Add a message describing your changes to the "Unreleased" section. The
58
+ changelog message should follow the same style as the commit message.
59
+ - Prefix your message with one of the following:
60
+ - `[Added]` for new features.
61
+ - `[Changed]` for changes in existing functionality.
62
+ - `[Deprecated]` for soon-to-be removed features.
63
+ - `[Removed]` for now removed features.
64
+ - `[Fixed]` for any bug fixes.
65
+ - `[Security]` in case of vulnerabilities.
66
+
67
+ ### Ruby code
68
+
69
+ - This project uses [Rubocop](https://rubocop.org) to enforce code style. Before
70
+ submitting your changes, make sure your tests are passing and code conforms to
71
+ the expected style by running `rake`.
72
+ - Do not change the library version. This will be done by the maintainer
73
+ whenever a new version is about to be released.
74
+
75
+ ### JavaScript code
76
+
77
+ - This project uses [ESLint](https://eslint.org) to enforce code style. Before
78
+ submitting your changes, make sure your tests are passing and code conforms to
79
+ the expected style by running `yarn test:ci`.
80
+ - Do not change the library version. This will be done by the maintainer
81
+ whenever a new version is about to be released.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # screenkit-tts-google
2
+
3
+ [![Tests](https://github.com/fnando/screenkit-tts-google/workflows/ruby-tests/badge.svg)](https://github.com/fnando/screenkit-tts-google)
4
+ [![Gem](https://img.shields.io/gem/v/screenkit-tts-google.svg)](https://rubygems.org/gems/screenkit-tts-google)
5
+ [![Gem](https://img.shields.io/gem/dt/screenkit-tts-google.svg)](https://rubygems.org/gems/screenkit-tts-google)
6
+ [![MIT License](https://img.shields.io/:License-MIT-blue.svg)](https://tldrlegal.com/license/mit-license)
7
+
8
+ TTS engine for ScreenKit
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ gem install screenkit-tts-google
14
+ ```
15
+
16
+ Or add the following line to your project's Gemfile:
17
+
18
+ ```ruby
19
+ gem "screenkit-tts-google"
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ When calling [screenkit](https://github.com/fnando/screenkit), you must provide
25
+ a JSON file that starts with `google` in its name (e.g. `google.json`,
26
+ `google-credentials.json`, etc).
27
+
28
+ ```base
29
+ screenkit episode export --dir episodes/001* --api-key google.json
30
+ ```
31
+
32
+ Then, add the following to your ScreenKit configuration:
33
+
34
+ ```yaml
35
+ tts:
36
+ - id: google
37
+ engine: google
38
+ enabled: true
39
+ voice:
40
+ language_code: en-US
41
+ ssml_gender: "FEMALE"
42
+ audio_config:
43
+ audio_encoding: "M4A"
44
+ speaking_rate: 1.0
45
+ ```
46
+
47
+ For more info, see:
48
+
49
+ - [Google Text to Speech API](https://docs.cloud.google.com/text-to-speech/docs/reference/rest/v1/text/synthesize)
50
+
51
+ ## Maintainer
52
+
53
+ - [Nando Vieira](https://github.com/fnando)
54
+
55
+ ## Contributors
56
+
57
+ - https://github.com/fnando/screenkit-tts-google/contributors
58
+
59
+ ## Contributing
60
+
61
+ For more details about how to contribute, please read
62
+ https://github.com/fnando/screenkit-tts-google/blob/main/CONTRIBUTING.md.
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the
67
+ [MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
68
+ found at https://github.com/fnando/screenkit-tts-google/blob/main/LICENSE.md.
69
+
70
+ ## Code of Conduct
71
+
72
+ Everyone interacting in the screenkit-tts-google project's codebases, issue
73
+ trackers, chat rooms and mailing lists is expected to follow the
74
+ [code of conduct](https://github.com/fnando/screenkit-tts-google/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "rubocop/rake_task"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.libs << "lib"
10
+ t.test_files = FileList["test/**/*_test.rb"]
11
+ end
12
+
13
+ RuboCop::RakeTask.new
14
+
15
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "screen_kit"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ begin
11
+ require "pry"
12
+ Pry.start
13
+ rescue LoadError
14
+ require "irb"
15
+ IRB.start(__FILE__)
16
+ end
data/bin/setup ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ IFS=$'\n\t'
6
+ set -vx
7
+
8
+ bundle install
9
+
10
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,99 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "$id": "https://screenkit.dev/schemas/tts/google.json",
4
+ "title": "The Apple `say` voice engine options",
5
+ "type": "object",
6
+ "properties": {
7
+ "id": {
8
+ "type": "string",
9
+ "description": "A unique identifier for the tts configuration"
10
+ },
11
+ "enabled": {
12
+ "type": "boolean"
13
+ },
14
+ "engine": {
15
+ "type": "string",
16
+ "enum": ["google"],
17
+ "description": "The TTS engine to use"
18
+ },
19
+ "input": {
20
+ "type": "object",
21
+ "properties": {
22
+ "custom_proununciations": {
23
+ "type": "object",
24
+ "properties": {
25
+ "pronunciations": {
26
+ "type": "array",
27
+ "items": {
28
+ "type": "object",
29
+ "properties": {
30
+ "phrase": {
31
+ "type": "string"
32
+ },
33
+ "phonetic_encoding": {
34
+ "type": "string",
35
+ "enum": [
36
+ "PHONETIC_ENCODING_UNSPECIFIED",
37
+ "PHONETIC_ENCODING_IPA",
38
+ "PHONETIC_ENCODING_X_SAMPA",
39
+ "PHONETIC_ENCODING_JAPANESE_YOMIGANA",
40
+ "PHONETIC_ENCODING_PINYIN"
41
+ ]
42
+ },
43
+ "pronunciation": {
44
+ "type": "string"
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ },
53
+ "voice": {
54
+ "description": "The voice configuraiton",
55
+ "type": "object",
56
+ "properties": {
57
+ "language_code": {
58
+ "type": "string",
59
+ "description": "The language code of the voice"
60
+ },
61
+ "ssml_gender": {
62
+ "type": "string",
63
+ "enum": ["FEMALE", "MALE", "NEUTRAL"]
64
+ },
65
+ "model_name": {
66
+ "type": "string"
67
+ }
68
+ }
69
+ },
70
+ "audio_config": {
71
+ "description": "The audio configuraiton",
72
+ "type": "object",
73
+ "properties": {
74
+ "audio_encoding": {
75
+ "type": "string",
76
+ "enum": ["MP3", "PCM", "M4A", "OGG_OPUS", "LINEAR16", "MULAW", "ALAW"]
77
+ },
78
+ "speaking_rate": {
79
+ "type": "number"
80
+ },
81
+ "pitch": {
82
+ "type": "number"
83
+ },
84
+ "volume_gain_db": {
85
+ "type": "number"
86
+ },
87
+ "sampleRateHertz": {
88
+ "type": "integer"
89
+ },
90
+ "effects_profile_id": {
91
+ "type": "array",
92
+ "items": {
93
+ "type": "string"
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ScreenKit
4
+ module TTS
5
+ class Google < Base
6
+ VERSION = "0.0.1"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "screenkit/tts/base"
4
+ require "google/cloud/text_to_speech"
5
+
6
+ module ScreenKit
7
+ require_relative "google/version"
8
+
9
+ EXTENSION = {
10
+ "MP3" => ".mp3",
11
+ "PCM" => ".pcm",
12
+ "M4A" => ".m4a",
13
+ "OGG_OPUS" => ".ogg",
14
+ "LINEAR16" => ".wav",
15
+ "MULAW" => ".wav",
16
+ "ALAW" => ".wav"
17
+ }.freeze
18
+
19
+ module TTS
20
+ class Google < Base
21
+ def self.schema_path
22
+ File.join(__dir__, "google/schema.json")
23
+ end
24
+
25
+ def self.available?(api_key: nil, **)
26
+ api_key && File.basename(api_key).match?(/^google.*\.json$/)
27
+ end
28
+
29
+ # This method is required.
30
+ def generate(text:, output_path:, log_path: nil, **)
31
+ # Optional: validate options against JSON schema.
32
+ self.class.validate!(options)
33
+
34
+ if log_path
35
+ File.open(log_path, "w") do |f|
36
+ f << JSON.pretty_generate(options.merge(input: {text:}))
37
+ end
38
+ end
39
+
40
+ client = ::Google::Cloud::TextToSpeech.text_to_speech do |config|
41
+ config.credentials = api_key
42
+ config.logger = Logger.new(log_path, level: Logger::DEBUG) if log_path
43
+ end
44
+
45
+ trace = ENV.fetch("GRPC_TRACE", nil)
46
+ verbosity = ENV.fetch("GRPC_VERBOSITY", nil)
47
+
48
+ ENV["GRPC_TRACE"] = "all"
49
+ ENV["GRPC_VERBOSITY"] = "debug"
50
+
51
+ audio_config = {
52
+ audio_encoding: "MP3"
53
+ }.merge(options[:audio_config] || {})
54
+
55
+ output_path = Pathname(output_path)
56
+ .sub_ext(EXTENSION[audio_config[:audio_encoding]])
57
+
58
+ response = client.synthesize_speech(
59
+ input: {text:},
60
+ voice: options[:voice],
61
+ audio_config:
62
+ )
63
+
64
+ File.binwrite(output_path, response.audio_content)
65
+ ensure
66
+ ENV["GRPC_TRACE"] = trace if trace
67
+ ENV["GRPC_VERBOSITY"] = verbosity if verbosity
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/screenkit/tts/google"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "screenkit-tts-google"
7
+ spec.version = ScreenKit::TTS::Google::VERSION
8
+ spec.authors = ["Nando Vieira"]
9
+ spec.email = ["me@fnando.com"]
10
+ spec.metadata = {"rubygems_mfa_required" => "true"}
11
+
12
+ spec.summary = "Google TTS engine for ScreenKit"
13
+ spec.description = spec.summary
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.4.0")
16
+
17
+ github_url = "https://github.com/fnando/screenkit-tts-google"
18
+ github_tree_url = "#{github_url}/tree/v#{spec.version}"
19
+
20
+ spec.homepage = github_url
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["bug_tracker_uri"] = "#{github_url}/issues"
23
+ spec.metadata["source_code_uri"] = github_tree_url
24
+ spec.metadata["changelog_uri"] = "#{github_tree_url}/CHANGELOG.md"
25
+ spec.metadata["documentation_uri"] = "#{github_tree_url}/README.md"
26
+ spec.metadata["license_uri"] = "#{github_tree_url}/LICENSE.md"
27
+
28
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
+ `git ls-files -z`
30
+ .split("\x0")
31
+ .reject {|f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_dependency "google-cloud-text_to_speech"
39
+ spec.add_dependency "screenkit"
40
+ spec.add_development_dependency "minitest"
41
+ spec.add_development_dependency "minitest-utils"
42
+ spec.add_development_dependency "pry-meta"
43
+ spec.add_development_dependency "rake"
44
+ spec.add_development_dependency "rubocop"
45
+ spec.add_development_dependency "rubocop-fnando"
46
+ spec.add_development_dependency "simplecov"
47
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: screenkit-tts-google
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nando Vieira
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: google-cloud-text_to_speech
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: screenkit
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: minitest
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: minitest-utils
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: pry-meta
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-fnando
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: simplecov
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ description: Google TTS engine for ScreenKit
139
+ email:
140
+ - me@fnando.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - ".github/CODEOWNERS"
146
+ - ".github/FUNDING.yml"
147
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
148
+ - ".github/ISSUE_TEMPLATE/config.yml"
149
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
150
+ - ".github/PULL_REQUEST_TEMPLATE.md"
151
+ - ".github/dependabot.yml"
152
+ - ".github/workflows/ruby-tests.yml"
153
+ - ".gitignore"
154
+ - ".rubocop.yml"
155
+ - CHANGELOG.md
156
+ - CODE_OF_CONDUCT.md
157
+ - CONTRIBUTING.md
158
+ - Gemfile
159
+ - LICENSE.md
160
+ - README.md
161
+ - Rakefile
162
+ - bin/console
163
+ - bin/setup
164
+ - lib/screenkit/tts/google.rb
165
+ - lib/screenkit/tts/google/schema.json
166
+ - lib/screenkit/tts/google/version.rb
167
+ - screenkit-tts-google.gemspec
168
+ homepage: https://github.com/fnando/screenkit-tts-google
169
+ licenses:
170
+ - MIT
171
+ metadata:
172
+ rubygems_mfa_required: 'true'
173
+ homepage_uri: https://github.com/fnando/screenkit-tts-google
174
+ bug_tracker_uri: https://github.com/fnando/screenkit-tts-google/issues
175
+ source_code_uri: https://github.com/fnando/screenkit-tts-google/tree/v0.0.1
176
+ changelog_uri: https://github.com/fnando/screenkit-tts-google/tree/v0.0.1/CHANGELOG.md
177
+ documentation_uri: https://github.com/fnando/screenkit-tts-google/tree/v0.0.1/README.md
178
+ license_uri: https://github.com/fnando/screenkit-tts-google/tree/v0.0.1/LICENSE.md
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: 3.4.0
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubygems_version: 3.6.9
194
+ specification_version: 4
195
+ summary: Google TTS engine for ScreenKit
196
+ test_files: []