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.
-
#delete_transcription(id) ⇒ Boolean
Delete an API transcription with a given ID.
-
#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 |
# 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 |
#delete_transcription(id) ⇒ Boolean
Delete an API transcription with a given ID. The transcription will not exist anymore in the API, therefore you won't be able to retrieve it.
an error else
92 93 94 |
# File 'lib/azure_stt/session.rb', line 92 def delete_transcription(id) client.delete_transcription(id) end |
#get_transcription(id) ⇒ Models::Transcription
Get a transcription identified by an id.
58 59 60 61 |
# File 'lib/azure_stt/session.rb', line 58 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)
74 75 76 77 78 79 |
# File 'lib/azure_stt/session.rb', line 74 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 |