Class: Deepgram::Listen::Client
Overview
The Client class within the Listen module extends the Base class to handle operations specific to the Deepgram ‘Listen’ API endpoint.
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
Initializes the Client object for the Deepgram ‘Listen’ service, setting up the necessary API endpoint and request headers for JSON.
-
#transcribe_file(path:, audio_format: 'audio/wav', **kwargs) ⇒ Deepgram::Listen::Response
Transcribes audio content from a file.
-
#transcribe_url(url:, **kwargs) ⇒ Deepgram::Listen::Response
Transcribes audio content from a URL.
Methods included from ResponseHandler
Constructor Details
#initialize ⇒ Client
Initializes the Client object for the Deepgram ‘Listen’ service, setting up the necessary API endpoint and request headers for JSON.
10 11 12 13 14 15 |
# File 'lib/deepgram/listen.rb', line 10 def initialize super @connection.path_prefix = 'v1/listen' @connection.headers['Content-Type'] = 'application/json' @connection.headers['Accept'] = 'application/json' end |
Instance Method Details
#transcribe_file(path:, audio_format: 'audio/wav', **kwargs) ⇒ Deepgram::Listen::Response
Transcribes audio content from a file.
23 24 25 26 27 28 29 30 |
# File 'lib/deepgram/listen.rb', line 23 def transcribe_file(path:, audio_format: 'audio/wav', **kwargs) validate_file_path(path) request(:post, **kwargs) do |request| request.headers['Content-Type'] = audio_format request.body = File.binread(path) end end |
#transcribe_url(url:, **kwargs) ⇒ Deepgram::Listen::Response
Transcribes audio content from a URL.
37 38 39 40 41 42 43 |
# File 'lib/deepgram/listen.rb', line 37 def transcribe_url(url:, **kwargs) validate_url(url) request(:post, **kwargs) do |request| request.body = JSON.generate(url: url) end end |