Sha256: 6f05733077d3214c60149f150028a82eae5511b32462f692d654a1abaca813cc

Contents?: true

Size: 583 Bytes

Versions: 8

Compression:

Stored size: 583 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

8 entries across 8 versions & 1 rubygems

Version Path
termit-3.9.0 lib/termit/speech_synthesizer.rb
termit-3.8.0 lib/termit/speech_synthesizer.rb
termit-3.7.0 lib/termit/speech_synthesizer.rb
termit-3.6.0 lib/termit/speech_synthesizer.rb
termit-3.5.0 lib/termit/speech_synthesizer.rb
termit-3.4.0 lib/termit/speech_synthesizer.rb
termit-3.2.0 lib/termit/speech_synthesizer.rb
termit-3.1.2 lib/termit/speech_synthesizer.rb