Skip to content

This is the official Ruby Gem for Grammatek TTS API

License

Notifications You must be signed in to change notification settings

grammatek/tts-ruby-gem

Repository files navigation

grammatek-tts

GTTS - the Ruby gem for the TTS API

This API gives access to Grammatek ehf advanced text to speech services. It provides endpoints to query all available voices and synthesize speech from given text for a particular voice. You can synthesize speech in several audio formats and different sample rates. Please authenticate with your client credentials via the /auth/v1 endpoint to receive a temporary access token for all API endpoints. This token is valid only for a certain time and you need to re-authenticate after it has expired. Please contact Grammatek via info@grammatek.com to receive your individual client credentials.

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: v1.0
  • Package version: 0.5
  • Build package: org.openapitools.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build grammatek-tts.gemspec

Then either install the gem locally:

gem install ./grammatek-tts-0.5.gem

(for development, run gem install --dev ./grammatek-tts-0.5.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'grammatek-tts', '~> 0.5'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'grammatek-tts', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'grammatek-tts'

# Setup authorization
GTTS.configure do |config|
  # Configure Bearer authorization: bearerAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
  # Configure a proc to get access tokens in lieu of the static access_token configuration
  config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } 
  # Configure faraday connection
  config.configure_faraday_connection { |connection| 'YOUR CONNECTION CONFIG PROC' }
end

api_instance = GTTS::AuthApi.new

begin
  #Get token info and expiration time
  result = api_instance.get_token_info
  p result
rescue GTTS::ApiError => e
  puts "Exception when calling AuthApi->get_token_info: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://api2.grammatek.com

Class Method HTTP request Description
GTTS::AuthApi get_token_info GET /auth/v1/token-info Get token info and expiration time
GTTS::AuthApi post_auth POST /auth/v1 Authenticate and receive access token
GTTS::SpeechApi get_voices GET /tts/v1/voices Describe/query available voices
GTTS::SpeechApi post_speech POST /tts/v1/speech TTS - Synthesize speech from text

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: Bearer authentication

About

This is the official Ruby Gem for Grammatek TTS API

Resources

License

Stars

Watchers

Forks

Packages

No packages published