Sha256: 457c11b77533b3889e6b4b757c45c57135a5092bb6b282263699c2bbbd5c2759

Contents?: true

Size: 581 Bytes

Versions: 7

Compression:

Stored size: 581 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::DataFetcher.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

7 entries across 7 versions & 1 rubygems

Version Path
termit-2.13.0 lib/termit/speech_synthesizer.rb
termit-2.12.1 lib/termit/speech_synthesizer.rb
termit-2.12.0 lib/termit/speech_synthesizer.rb
termit-2.11.2 lib/termit/speech_synthesizer.rb
termit-2.11.1 lib/termit/speech_synthesizer.rb
termit-2.11.0 lib/termit/speech_synthesizer.rb
termit-2.10.2 lib/termit/speech_synthesizer.rb