Class: Agents::TtsAgent
- Inherits:
-
Agent
- Object
- Agent
- Agents::TtsAgent
- Includes:
- FormConfigurable
- Defined in:
- lib/huginn_tts_agent/tts_agent.rb
Instance Method Summary collapse
- #check ⇒ Object
- #default_options ⇒ Object
- #receive(incoming_events) ⇒ Object
- #validate_options ⇒ Object
- #working? ⇒ Boolean
Instance Method Details
#check ⇒ Object
100 101 102 |
# File 'lib/huginn_tts_agent/tts_agent.rb', line 100 def check trigger_action end |
#default_options ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/huginn_tts_agent/tts_agent.rb', line 52 def { 'type' => 'elevenlabs', 'api_key' => '', 'text' => '', 'debug' => 'false', 'expected_receive_period_in_days' => '2', } end |
#receive(incoming_events) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/huginn_tts_agent/tts_agent.rb', line 91 def receive(incoming_events) incoming_events.each do |event| interpolate_with(event) do log event trigger_action end end end |
#validate_options ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/huginn_tts_agent/tts_agent.rb', line 67 def errors.add(:base, "type has invalid value: should be 'elevenlabs'") if interpolated['type'].present? && !%w(elevenlabs).include?(interpolated['type']) unless ['api_key'].present? || !['elevenlabs'].include?(['type']) errors.add(:base, "api_key is a required field") end unless ['text'].present? errors.add(:base, "text is a required field") end if .has_key?('debug') && boolify(['debug']).nil? errors.add(:base, "if provided, debug must be true or false") end unless ['expected_receive_period_in_days'].present? && ['expected_receive_period_in_days'].to_i > 0 errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working") end end |
#working? ⇒ Boolean
87 88 89 |
# File 'lib/huginn_tts_agent/tts_agent.rb', line 87 def working? event_created_within?(['expected_receive_period_in_days']) && !recent_error_logs? end |