diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 425d0417..3c845267 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -164,6 +164,7 @@ docs/RbmWebViewEnum.md docs/RecordingAvailableCallback.md docs/RecordingCompleteCallback.md docs/RecordingStateEnum.md +docs/RecordingTranscriptionClip.md docs/RecordingTranscriptionMetadata.md docs/RecordingTranscriptions.md docs/RecordingsApi.md @@ -384,6 +385,7 @@ lib/bandwidth-sdk/models/rbm_web_view_enum.rb lib/bandwidth-sdk/models/recording_available_callback.rb lib/bandwidth-sdk/models/recording_complete_callback.rb lib/bandwidth-sdk/models/recording_state_enum.rb +lib/bandwidth-sdk/models/recording_transcription_clip.rb lib/bandwidth-sdk/models/recording_transcription_metadata.rb lib/bandwidth-sdk/models/recording_transcriptions.rb lib/bandwidth-sdk/models/redirect_callback.rb diff --git a/README.md b/README.md index ad7e1e44..a9282b76 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,7 @@ Class | Method | HTTP request | Description - [Bandwidth::RecordingAvailableCallback](docs/RecordingAvailableCallback.md) - [Bandwidth::RecordingCompleteCallback](docs/RecordingCompleteCallback.md) - [Bandwidth::RecordingStateEnum](docs/RecordingStateEnum.md) + - [Bandwidth::RecordingTranscriptionClip](docs/RecordingTranscriptionClip.md) - [Bandwidth::RecordingTranscriptionMetadata](docs/RecordingTranscriptionMetadata.md) - [Bandwidth::RecordingTranscriptions](docs/RecordingTranscriptions.md) - [Bandwidth::RedirectCallback](docs/RedirectCallback.md) diff --git a/bandwidth.yml b/bandwidth.yml index a380e26d..fd39c5cb 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -4354,6 +4354,72 @@ components: type: array items: $ref: '#/components/schemas/transcription' + clips: + type: array + description: >- + A list of individual speech clips with speaker, timing, and + confidence information. + items: + $ref: '#/components/schemas/recordingTranscriptionClip' + example: + transcripts: + - speaker: 0 + text: Hi, is Thursday at two still good for you? Perfect, talk soon. + confidence: 0.96 + - speaker: 1 + text: Yes, that works great. See you then! Sounds good, bye! + confidence: 0.97 + clips: + - speaker: 0 + text: Hi, is Thursday at two still good for you? + confidence: 0.97 + startTimeSeconds: 0.4 + endTimeSeconds: 3.1 + - speaker: 1 + text: Yes, that works great. See you then! + confidence: 0.95 + startTimeSeconds: 3.8 + endTimeSeconds: 6.2 + - speaker: 0 + text: Perfect, talk soon. + confidence: 0.94 + startTimeSeconds: 6.9 + endTimeSeconds: 8.1 + - speaker: 1 + text: Sounds good, bye! + confidence: 0.98 + startTimeSeconds: 8.5 + endTimeSeconds: 9.7 + recordingTranscriptionClip: + type: object + properties: + speaker: + type: integer + description: Zero-based index identifying the speaker. + example: 0 + text: + type: string + description: The transcribed text of this clip. + example: Hi there, thanks for calling! + confidence: + type: number + format: double + minimum: 0 + maximum: 1 + description: >- + How confident the transcription engine was in transcribing this clip + (from `0.0` to `1.0`). + example: 0.85 + startTimeSeconds: + type: number + format: double + description: The start time of this clip within the recording, in seconds. + example: 2.3 + endTimeSeconds: + type: number + format: double + description: The end time of this clip within the recording, in seconds. + example: 3.1 callTranscriptionMetadataList: type: array items: @@ -5480,6 +5546,10 @@ components: transcription: type: object properties: + speaker: + type: integer + description: Zero-based index identifying the speaker. + example: 0 text: type: string description: The transcribed text diff --git a/docs/RbmActionBase.md b/docs/RbmActionBase.md index aa1ab41a..3a80e931 100644 --- a/docs/RbmActionBase.md +++ b/docs/RbmActionBase.md @@ -16,7 +16,7 @@ require 'bandwidth-sdk' instance = Bandwidth::RbmActionBase.new( type: null, text: Hello world, - postback_data: [B@20706e70 + postback_data: [B@3c29f6be ) ``` diff --git a/docs/RbmSuggestionResponse.md b/docs/RbmSuggestionResponse.md index 5df0ccb8..17ef49f6 100644 --- a/docs/RbmSuggestionResponse.md +++ b/docs/RbmSuggestionResponse.md @@ -15,7 +15,7 @@ require 'bandwidth-sdk' instance = Bandwidth::RbmSuggestionResponse.new( text: Yes, I would like to proceed, - postback_data: [B@20706e70, + postback_data: [B@3c29f6be, paired_message_id: 1752697342534u24xerqdukke523x ) ``` diff --git a/docs/RecordingTranscriptionClip.md b/docs/RecordingTranscriptionClip.md new file mode 100644 index 00000000..67b43f44 --- /dev/null +++ b/docs/RecordingTranscriptionClip.md @@ -0,0 +1,26 @@ +# Bandwidth::RecordingTranscriptionClip + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **speaker** | **Integer** | Zero-based index identifying the speaker. | [optional] | +| **text** | **String** | The transcribed text of this clip. | [optional] | +| **confidence** | **Float** | How confident the transcription engine was in transcribing this clip (from `0.0` to `1.0`). | [optional] | +| **start_time_seconds** | **Float** | The start time of this clip within the recording, in seconds. | [optional] | +| **end_time_seconds** | **Float** | The end time of this clip within the recording, in seconds. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::RecordingTranscriptionClip.new( + speaker: 0, + text: Hi there, thanks for calling!, + confidence: 0.85, + start_time_seconds: 2.3, + end_time_seconds: 3.1 +) +``` + diff --git a/docs/RecordingTranscriptions.md b/docs/RecordingTranscriptions.md index edca56c9..dc0f8dad 100644 --- a/docs/RecordingTranscriptions.md +++ b/docs/RecordingTranscriptions.md @@ -5,6 +5,7 @@ | Name | Type | Description | Notes | | ---- | ---- | ----------- | ----- | | **transcripts** | [**Array<Transcription>**](Transcription.md) | | [optional] | +| **clips** | [**Array<RecordingTranscriptionClip>**](RecordingTranscriptionClip.md) | A list of individual speech clips with speaker, timing, and confidence information. | [optional] | ## Example @@ -12,7 +13,8 @@ require 'bandwidth-sdk' instance = Bandwidth::RecordingTranscriptions.new( - transcripts: null + transcripts: null, + clips: null ) ``` diff --git a/docs/Transcription.md b/docs/Transcription.md index 7caa4d2a..67d126d2 100644 --- a/docs/Transcription.md +++ b/docs/Transcription.md @@ -4,6 +4,7 @@ | Name | Type | Description | Notes | | ---- | ---- | ----------- | ----- | +| **speaker** | **Integer** | Zero-based index identifying the speaker. | [optional] | | **text** | **String** | The transcribed text | [optional] | | **confidence** | **Float** | The confidence on the recognized content, ranging from `0.0` to `1.0` with `1.0` being the highest confidence. | [optional] | @@ -13,6 +14,7 @@ require 'bandwidth-sdk' instance = Bandwidth::Transcription.new( + speaker: 0, text: Nice talking to you, friend!, confidence: 0.9 ) diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb index a15c309c..c0d0adcb 100644 --- a/lib/bandwidth-sdk.rb +++ b/lib/bandwidth-sdk.rb @@ -170,6 +170,7 @@ require 'bandwidth-sdk/models/recording_available_callback' require 'bandwidth-sdk/models/recording_complete_callback' require 'bandwidth-sdk/models/recording_state_enum' +require 'bandwidth-sdk/models/recording_transcription_clip' require 'bandwidth-sdk/models/recording_transcription_metadata' require 'bandwidth-sdk/models/recording_transcriptions' require 'bandwidth-sdk/models/redirect_callback' diff --git a/lib/bandwidth-sdk/models/recording_transcription_clip.rb b/lib/bandwidth-sdk/models/recording_transcription_clip.rb new file mode 100644 index 00000000..b4fd0a2c --- /dev/null +++ b/lib/bandwidth-sdk/models/recording_transcription_clip.rb @@ -0,0 +1,214 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +Generator version: 7.17.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class RecordingTranscriptionClip < ApiModelBase + # Zero-based index identifying the speaker. + attr_accessor :speaker + + # The transcribed text of this clip. + attr_accessor :text + + # How confident the transcription engine was in transcribing this clip (from `0.0` to `1.0`). + attr_accessor :confidence + + # The start time of this clip within the recording, in seconds. + attr_accessor :start_time_seconds + + # The end time of this clip within the recording, in seconds. + attr_accessor :end_time_seconds + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'speaker' => :'speaker', + :'text' => :'text', + :'confidence' => :'confidence', + :'start_time_seconds' => :'startTimeSeconds', + :'end_time_seconds' => :'endTimeSeconds' + } + end + + # Returns attribute mapping this model knows about + def self.acceptable_attribute_map + attribute_map + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + acceptable_attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'speaker' => :'Integer', + :'text' => :'String', + :'confidence' => :'Float', + :'start_time_seconds' => :'Float', + :'end_time_seconds' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RecordingTranscriptionClip` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + acceptable_attribute_map = self.class.acceptable_attribute_map + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!acceptable_attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RecordingTranscriptionClip`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'speaker') + self.speaker = attributes[:'speaker'] + end + + if attributes.key?(:'text') + self.text = attributes[:'text'] + end + + if attributes.key?(:'confidence') + self.confidence = attributes[:'confidence'] + end + + if attributes.key?(:'start_time_seconds') + self.start_time_seconds = attributes[:'start_time_seconds'] + end + + if attributes.key?(:'end_time_seconds') + self.end_time_seconds = attributes[:'end_time_seconds'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@confidence.nil? && @confidence > 1 + invalid_properties.push('invalid value for "confidence", must be smaller than or equal to 1.') + end + + if !@confidence.nil? && @confidence < 0 + invalid_properties.push('invalid value for "confidence", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@confidence.nil? && @confidence > 1 + return false if !@confidence.nil? && @confidence < 0 + true + end + + # Custom attribute writer method with validation + # @param [Object] confidence Value to be assigned + def confidence=(confidence) + if confidence.nil? + fail ArgumentError, 'confidence cannot be nil' + end + + if confidence > 1 + fail ArgumentError, 'invalid value for "confidence", must be smaller than or equal to 1.' + end + + if confidence < 0 + fail ArgumentError, 'invalid value for "confidence", must be greater than or equal to 0.' + end + + @confidence = confidence + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + speaker == o.speaker && + text == o.text && + confidence == o.confidence && + start_time_seconds == o.start_time_seconds && + end_time_seconds == o.end_time_seconds + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [speaker, text, confidence, start_time_seconds, end_time_seconds].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + end +end diff --git a/lib/bandwidth-sdk/models/recording_transcriptions.rb b/lib/bandwidth-sdk/models/recording_transcriptions.rb index c82633a5..a3ef828b 100644 --- a/lib/bandwidth-sdk/models/recording_transcriptions.rb +++ b/lib/bandwidth-sdk/models/recording_transcriptions.rb @@ -17,10 +17,14 @@ module Bandwidth class RecordingTranscriptions < ApiModelBase attr_accessor :transcripts + # A list of individual speech clips with speaker, timing, and confidence information. + attr_accessor :clips + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'transcripts' => :'transcripts' + :'transcripts' => :'transcripts', + :'clips' => :'clips' } end @@ -37,7 +41,8 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'transcripts' => :'Array' + :'transcripts' => :'Array', + :'clips' => :'Array' } end @@ -68,6 +73,12 @@ def initialize(attributes = {}) self.transcripts = value end end + + if attributes.key?(:'clips') + if (value = attributes[:'clips']).is_a?(Array) + self.clips = value + end + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -90,7 +101,8 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && - transcripts == o.transcripts + transcripts == o.transcripts && + clips == o.clips end # @see the `==` method @@ -102,7 +114,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [transcripts].hash + [transcripts, clips].hash end # Builds the object from hash diff --git a/lib/bandwidth-sdk/models/transcription.rb b/lib/bandwidth-sdk/models/transcription.rb index 3b1008dd..f304a833 100644 --- a/lib/bandwidth-sdk/models/transcription.rb +++ b/lib/bandwidth-sdk/models/transcription.rb @@ -15,6 +15,9 @@ module Bandwidth class Transcription < ApiModelBase + # Zero-based index identifying the speaker. + attr_accessor :speaker + # The transcribed text attr_accessor :text @@ -24,6 +27,7 @@ class Transcription < ApiModelBase # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'speaker' => :'speaker', :'text' => :'text', :'confidence' => :'confidence' } @@ -42,6 +46,7 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { + :'speaker' => :'Integer', :'text' => :'String', :'confidence' => :'Float' } @@ -69,6 +74,10 @@ def initialize(attributes = {}) h[k.to_sym] = v } + if attributes.key?(:'speaker') + self.speaker = attributes[:'speaker'] + end + if attributes.key?(:'text') self.text = attributes[:'text'] end @@ -98,6 +107,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + speaker == o.speaker && text == o.text && confidence == o.confidence end @@ -111,7 +121,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [text, confidence].hash + [speaker, text, confidence].hash end # Builds the object from hash diff --git a/spec/unit/api/recordings_api_spec.rb b/spec/unit/api/recordings_api_spec.rb index a0719bf9..aeb68e85 100644 --- a/spec/unit/api/recordings_api_spec.rb +++ b/spec/unit/api/recordings_api_spec.rb @@ -191,6 +191,7 @@ expect(data).to be_instance_of(Bandwidth::RecordingTranscriptions) expect(data.transcripts).to be_instance_of(Array) expect(data.transcripts[0]).to be_instance_of(Bandwidth::Transcription) + expect(data.transcripts[0].speaker).to be_instance_of(Integer) expect(data.transcripts[0].text).to be_instance_of(String) expect(data.transcripts[0].confidence).to be_instance_of(Float) end diff --git a/spec/unit/models/recording_transcription_clip_spec.rb b/spec/unit/models/recording_transcription_clip_spec.rb new file mode 100644 index 00000000..f572c8b7 --- /dev/null +++ b/spec/unit/models/recording_transcription_clip_spec.rb @@ -0,0 +1,96 @@ +# Unit tests for Bandwidth::RecordingTranscriptionClip +describe Bandwidth::RecordingTranscriptionClip do + let(:recording_transcription_clip_default) { Bandwidth::RecordingTranscriptionClip.new } + let(:recording_transcription_clip_values) { Bandwidth::RecordingTranscriptionClip.new({ + speaker: 0, + text: 'Hello world', + confidence: 0.9, + start_time_seconds: 1.5, + end_time_seconds: 3.2 + }) } + + describe '#initialize' do + it 'causes an ArgumentError by passing an Array to the initialize method' do + expect { + Bandwidth::RecordingTranscriptionClip.new([]) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do + expect { + Bandwidth::RecordingTranscriptionClip.new({ invalid: true }) + }.to raise_error(ArgumentError) + end + end + + describe '#acceptable_attributes' do + it 'expects acceptable JSON attributes to be those in the attribute map' do + expect(Bandwidth::RecordingTranscriptionClip.acceptable_attributes).to eq(Bandwidth::RecordingTranscriptionClip.attribute_map.values) + end + end + + describe '#openapi_nullable' do + it 'expects nullable attributes to be an empty set' do + expect(Bandwidth::RecordingTranscriptionClip.openapi_nullable).to eq(Set.new([])) + end + end + + describe '#build_from_hash' do + it 'validates instance of RecordingTranscriptionClip created by the build_from_hash method' do + recording_transcription_clip_from_hash = Bandwidth::RecordingTranscriptionClip.build_from_hash({ + speaker: 0, + text: 'Hello world', + confidence: 0.9, + startTimeSeconds: 1.5, + endTimeSeconds: 3.2 + }) + expect(recording_transcription_clip_from_hash).to be_instance_of(Bandwidth::RecordingTranscriptionClip) + expect(recording_transcription_clip_from_hash.speaker).to eq(0) + expect(recording_transcription_clip_from_hash.text).to eq('Hello world') + expect(recording_transcription_clip_from_hash.confidence).to eq(0.9) + expect(recording_transcription_clip_from_hash.start_time_seconds).to eq(1.5) + expect(recording_transcription_clip_from_hash.end_time_seconds).to eq(3.2) + end + end + + describe '#to_s' do + it 'returns a string representation of the object' do + expect(recording_transcription_clip_values.to_s).to eq('{:speaker=>0, :text=>"Hello world", :confidence=>0.9, :startTimeSeconds=>1.5, :endTimeSeconds=>3.2}') + end + end + + describe '#eq? #==' do + it 'returns true/false when comparing objects' do + expect(recording_transcription_clip_default.eql?(Bandwidth::RecordingTranscriptionClip.new)).to be true + expect(recording_transcription_clip_default.eql?(recording_transcription_clip_values)).to be false + end + end + + describe '#to_body #to_hash' do + it 'returns a hash representation of the object' do + expect(recording_transcription_clip_values.to_body).to eq({ + speaker: 0, + text: 'Hello world', + confidence: 0.9, + startTimeSeconds: 1.5, + endTimeSeconds: 3.2 + }) + end + end + + describe 'custom attribute writers' do + it '#confidence=' do + expect { + Bandwidth::RecordingTranscriptionClip.new({ confidence: nil }) + }.to raise_error(ArgumentError, 'confidence cannot be nil') + + expect { + Bandwidth::RecordingTranscriptionClip.new({ confidence: 1.5 }) + }.to raise_error(ArgumentError, 'invalid value for "confidence", must be smaller than or equal to 1.') + + expect { + Bandwidth::RecordingTranscriptionClip.new({ confidence: -0.5 }) + }.to raise_error(ArgumentError, 'invalid value for "confidence", must be greater than or equal to 0.') + end + end +end diff --git a/spec/unit/models/recording_transcriptions_spec.rb b/spec/unit/models/recording_transcriptions_spec.rb index a4d403ca..043c209e 100644 --- a/spec/unit/models/recording_transcriptions_spec.rb +++ b/spec/unit/models/recording_transcriptions_spec.rb @@ -3,7 +3,20 @@ let(:recording_transcriptions_default) { Bandwidth::RecordingTranscriptions.new } let(:recording_transcriptions_values) { Bandwidth::RecordingTranscriptions.new({ transcripts: [ - Bandwidth::Transcription.new({ text: 'Hello World! Thank you for calling.', confidence: 0.9 }) + Bandwidth::Transcription.new({ + speaker: 1, + text: 'Hello World! Thank you for calling.', + confidence: 0.9 + }) + ], + clips: [ + Bandwidth::RecordingTranscriptionClip.new({ + speaker: 1, + text: 'Hello World! Thank you for calling.', + confidence: 0.9, + start_time_seconds: 1.0, + end_time_seconds: 5.0 + }) ] }) } @@ -36,19 +49,28 @@ describe '#build_from_hash' do it 'validates instance of RecordingTranscriptions created by the build_from_hash method' do recording_transcriptions_from_hash = Bandwidth::RecordingTranscriptions.build_from_hash({ - transcripts: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9 }] + transcripts: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9, speaker: 1 }], + clips: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9, speaker: 1, startTimeSeconds: 1.0, endTimeSeconds: 5.0 }] }) expect(recording_transcriptions_from_hash).to be_instance_of(Bandwidth::RecordingTranscriptions) expect(recording_transcriptions_from_hash.transcripts).to be_instance_of(Array) expect(recording_transcriptions_from_hash.transcripts.first).to be_instance_of(Bandwidth::Transcription) + expect(recording_transcriptions_from_hash.transcripts.first.speaker).to eq(1) expect(recording_transcriptions_from_hash.transcripts.first.text).to eq('Hello World! Thank you for calling.') expect(recording_transcriptions_from_hash.transcripts.first.confidence).to eq(0.9) + expect(recording_transcriptions_from_hash.clips).to be_instance_of(Array) + expect(recording_transcriptions_from_hash.clips.first).to be_instance_of(Bandwidth::RecordingTranscriptionClip) + expect(recording_transcriptions_from_hash.clips.first.speaker).to eq(1) + expect(recording_transcriptions_from_hash.clips.first.text).to eq('Hello World! Thank you for calling.') + expect(recording_transcriptions_from_hash.clips.first.confidence).to eq(0.9) + expect(recording_transcriptions_from_hash.clips.first.start_time_seconds).to eq(1.0) + expect(recording_transcriptions_from_hash.clips.first.end_time_seconds).to eq(5.0) end end describe '#to_s' do it 'returns a string representation of the object' do - expect(recording_transcriptions_values.to_s).to eq('{:transcripts=>[{:text=>"Hello World! Thank you for calling.", :confidence=>0.9}]}') + expect(recording_transcriptions_values.to_s).to eq('{:transcripts=>[{:speaker=>1, :text=>"Hello World! Thank you for calling.", :confidence=>0.9}], :clips=>[{:speaker=>1, :text=>"Hello World! Thank you for calling.", :confidence=>0.9, :startTimeSeconds=>1.0, :endTimeSeconds=>5.0}]}') end end @@ -62,7 +84,8 @@ describe '#to_body #to_hash' do it 'returns a hash representation of the object' do expect(recording_transcriptions_values.to_body).to eq({ - transcripts: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9 }] + transcripts: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9, speaker: 1 }], + clips: [{ text: 'Hello World! Thank you for calling.', confidence: 0.9, speaker: 1, startTimeSeconds: 1.0, endTimeSeconds: 5.0 }] }) end end diff --git a/spec/unit/models/transcription_spec.rb b/spec/unit/models/transcription_spec.rb index 02a15f23..78d52fff 100644 --- a/spec/unit/models/transcription_spec.rb +++ b/spec/unit/models/transcription_spec.rb @@ -2,6 +2,7 @@ describe Bandwidth::Transcription do let(:transcription_default) { Bandwidth::Transcription.new } let(:transcription_values) { Bandwidth::Transcription.new({ + speaker: 1, text: 'Hello World! Thank you for calling.', confidence: 0.9 }) } @@ -35,10 +36,12 @@ describe '#build_from_hash' do it 'validates instance of Transcription created by the build_from_hash method' do transcription_from_hash = Bandwidth::Transcription.build_from_hash({ + speaker: 1, text: 'Hello World! Thank you for calling.', confidence: 0.9 }) expect(transcription_from_hash).to be_instance_of(Bandwidth::Transcription) + expect(transcription_from_hash.speaker).to eq(1) expect(transcription_from_hash.text).to eq('Hello World! Thank you for calling.') expect(transcription_from_hash.confidence).to eq(0.9) end @@ -46,7 +49,7 @@ describe '#to_s' do it 'returns a string representation of the object' do - expect(transcription_values.to_s).to eq('{:text=>"Hello World! Thank you for calling.", :confidence=>0.9}') + expect(transcription_values.to_s).to eq('{:speaker=>1, :text=>"Hello World! Thank you for calling.", :confidence=>0.9}') end end @@ -60,6 +63,7 @@ describe '#to_body #to_hash' do it 'returns a hash representation of the object' do expect(transcription_values.to_body).to eq({ + speaker: 1, text: 'Hello World! Thank you for calling.', confidence: 0.9 })