Class: Deepgram::Read::Client
Overview
The Client class extends the Base class to handle read operations specific to the Deepgram ‘Read’ API endpoint.
Instance Method Summary collapse
-
#analyze(text:, **kwargs) ⇒ Deepgram::Read::Response
Sends a POST request to analyze text using the Deepgram Read API.
-
#initialize(language = 'en') ⇒ Client
constructor
Initializes a Client object for the Deepgram ‘Read’ service.
Methods inherited from Base
Methods included from Deepgram::ResponseHandler
Constructor Details
#initialize(language = 'en') ⇒ Client
Initializes a Client object for the Deepgram ‘Read’ service. Sets the default language and appropriate headers for JSON requests.
14 15 16 17 18 19 |
# File 'lib/deepgram/read.rb', line 14 def initialize(language = 'en') super() @connection.path_prefix = 'v1/read' @connection.params[:language] = language @connection.headers['Content-Type'] = 'application/json' end |
Instance Method Details
#analyze(text:, **kwargs) ⇒ Deepgram::Read::Response
Sends a POST request to analyze text using the Deepgram Read API. Returns a Response object containing the analysis results.
27 28 29 30 31 32 33 |
# File 'lib/deepgram/read.rb', line 27 def analyze(text:, **kwargs) res = request(:post, **kwargs) do |request| request.body = JSON.generate(text: text) end Response.new(status: res.status, body: res.body, headers: res.headers) end |