Class: Interfacets::Client::Channels::SpeechToText
- Inherits:
-
Object
- Object
- Interfacets::Client::Channels::SpeechToText
show all
- Includes:
- Base
- Defined in:
- lib/interfacets/client/channels/speech_to_text.rb
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
Attributes included from Base
#id
Instance Method Summary
collapse
Methods included from Base
#initialize, #type
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Instance Attribute Details
#helper ⇒ Object
Returns the value of attribute helper.
50
51
52
|
# File 'lib/interfacets/client/channels/speech_to_text.rb', line 50
def helper
@helper
end
|
Instance Method Details
#builder(stream = "default") ⇒ Object
57
58
59
|
# File 'lib/interfacets/client/channels/speech_to_text.rb', line 57
def builder(stream = "default")
@builder
end
|
#handle(event:, entity:) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/interfacets/client/channels/speech_to_text.rb', line 61
def handle(event:, entity:, **)
callback_id = event.dig("payload", "id")
case event.fetch("type")
when "text-result"
builder
.callbacks
.delete(callback_id)
.fetch(:on_done)
.then do
entity.instance_exec(event.dig("payload", "text"), &_1)
end
when "text-progress"
builder
.callbacks
.fetch(callback_id)
.fetch(:on_progress)
.then do
entity.instance_exec(event.dig("payload", "text"), &_1)
end
when "text-submit"
builder
.callbacks
.fetch(callback_id)
.fetch(:on_submit)
.then do
entity.instance_exec(event.dig("payload", "text"), &_1)
end
else
raise "unknown event type: #{event.inspect}"
end
end
|
#prepare(entity) ⇒ Object
52
53
54
55
|
# File 'lib/interfacets/client/channels/speech_to_text.rb', line 52
def prepare(entity)
@builder ||= Builder.new
@builder.entity = entity
end
|
#result ⇒ Object
94
95
96
|
# File 'lib/interfacets/client/channels/speech_to_text.rb', line 94
def result
{ streams: { default: @builder.flush_event } }
end
|