Sha256: c07b535979862525f9ccb9560e708b24651b25580b4178ba5072468fac750ff4

Contents?: true

Size: 582 Bytes

Versions: 5

Compression:

Stored size: 582 Bytes

Contents

#encoding: UTF-8
module Termit
  class SpeechSynthesizer
    include CanOutput
    delegate :display_player_error_and_quit, to: :output_manager

    def initialize options
      check_sound_player
      @text = options[:text]
      @url = Termit::UrlConstructor.new(options).url
    end

    def call
      response = Termit::SoundFetcher.new(@url, @text).data
      Termit::SoundResponseHandler.new(response.body).call
    end

    private

    def check_sound_player
      unless system 'which mpg123 > /dev/null'
        display_player_error_and_quit
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
termit-3.1.1 lib/termit/speech_synthesizer.rb
termit-3.1.0 lib/termit/speech_synthesizer.rb
termit-3.0.2 lib/termit/speech_synthesizer.rb
termit-3.0.1 lib/termit/speech_synthesizer.rb
termit-3.0.0 lib/termit/speech_synthesizer.rb