Class: Deepgram::Speak::Client
Overview
The Client class within the Speak module extends the Base class to handle operations specific to the Deepgram ‘Speak’ API endpoint.
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
Initializes the Client object for the Deepgram ‘Speak’ service, setting up the necessary API endpoint and request headers for JSON.
-
#speak(text:, **kwargs) ⇒ Deepgram::Speak::Response
Sends a synchronous request to convert text to speech.
-
#speak_async(text:, callback_url:, **kwargs) ⇒ Deepgram::Speak::Response
Sends an asynchronous request to convert text to speech, with the results sent to a specified callback URL.
Methods included from ResponseHandler
Constructor Details
#initialize ⇒ Client
Initializes the Client object for the Deepgram ‘Speak’ service, setting up the necessary API endpoint and request headers for JSON.
10 11 12 13 14 |
# File 'lib/deepgram/speak.rb', line 10 def initialize super @connection.path_prefix = 'v1/speak' @connection.headers['Content-Type'] = 'application/json' end |
Instance Method Details
#speak(text:, **kwargs) ⇒ Deepgram::Speak::Response
Sends a synchronous request to convert text to speech.
21 22 23 24 25 |
# File 'lib/deepgram/speak.rb', line 21 def speak(text:, **kwargs) request(:post, **kwargs) do |request| request.body = JSON.generate(text: text) end end |
#speak_async(text:, callback_url:, **kwargs) ⇒ Deepgram::Speak::Response
Sends an asynchronous request to convert text to speech, with the results sent to a specified callback URL.
34 35 36 37 38 |
# File 'lib/deepgram/speak.rb', line 34 def speak_async(text:, callback_url:, **kwargs) request(:post, callback_url: callback_url, **kwargs) do |request| request.body = JSON.generate(text: text) end end |