Sha256: 78d75c95c8818472554e8e9ff3e48fbf0d9b6988deea103e338f76180916616c

Contents?: true

Size: 629 Bytes

Versions: 5

Compression:

Stored size: 629 Bytes

Contents

#encoding: UTF-8
module Termit
  class SpeechSynthesizer
    extend ::Delegation
    @output_manager = Termit::OutputManager.new
    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

5 entries across 5 versions & 1 rubygems

Version Path
termit-2.10.0 lib/termit/speech_synthesizer.rb
termit-2.0.9 lib/termit/speech_synthesizer.rb
termit-2.0.8 lib/termit/speech_synthesizer.rb
termit-2.0.7 lib/termit/speech_synthesizer.rb
termit-2.0.6 lib/termit/speech_synthesizer.rb