Class: AzureSTT::Session

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

Parameters:

  • region (String) (defaults to: AzureSTT.configuration.region)

    The region, optional, default is read from

  • subscription_key (String) (defaults to: AzureSTT.configuration.subscription_key)

    The subscription, optional, default is



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

#clientObject (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)

Parameters:

  • content_urls (Array[String])

    The urls of your files

  • properties (Hash)

    The properties you want to use for the

  • locale (String)

    The locale of the contained data

  • display_name (String)

    The name of the transcription (can be

Returns:

See Also:



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

Parameters:

  • id (String)

    The id of the transcription in the API

Returns:

  • (Boolean)

    true if the transcription had been deleted, raises

See Also:



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.

Parameters:

  • id (String)

    The identifier of the transcription

Returns:

See Also:



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)

Parameters:

  • skip (Integer) (defaults to: nil)

    Number of transcriptions that will be skipped (optional)

  • top (Integer) (defaults to: nil)

    Number of transcriptions that will be included after skipping

Returns:

See Also:



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