assemblyai 1.0.0.pre.beta.6 → 1.0.0.pre.beta.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assemblyai/files/client.rb +4 -2
  3. data/lib/assemblyai/files/types/uploaded_file.rb +20 -11
  4. data/lib/assemblyai/lemur/client.rb +256 -150
  5. data/lib/assemblyai/lemur/types/lemur_action_items_response.rb +28 -14
  6. data/lib/assemblyai/lemur/types/lemur_base_params.rb +83 -54
  7. data/lib/assemblyai/lemur/types/lemur_base_params_context.rb +11 -5
  8. data/lib/assemblyai/lemur/types/lemur_base_response.rb +20 -11
  9. data/lib/assemblyai/lemur/types/lemur_question.rb +57 -31
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -14
  12. data/lib/assemblyai/lemur/types/lemur_question_context.rb +13 -6
  13. data/lib/assemblyai/lemur/types/lemur_summary_response.rb +28 -14
  14. data/lib/assemblyai/lemur/types/lemur_task_response.rb +28 -14
  15. data/lib/assemblyai/lemur/types/purge_lemur_request_data_response.rb +32 -17
  16. data/lib/assemblyai/realtime/client.rb +32 -16
  17. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
  18. data/lib/assemblyai/realtime/types/final_transcript.rb +72 -41
  19. data/lib/assemblyai/realtime/types/force_end_utterance.rb +20 -11
  20. data/lib/assemblyai/realtime/types/message_type.rb +1 -0
  21. data/lib/assemblyai/realtime/types/partial_transcript.rb +62 -34
  22. data/lib/assemblyai/realtime/types/realtime_base_message.rb +22 -13
  23. data/lib/assemblyai/realtime/types/realtime_base_transcript.rb +57 -31
  24. data/lib/assemblyai/realtime/types/realtime_error.rb +20 -11
  25. data/lib/assemblyai/realtime/types/realtime_message.rb +44 -18
  26. data/lib/assemblyai/realtime/types/realtime_temporary_token_response.rb +21 -12
  27. data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
  28. data/lib/assemblyai/realtime/types/session_begins.rb +31 -14
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +20 -11
  31. data/lib/assemblyai/realtime/types/terminate_session.rb +21 -12
  32. data/lib/assemblyai/realtime/types/word.rb +36 -18
  33. data/lib/assemblyai/streaming/types/receive_message.rb +113 -0
  34. data/lib/assemblyai/streaming/types/send_message.rb +86 -0
  35. data/lib/assemblyai/streaming/types/streaming.rb +11 -0
  36. data/lib/assemblyai/transcripts/client.rb +54 -20
  37. data/lib/assemblyai/transcripts/list_by_url_client.rb +6 -4
  38. data/lib/assemblyai/transcripts/polling_client.rb +12 -2
  39. data/lib/assemblyai/transcripts/types/auto_highlight_result.rb +40 -19
  40. data/lib/assemblyai/transcripts/types/auto_highlights_result.rb +38 -14
  41. data/lib/assemblyai/transcripts/types/chapter.rb +40 -20
  42. data/lib/assemblyai/transcripts/types/content_safety_label.rb +32 -16
  43. data/lib/assemblyai/transcripts/types/content_safety_label_result.rb +51 -29
  44. data/lib/assemblyai/transcripts/types/content_safety_labels_result.rb +51 -29
  45. data/lib/assemblyai/transcripts/types/entity.rb +41 -21
  46. data/lib/assemblyai/transcripts/types/page_details.rb +60 -33
  47. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  48. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  49. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  50. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  51. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +62 -35
  52. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  53. data/lib/assemblyai/transcripts/types/speech_model.rb +2 -0
  54. data/lib/assemblyai/transcripts/types/substitution_policy.rb +4 -2
  55. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  56. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -19
  57. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  58. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  59. data/lib/assemblyai/transcripts/types/transcript.rb +512 -293
  60. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  61. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +3 -2
  62. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -16
  63. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +63 -30
  64. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +334 -191
  65. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -33
  66. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  67. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -33
  68. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  69. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -31
  70. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  71. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  72. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  73. data/lib/assemblyai/types/error.rb +32 -16
  74. data/lib/requests.rb +80 -34
  75. data/lib/types_export.rb +9 -8
  76. metadata +6 -5
  77. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  78. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
  79. data/lib/assemblyai/realtime/types/send_message.rb +0 -74
@@ -1,64 +1,91 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Transcripts
8
+ # Details of the transcript page. Transcripts are sorted from newest to oldest.
9
+ # The previous URL always points to a page with older transcripts.
7
10
  class PageDetails
8
- attr_reader :limit, :result_count, :current_url, :prev_url, :next_url, :additional_properties
11
+ # @return [Integer]
12
+ attr_reader :limit
13
+ # @return [Integer]
14
+ attr_reader :result_count
15
+ # @return [String]
16
+ attr_reader :current_url
17
+ # @return [String] The URL to the next page of transcripts. The previous URL always points to a
18
+ # page with older transcripts.
19
+ attr_reader :prev_url
20
+ # @return [String] The URL to the next page of transcripts. The next URL always points to a page
21
+ # with newer transcripts.
22
+ attr_reader :next_url
23
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
24
+ attr_reader :additional_properties
25
+ # @return [Object]
26
+ attr_reader :_field_set
27
+ protected :_field_set
28
+
29
+ OMIT = Object.new
9
30
 
10
31
  # @param limit [Integer]
11
32
  # @param result_count [Integer]
12
33
  # @param current_url [String]
13
- # @param prev_url [String]
14
- # @param next_url [String]
34
+ # @param prev_url [String] The URL to the next page of transcripts. The previous URL always points to a
35
+ # page with older transcripts.
36
+ # @param next_url [String] The URL to the next page of transcripts. The next URL always points to a page
37
+ # with newer transcripts.
15
38
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Transcripts::PageDetails]
17
- def initialize(limit:, result_count:, current_url:, prev_url:, next_url: nil, additional_properties: nil)
18
- # @type [Integer]
39
+ # @return [AssemblyAI::Transcripts::PageDetails]
40
+ def initialize(limit:, result_count:, current_url:, prev_url: OMIT, next_url: OMIT, additional_properties: nil)
19
41
  @limit = limit
20
- # @type [Integer]
21
42
  @result_count = result_count
22
- # @type [String]
23
43
  @current_url = current_url
24
- # @type [String]
25
- @prev_url = prev_url
26
- # @type [String]
27
- @next_url = next_url
28
- # @type [OpenStruct] Additional properties unmapped to the current class definition
44
+ @prev_url = prev_url if prev_url != OMIT
45
+ @next_url = next_url if next_url != OMIT
29
46
  @additional_properties = additional_properties
47
+ @_field_set = {
48
+ "limit": limit,
49
+ "result_count": result_count,
50
+ "current_url": current_url,
51
+ "prev_url": prev_url,
52
+ "next_url": next_url
53
+ }.reject do |_k, v|
54
+ v == OMIT
55
+ end
30
56
  end
31
57
 
32
58
  # Deserialize a JSON object to an instance of PageDetails
33
59
  #
34
- # @param json_object [JSON]
35
- # @return [Transcripts::PageDetails]
60
+ # @param json_object [String]
61
+ # @return [AssemblyAI::Transcripts::PageDetails]
36
62
  def self.from_json(json_object:)
37
63
  struct = JSON.parse(json_object, object_class: OpenStruct)
38
- JSON.parse(json_object)
39
- limit = struct.limit
40
- result_count = struct.result_count
41
- current_url = struct.current_url
42
- prev_url = struct.prev_url
43
- next_url = struct.next_url
44
- new(limit: limit, result_count: result_count, current_url: current_url, prev_url: prev_url, next_url: next_url,
45
- additional_properties: struct)
64
+ limit = struct["limit"]
65
+ result_count = struct["result_count"]
66
+ current_url = struct["current_url"]
67
+ prev_url = struct["prev_url"]
68
+ next_url = struct["next_url"]
69
+ new(
70
+ limit: limit,
71
+ result_count: result_count,
72
+ current_url: current_url,
73
+ prev_url: prev_url,
74
+ next_url: next_url,
75
+ additional_properties: struct
76
+ )
46
77
  end
47
78
 
48
79
  # Serialize an instance of PageDetails to a JSON object
49
80
  #
50
- # @return [JSON]
81
+ # @return [String]
51
82
  def to_json(*_args)
52
- {
53
- "limit": @limit,
54
- "result_count": @result_count,
55
- "current_url": @current_url,
56
- "prev_url": @prev_url,
57
- "next_url": @next_url
58
- }.to_json
83
+ @_field_set&.to_json
59
84
  end
60
85
 
61
- # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
86
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
87
+ # hash and check each fields type against the current object's property
88
+ # definitions.
62
89
  #
63
90
  # @param obj [Object]
64
91
  # @return [Void]
@@ -66,7 +93,7 @@ module AssemblyAI
66
93
  obj.limit.is_a?(Integer) != false || raise("Passed value for field obj.limit is not the expected type, validation failed.")
67
94
  obj.result_count.is_a?(Integer) != false || raise("Passed value for field obj.result_count is not the expected type, validation failed.")
68
95
  obj.current_url.is_a?(String) != false || raise("Passed value for field obj.current_url is not the expected type, validation failed.")
69
- obj.prev_url.is_a?(String) != false || raise("Passed value for field obj.prev_url is not the expected type, validation failed.")
96
+ obj.prev_url&.is_a?(String) != false || raise("Passed value for field obj.prev_url is not the expected type, validation failed.")
70
97
  obj.next_url&.is_a?(String) != false || raise("Passed value for field obj.next_url is not the expected type, validation failed.")
71
98
  end
72
99
  end
@@ -1,58 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "transcript_paragraph"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  class ParagraphsResponse
9
- attr_reader :id, :confidence, :audio_duration, :paragraphs, :additional_properties
10
+ # @return [String]
11
+ attr_reader :id
12
+ # @return [Float]
13
+ attr_reader :confidence
14
+ # @return [Float]
15
+ attr_reader :audio_duration
16
+ # @return [Array<AssemblyAI::Transcripts::TranscriptParagraph>]
17
+ attr_reader :paragraphs
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
10
25
 
11
26
  # @param id [String]
12
27
  # @param confidence [Float]
13
28
  # @param audio_duration [Float]
14
- # @param paragraphs [Array<Transcripts::TranscriptParagraph>]
29
+ # @param paragraphs [Array<AssemblyAI::Transcripts::TranscriptParagraph>]
15
30
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Transcripts::ParagraphsResponse]
31
+ # @return [AssemblyAI::Transcripts::ParagraphsResponse]
17
32
  def initialize(id:, confidence:, audio_duration:, paragraphs:, additional_properties: nil)
18
- # @type [String]
19
33
  @id = id
20
- # @type [Float]
21
34
  @confidence = confidence
22
- # @type [Float]
23
35
  @audio_duration = audio_duration
24
- # @type [Array<Transcripts::TranscriptParagraph>]
25
36
  @paragraphs = paragraphs
26
- # @type [OpenStruct] Additional properties unmapped to the current class definition
27
37
  @additional_properties = additional_properties
38
+ @_field_set = { "id": id, "confidence": confidence, "audio_duration": audio_duration, "paragraphs": paragraphs }
28
39
  end
29
40
 
30
41
  # Deserialize a JSON object to an instance of ParagraphsResponse
31
42
  #
32
- # @param json_object [JSON]
33
- # @return [Transcripts::ParagraphsResponse]
43
+ # @param json_object [String]
44
+ # @return [AssemblyAI::Transcripts::ParagraphsResponse]
34
45
  def self.from_json(json_object:)
35
46
  struct = JSON.parse(json_object, object_class: OpenStruct)
36
47
  parsed_json = JSON.parse(json_object)
37
- id = struct.id
38
- confidence = struct.confidence
39
- audio_duration = struct.audio_duration
48
+ id = struct["id"]
49
+ confidence = struct["confidence"]
50
+ audio_duration = struct["audio_duration"]
40
51
  paragraphs = parsed_json["paragraphs"]&.map do |v|
41
52
  v = v.to_json
42
- Transcripts::TranscriptParagraph.from_json(json_object: v)
53
+ AssemblyAI::Transcripts::TranscriptParagraph.from_json(json_object: v)
43
54
  end
44
- new(id: id, confidence: confidence, audio_duration: audio_duration, paragraphs: paragraphs,
45
- additional_properties: struct)
55
+ new(
56
+ id: id,
57
+ confidence: confidence,
58
+ audio_duration: audio_duration,
59
+ paragraphs: paragraphs,
60
+ additional_properties: struct
61
+ )
46
62
  end
47
63
 
48
64
  # Serialize an instance of ParagraphsResponse to a JSON object
49
65
  #
50
- # @return [JSON]
66
+ # @return [String]
51
67
  def to_json(*_args)
52
- { "id": @id, "confidence": @confidence, "audio_duration": @audio_duration, "paragraphs": @paragraphs }.to_json
68
+ @_field_set&.to_json
53
69
  end
54
70
 
55
- # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
71
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
72
+ # hash and check each fields type against the current object's property
73
+ # definitions.
56
74
  #
57
75
  # @param obj [Object]
58
76
  # @return [Void]
@@ -2,7 +2,10 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Transcripts
5
- # Controls the filetype of the audio created by redact_pii_audio. Currently supports mp3 (default) and wav. See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
5
+ # Controls the filetype of the audio created by redact_pii_audio. Currently
6
+ # supports mp3 (default) and wav. See [PII
7
+ # redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more
8
+ # details.
6
9
  class RedactPiiAudioQuality
7
10
  MP3 = "mp3"
8
11
  WAV = "wav"
@@ -1,46 +1,60 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "redacted_audio_status"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  class RedactedAudioResponse
9
- attr_reader :status, :redacted_audio_url, :additional_properties
10
+ # @return [AssemblyAI::Transcripts::REDACTED_AUDIO_STATUS] The status of the redacted audio
11
+ attr_reader :status
12
+ # @return [String] The URL of the redacted audio file
13
+ attr_reader :redacted_audio_url
14
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
15
+ attr_reader :additional_properties
16
+ # @return [Object]
17
+ attr_reader :_field_set
18
+ protected :_field_set
10
19
 
11
- # @param status [Transcripts::REDACTED_AUDIO_STATUS] The status of the redacted audio
20
+ OMIT = Object.new
21
+
22
+ # @param status [AssemblyAI::Transcripts::REDACTED_AUDIO_STATUS] The status of the redacted audio
12
23
  # @param redacted_audio_url [String] The URL of the redacted audio file
13
24
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
- # @return [Transcripts::RedactedAudioResponse]
25
+ # @return [AssemblyAI::Transcripts::RedactedAudioResponse]
15
26
  def initialize(status:, redacted_audio_url:, additional_properties: nil)
16
- # @type [Transcripts::REDACTED_AUDIO_STATUS] The status of the redacted audio
17
27
  @status = status
18
- # @type [String] The URL of the redacted audio file
19
28
  @redacted_audio_url = redacted_audio_url
20
- # @type [OpenStruct] Additional properties unmapped to the current class definition
21
29
  @additional_properties = additional_properties
30
+ @_field_set = { "status": status, "redacted_audio_url": redacted_audio_url }
22
31
  end
23
32
 
24
33
  # Deserialize a JSON object to an instance of RedactedAudioResponse
25
34
  #
26
- # @param json_object [JSON]
27
- # @return [Transcripts::RedactedAudioResponse]
35
+ # @param json_object [String]
36
+ # @return [AssemblyAI::Transcripts::RedactedAudioResponse]
28
37
  def self.from_json(json_object:)
29
38
  struct = JSON.parse(json_object, object_class: OpenStruct)
30
- JSON.parse(json_object)
31
- status = struct.status
32
- redacted_audio_url = struct.redacted_audio_url
33
- new(status: status, redacted_audio_url: redacted_audio_url, additional_properties: struct)
39
+ status = struct["status"]
40
+ redacted_audio_url = struct["redacted_audio_url"]
41
+ new(
42
+ status: status,
43
+ redacted_audio_url: redacted_audio_url,
44
+ additional_properties: struct
45
+ )
34
46
  end
35
47
 
36
48
  # Serialize an instance of RedactedAudioResponse to a JSON object
37
49
  #
38
- # @return [JSON]
50
+ # @return [String]
39
51
  def to_json(*_args)
40
- { "status": @status, "redacted_audio_url": @redacted_audio_url }.to_json
52
+ @_field_set&.to_json
41
53
  end
42
54
 
43
- # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
55
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
56
+ # hash and check each fields type against the current object's property
57
+ # definitions.
44
58
  #
45
59
  # @param obj [Object]
46
60
  # @return [Void]
@@ -1,58 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "transcript_sentence"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  class SentencesResponse
9
- attr_reader :id, :confidence, :audio_duration, :sentences, :additional_properties
10
+ # @return [String]
11
+ attr_reader :id
12
+ # @return [Float]
13
+ attr_reader :confidence
14
+ # @return [Float]
15
+ attr_reader :audio_duration
16
+ # @return [Array<AssemblyAI::Transcripts::TranscriptSentence>]
17
+ attr_reader :sentences
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
10
25
 
11
26
  # @param id [String]
12
27
  # @param confidence [Float]
13
28
  # @param audio_duration [Float]
14
- # @param sentences [Array<Transcripts::TranscriptSentence>]
29
+ # @param sentences [Array<AssemblyAI::Transcripts::TranscriptSentence>]
15
30
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Transcripts::SentencesResponse]
31
+ # @return [AssemblyAI::Transcripts::SentencesResponse]
17
32
  def initialize(id:, confidence:, audio_duration:, sentences:, additional_properties: nil)
18
- # @type [String]
19
33
  @id = id
20
- # @type [Float]
21
34
  @confidence = confidence
22
- # @type [Float]
23
35
  @audio_duration = audio_duration
24
- # @type [Array<Transcripts::TranscriptSentence>]
25
36
  @sentences = sentences
26
- # @type [OpenStruct] Additional properties unmapped to the current class definition
27
37
  @additional_properties = additional_properties
38
+ @_field_set = { "id": id, "confidence": confidence, "audio_duration": audio_duration, "sentences": sentences }
28
39
  end
29
40
 
30
41
  # Deserialize a JSON object to an instance of SentencesResponse
31
42
  #
32
- # @param json_object [JSON]
33
- # @return [Transcripts::SentencesResponse]
43
+ # @param json_object [String]
44
+ # @return [AssemblyAI::Transcripts::SentencesResponse]
34
45
  def self.from_json(json_object:)
35
46
  struct = JSON.parse(json_object, object_class: OpenStruct)
36
47
  parsed_json = JSON.parse(json_object)
37
- id = struct.id
38
- confidence = struct.confidence
39
- audio_duration = struct.audio_duration
48
+ id = struct["id"]
49
+ confidence = struct["confidence"]
50
+ audio_duration = struct["audio_duration"]
40
51
  sentences = parsed_json["sentences"]&.map do |v|
41
52
  v = v.to_json
42
- Transcripts::TranscriptSentence.from_json(json_object: v)
53
+ AssemblyAI::Transcripts::TranscriptSentence.from_json(json_object: v)
43
54
  end
44
- new(id: id, confidence: confidence, audio_duration: audio_duration, sentences: sentences,
45
- additional_properties: struct)
55
+ new(
56
+ id: id,
57
+ confidence: confidence,
58
+ audio_duration: audio_duration,
59
+ sentences: sentences,
60
+ additional_properties: struct
61
+ )
46
62
  end
47
63
 
48
64
  # Serialize an instance of SentencesResponse to a JSON object
49
65
  #
50
- # @return [JSON]
66
+ # @return [String]
51
67
  def to_json(*_args)
52
- { "id": @id, "confidence": @confidence, "audio_duration": @audio_duration, "sentences": @sentences }.to_json
68
+ @_field_set&.to_json
53
69
  end
54
70
 
55
- # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
71
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
72
+ # hash and check each fields type against the current object's property
73
+ # definitions.
56
74
  #
57
75
  # @param obj [Object]
58
76
  # @return [Void]
@@ -1,71 +1,98 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "sentiment"
4
+ require "ostruct"
4
5
  require "json"
5
6
 
6
7
  module AssemblyAI
7
8
  class Transcripts
8
9
  # The result of the sentiment analysis model
9
10
  class SentimentAnalysisResult
10
- attr_reader :text, :start, :end_, :sentiment, :confidence, :speaker, :additional_properties
11
+ # @return [String] The transcript of the sentence
12
+ attr_reader :text
13
+ # @return [Integer] The starting time, in milliseconds, of the sentence
14
+ attr_reader :start
15
+ # @return [Integer] The ending time, in milliseconds, of the sentence
16
+ attr_reader :end_
17
+ # @return [AssemblyAI::Transcripts::Sentiment] The detected sentiment for the sentence, one of POSITIVE, NEUTRAL, NEGATIVE
18
+ attr_reader :sentiment
19
+ # @return [Float] The confidence score for the detected sentiment of the sentence, from 0 to 1
20
+ attr_reader :confidence
21
+ # @return [String] The speaker of the sentence if [Speaker
22
+ # Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
23
+ # enabled, else null
24
+ attr_reader :speaker
25
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
26
+ attr_reader :additional_properties
27
+ # @return [Object]
28
+ attr_reader :_field_set
29
+ protected :_field_set
30
+
31
+ OMIT = Object.new
11
32
 
12
33
  # @param text [String] The transcript of the sentence
13
34
  # @param start [Integer] The starting time, in milliseconds, of the sentence
14
35
  # @param end_ [Integer] The ending time, in milliseconds, of the sentence
15
- # @param sentiment [Transcripts::Sentiment] The detected sentiment for the sentence, one of POSITIVE, NEUTRAL, NEGATIVE
36
+ # @param sentiment [AssemblyAI::Transcripts::Sentiment] The detected sentiment for the sentence, one of POSITIVE, NEUTRAL, NEGATIVE
16
37
  # @param confidence [Float] The confidence score for the detected sentiment of the sentence, from 0 to 1
17
- # @param speaker [String] The speaker of the sentence if [Speaker Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is enabled, else null
38
+ # @param speaker [String] The speaker of the sentence if [Speaker
39
+ # Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is
40
+ # enabled, else null
18
41
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
19
- # @return [Transcripts::SentimentAnalysisResult]
20
- def initialize(text:, start:, end_:, sentiment:, confidence:, speaker: nil, additional_properties: nil)
21
- # @type [String] The transcript of the sentence
42
+ # @return [AssemblyAI::Transcripts::SentimentAnalysisResult]
43
+ def initialize(text:, start:, end_:, sentiment:, confidence:, speaker: OMIT, additional_properties: nil)
22
44
  @text = text
23
- # @type [Integer] The starting time, in milliseconds, of the sentence
24
45
  @start = start
25
- # @type [Integer] The ending time, in milliseconds, of the sentence
26
46
  @end_ = end_
27
- # @type [Transcripts::Sentiment] The detected sentiment for the sentence, one of POSITIVE, NEUTRAL, NEGATIVE
28
47
  @sentiment = sentiment
29
- # @type [Float] The confidence score for the detected sentiment of the sentence, from 0 to 1
30
48
  @confidence = confidence
31
- # @type [String] The speaker of the sentence if [Speaker Diarization](https://www.assemblyai.com/docs/models/speaker-diarization) is enabled, else null
32
- @speaker = speaker
33
- # @type [OpenStruct] Additional properties unmapped to the current class definition
49
+ @speaker = speaker if speaker != OMIT
34
50
  @additional_properties = additional_properties
51
+ @_field_set = {
52
+ "text": text,
53
+ "start": start,
54
+ "end": end_,
55
+ "sentiment": sentiment,
56
+ "confidence": confidence,
57
+ "speaker": speaker
58
+ }.reject do |_k, v|
59
+ v == OMIT
60
+ end
35
61
  end
36
62
 
37
63
  # Deserialize a JSON object to an instance of SentimentAnalysisResult
38
64
  #
39
- # @param json_object [JSON]
40
- # @return [Transcripts::SentimentAnalysisResult]
65
+ # @param json_object [String]
66
+ # @return [AssemblyAI::Transcripts::SentimentAnalysisResult]
41
67
  def self.from_json(json_object:)
42
68
  struct = JSON.parse(json_object, object_class: OpenStruct)
43
- JSON.parse(json_object)
44
- text = struct.text
45
- start = struct.start
46
- end_ = struct.end
47
- sentiment = struct.sentiment
48
- confidence = struct.confidence
49
- speaker = struct.speaker
50
- new(text: text, start: start, end_: end_, sentiment: sentiment, confidence: confidence, speaker: speaker,
51
- additional_properties: struct)
69
+ text = struct["text"]
70
+ start = struct["start"]
71
+ end_ = struct["end"]
72
+ sentiment = struct["sentiment"]
73
+ confidence = struct["confidence"]
74
+ speaker = struct["speaker"]
75
+ new(
76
+ text: text,
77
+ start: start,
78
+ end_: end_,
79
+ sentiment: sentiment,
80
+ confidence: confidence,
81
+ speaker: speaker,
82
+ additional_properties: struct
83
+ )
52
84
  end
53
85
 
54
86
  # Serialize an instance of SentimentAnalysisResult to a JSON object
55
87
  #
56
- # @return [JSON]
88
+ # @return [String]
57
89
  def to_json(*_args)
58
- {
59
- "text": @text,
60
- "start": @start,
61
- "end": @end_,
62
- "sentiment": @sentiment,
63
- "confidence": @confidence,
64
- "speaker": @speaker
65
- }.to_json
90
+ @_field_set&.to_json
66
91
  end
67
92
 
68
- # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
93
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
94
+ # hash and check each fields type against the current object's property
95
+ # definitions.
69
96
  #
70
97
  # @param obj [Object]
71
98
  # @return [Void]
@@ -73,7 +100,7 @@ module AssemblyAI
73
100
  obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
74
101
  obj.start.is_a?(Integer) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
75
102
  obj.end_.is_a?(Integer) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
76
- obj.sentiment.is_a?(Transcripts::Sentiment) != false || raise("Passed value for field obj.sentiment is not the expected type, validation failed.")
103
+ obj.sentiment.is_a?(AssemblyAI::Transcripts::Sentiment) != false || raise("Passed value for field obj.sentiment is not the expected type, validation failed.")
77
104
  obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
78
105
  obj.speaker&.is_a?(String) != false || raise("Passed value for field obj.speaker is not the expected type, validation failed.")
79
106
  end
@@ -1,49 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
3
4
  require "json"
4
5
 
5
6
  module AssemblyAI
6
7
  class Transcripts
7
8
  class SeverityScoreSummary
8
- attr_reader :low, :medium, :high, :additional_properties
9
+ # @return [Float]
10
+ attr_reader :low
11
+ # @return [Float]
12
+ attr_reader :medium
13
+ # @return [Float]
14
+ attr_reader :high
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
9
22
 
10
23
  # @param low [Float]
11
24
  # @param medium [Float]
12
25
  # @param high [Float]
13
26
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
- # @return [Transcripts::SeverityScoreSummary]
27
+ # @return [AssemblyAI::Transcripts::SeverityScoreSummary]
15
28
  def initialize(low:, medium:, high:, additional_properties: nil)
16
- # @type [Float]
17
29
  @low = low
18
- # @type [Float]
19
30
  @medium = medium
20
- # @type [Float]
21
31
  @high = high
22
- # @type [OpenStruct] Additional properties unmapped to the current class definition
23
32
  @additional_properties = additional_properties
33
+ @_field_set = { "low": low, "medium": medium, "high": high }
24
34
  end
25
35
 
26
36
  # Deserialize a JSON object to an instance of SeverityScoreSummary
27
37
  #
28
- # @param json_object [JSON]
29
- # @return [Transcripts::SeverityScoreSummary]
38
+ # @param json_object [String]
39
+ # @return [AssemblyAI::Transcripts::SeverityScoreSummary]
30
40
  def self.from_json(json_object:)
31
41
  struct = JSON.parse(json_object, object_class: OpenStruct)
32
- JSON.parse(json_object)
33
- low = struct.low
34
- medium = struct.medium
35
- high = struct.high
36
- new(low: low, medium: medium, high: high, additional_properties: struct)
42
+ low = struct["low"]
43
+ medium = struct["medium"]
44
+ high = struct["high"]
45
+ new(
46
+ low: low,
47
+ medium: medium,
48
+ high: high,
49
+ additional_properties: struct
50
+ )
37
51
  end
38
52
 
39
53
  # Serialize an instance of SeverityScoreSummary to a JSON object
40
54
  #
41
- # @return [JSON]
55
+ # @return [String]
42
56
  def to_json(*_args)
43
- { "low": @low, "medium": @medium, "high": @high }.to_json
57
+ @_field_set&.to_json
44
58
  end
45
59
 
46
- # Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.
60
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
61
+ # hash and check each fields type against the current object's property
62
+ # definitions.
47
63
  #
48
64
  # @param obj [Object]
49
65
  # @return [Void]
@@ -4,7 +4,9 @@ module AssemblyAI
4
4
  class Transcripts
5
5
  # The speech model to use for the transcription.
6
6
  class SpeechModel
7
+ BEST = "best"
7
8
  NANO = "nano"
9
+ # @deprecated This option will stop working in the near future. Please use {#BEST} or {#NANO} instead
8
10
  CONFORMER2 = "conformer-2"
9
11
  end
10
12
  end
@@ -2,9 +2,11 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Transcripts
5
- # The replacement logic for detected PII, can be "entity_type" or "hash". See [PII redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more details.
5
+ # The replacement logic for detected PII, can be "entity_name" or "hash". See [PII
6
+ # redaction](https://www.assemblyai.com/docs/models/pii-redaction) for more
7
+ # details.
6
8
  class SubstitutionPolicy
7
- ENTITY_TYPE = "entity_type"
9
+ ENTITY_NAME = "entity_name"
8
10
  HASH = "hash"
9
11
  end
10
12
  end