Class: AssemblyAI::RealtimeClient
- Inherits:
-
Object
- Object
- AssemblyAI::RealtimeClient
- Defined in:
- lib/assemblyai/realtime/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create_temporary_token(expires_in:, request_options: nil) ⇒ AssemblyAI::Realtime::RealtimeTemporaryTokenResponse
Create a temporary authentication token for Streaming Speech-to-Text.
- #initialize(request_client:) ⇒ AssemblyAI::RealtimeClient constructor
Constructor Details
#initialize(request_client:) ⇒ AssemblyAI::RealtimeClient
14 15 16 |
# File 'lib/assemblyai/realtime/client.rb', line 14 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ AssemblyAI::RequestClient (readonly)
10 11 12 |
# File 'lib/assemblyai/realtime/client.rb', line 10 def request_client @request_client end |
Instance Method Details
#create_temporary_token(expires_in:, request_options: nil) ⇒ AssemblyAI::Realtime::RealtimeTemporaryTokenResponse
Create a temporary authentication token for Streaming Speech-to-Text
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/assemblyai/realtime/client.rb', line 30 def create_temporary_token(expires_in:, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .api_key unless &.api_key.nil? req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), expires_in: expires_in }.compact req.url "#{@request_client.get_url(request_options: )}/v2/realtime/token" end AssemblyAI::Realtime::RealtimeTemporaryTokenResponse.from_json(json_object: response.body) end |