Class: AzureSTT::Session
- Inherits:
-
Object
- Object
- AzureSTT::Session
- Defined in:
- lib/azure_stt/session.rb
Overview
A session is the class the end user uses to retrieve the Transcription. It contains a client.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create_transcription(content_urls:, properties:, locale:, display_name:) ⇒ Models::Transcription
Create a transcription by calling the API.
-
#get_transcription(id) ⇒ Models::Transcription
Get a transcription identified by an id.
-
#get_transcriptions(skip: nil, top: nil) ⇒ Array[Models::Transcription]
Get multiple transcriptions.
-
#initialize(region: AzureSTT.configuration.region, subscription_key: AzureSTT.configuration.subscription_key) ⇒ Session
constructor
Create a session.
Constructor Details
#initialize(region: AzureSTT.configuration.region, subscription_key: AzureSTT.configuration.subscription_key) ⇒ Session
Create a session. If you don't provide any subscription_key or region, the value is read from configuration.
configuration read from configuration
20 21 22 23 |
# File 'lib/azure_stt/session.rb', line 20 def initialize(region: AzureSTT.configuration.region, subscription_key: AzureSTT.configuration.subscription_key) @client = Client.new(region: region, subscription_key: subscription_key) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/azure_stt/session.rb', line 9 def client @client end |
Instance Method Details
#create_transcription(content_urls:, properties:, locale:, display_name:) ⇒ Models::Transcription
Create a transcription by calling the API.
transcription left empty)
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/azure_stt/session.rb', line 39 def create_transcription(content_urls:, properties:, locale:, display_name:) transcription_hash = client.create_transcription( { contentUrls: content_urls, properties: properties, locale: locale, displayName: display_name } ) build_transcription_from_hash(transcription_hash) end |
#get_transcription(id) ⇒ Models::Transcription
Get a transcription identified by an id.
60 61 62 63 |
# File 'lib/azure_stt/session.rb', line 60 def get_transcription(id) transcription_hash = client.get_transcription(id) build_transcription_from_hash(transcription_hash) end |
#get_transcriptions(skip: nil, top: nil) ⇒ Array[Models::Transcription]
Get multiple transcriptions.
(optional)
76 77 78 79 80 81 |
# File 'lib/azure_stt/session.rb', line 76 def get_transcriptions(skip: nil, top: nil) transcriptions_array = client.get_transcriptions(skip: skip, top: top) transcriptions_array.map do |transcription_hash| build_transcription_from_hash(transcription_hash) end end |