assemblyai 1.0.0.pre.beta.7 → 1.0.0.pre.beta.9

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 +260 -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 -55
  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 -32
  10. data/lib/assemblyai/lemur/types/lemur_question_answer.rb +28 -14
  11. data/lib/assemblyai/lemur/types/lemur_question_answer_response.rb +29 -15
  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 +30 -14
  17. data/lib/assemblyai/realtime/types/configure_end_utterance_silence_threshold.rb +24 -13
  18. data/lib/assemblyai/realtime/types/final_transcript.rb +73 -42
  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 +63 -35
  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 +20 -11
  27. data/lib/assemblyai/realtime/types/realtime_transcript.rb +15 -9
  28. data/lib/assemblyai/realtime/types/session_begins.rb +32 -15
  29. data/lib/assemblyai/realtime/types/session_information.rb +69 -0
  30. data/lib/assemblyai/realtime/types/session_terminated.rb +21 -12
  31. data/lib/assemblyai/realtime/types/terminate_session.rb +20 -11
  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/{realtime → streaming}/types/send_message.rb +26 -14
  35. data/lib/assemblyai/streaming/types/streaming.rb +11 -0
  36. data/lib/assemblyai/transcripts/client.rb +50 -18
  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/entity_type.rb +15 -0
  47. data/lib/assemblyai/transcripts/types/page_details.rb +62 -36
  48. data/lib/assemblyai/transcripts/types/paragraphs_response.rb +37 -19
  49. data/lib/assemblyai/transcripts/types/redact_pii_audio_quality.rb +4 -1
  50. data/lib/assemblyai/transcripts/types/redacted_audio_response.rb +29 -15
  51. data/lib/assemblyai/transcripts/types/sentences_response.rb +37 -19
  52. data/lib/assemblyai/transcripts/types/sentiment_analysis_result.rb +63 -36
  53. data/lib/assemblyai/transcripts/types/severity_score_summary.rb +32 -16
  54. data/lib/assemblyai/transcripts/types/speech_model.rb +1 -0
  55. data/lib/assemblyai/transcripts/types/substitution_policy.rb +3 -1
  56. data/lib/assemblyai/transcripts/types/timestamp.rb +28 -14
  57. data/lib/assemblyai/transcripts/types/topic_detection_model_result.rb +39 -20
  58. data/lib/assemblyai/transcripts/types/topic_detection_result.rb +40 -21
  59. data/lib/assemblyai/transcripts/types/topic_detection_result_labels_item.rb +31 -15
  60. data/lib/assemblyai/transcripts/types/transcript.rb +513 -295
  61. data/lib/assemblyai/transcripts/types/transcript_custom_spelling.rb +30 -15
  62. data/lib/assemblyai/transcripts/types/transcript_language_code.rb +87 -4
  63. data/lib/assemblyai/transcripts/types/transcript_list.rb +33 -17
  64. data/lib/assemblyai/transcripts/types/transcript_list_item.rb +60 -35
  65. data/lib/assemblyai/transcripts/types/transcript_optional_params.rb +338 -196
  66. data/lib/assemblyai/transcripts/types/transcript_paragraph.rb +61 -34
  67. data/lib/assemblyai/transcripts/types/transcript_ready_notification.rb +30 -16
  68. data/lib/assemblyai/transcripts/types/transcript_sentence.rb +61 -34
  69. data/lib/assemblyai/transcripts/types/transcript_status.rb +2 -1
  70. data/lib/assemblyai/transcripts/types/transcript_utterance.rb +55 -32
  71. data/lib/assemblyai/transcripts/types/transcript_word.rb +55 -24
  72. data/lib/assemblyai/transcripts/types/word_search_match.rb +40 -20
  73. data/lib/assemblyai/transcripts/types/word_search_response.rb +36 -17
  74. data/lib/assemblyai/types/error.rb +32 -16
  75. data/lib/requests.rb +80 -34
  76. data/lib/types_export.rb +4 -3
  77. metadata +6 -5
  78. data/lib/assemblyai/realtime/types/audio_data.rb +0 -7
  79. data/lib/assemblyai/realtime/types/receive_message.rb +0 -87
@@ -1,46 +1,61 @@
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
- # Object containing words or phrases to replace, and the word or phrase to replace with
8
+ # Object containing words or phrases to replace, and the word or phrase to replace
9
+ # with
8
10
  class TranscriptCustomSpelling
9
- attr_reader :from, :to, :additional_properties
11
+ # @return [Array<String>] Words or phrases to replace
12
+ attr_reader :from
13
+ # @return [String] Word or phrase to replace with
14
+ attr_reader :to
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
10
22
 
11
23
  # @param from [Array<String>] Words or phrases to replace
12
24
  # @param to [String] Word or phrase to replace with
13
25
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
14
- # @return [Transcripts::TranscriptCustomSpelling]
26
+ # @return [AssemblyAI::Transcripts::TranscriptCustomSpelling]
15
27
  def initialize(from:, to:, additional_properties: nil)
16
- # @type [Array<String>] Words or phrases to replace
17
28
  @from = from
18
- # @type [String] Word or phrase to replace with
19
29
  @to = to
20
- # @type [OpenStruct] Additional properties unmapped to the current class definition
21
30
  @additional_properties = additional_properties
31
+ @_field_set = { "from": from, "to": to }
22
32
  end
23
33
 
24
34
  # Deserialize a JSON object to an instance of TranscriptCustomSpelling
25
35
  #
26
- # @param json_object [JSON]
27
- # @return [Transcripts::TranscriptCustomSpelling]
36
+ # @param json_object [String]
37
+ # @return [AssemblyAI::Transcripts::TranscriptCustomSpelling]
28
38
  def self.from_json(json_object:)
29
39
  struct = JSON.parse(json_object, object_class: OpenStruct)
30
- JSON.parse(json_object)
31
- from = struct.from
32
- to = struct.to
33
- new(from: from, to: to, additional_properties: struct)
40
+ from = struct["from"]
41
+ to = struct["to"]
42
+ new(
43
+ from: from,
44
+ to: to,
45
+ additional_properties: struct
46
+ )
34
47
  end
35
48
 
36
49
  # Serialize an instance of TranscriptCustomSpelling to a JSON object
37
50
  #
38
- # @return [JSON]
51
+ # @return [String]
39
52
  def to_json(*_args)
40
- { "from": @from, "to": @to }.to_json
53
+ @_field_set&.to_json
41
54
  end
42
55
 
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.
56
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
57
+ # hash and check each fields type against the current object's property
58
+ # definitions.
44
59
  #
45
60
  # @param obj [Object]
46
61
  # @return [Void]
@@ -2,8 +2,9 @@
2
2
 
3
3
  module AssemblyAI
4
4
  class Transcripts
5
- # The language of your audio file. Possible values are found in [Supported Languages](https://www.assemblyai.com/docs/concepts/supported-languages).
6
- # The default value is 'en_us'.
5
+ # The language of your audio file. Possible values are found in [Supported
6
+ # Languages](https://www.assemblyai.com/docs/concepts/supported-languages).
7
+ # The default value is 'en_us'.
7
8
  class TranscriptLanguageCode
8
9
  EN = "en"
9
10
  EN_AU = "en_au"
@@ -15,16 +16,98 @@ module AssemblyAI
15
16
  IT = "it"
16
17
  PT = "pt"
17
18
  NL = "nl"
18
- HI = "hi"
19
- JA = "ja"
19
+ AF = "af"
20
+ SQ = "sq"
21
+ AM = "am"
22
+ AR = "ar"
23
+ HY = "hy"
24
+ AS = "as"
25
+ AZ = "az"
26
+ BA = "ba"
27
+ EU = "eu"
28
+ BE = "be"
29
+ BN = "bn"
30
+ BS = "bs"
31
+ BR = "br"
32
+ BG = "bg"
33
+ MY = "my"
34
+ CA = "ca"
20
35
  ZH = "zh"
36
+ HR = "hr"
37
+ CS = "cs"
38
+ DA = "da"
39
+ ET = "et"
40
+ FO = "fo"
21
41
  FI = "fi"
42
+ GL = "gl"
43
+ KA = "ka"
44
+ EL = "el"
45
+ GU = "gu"
46
+ HT = "ht"
47
+ HA = "ha"
48
+ HAW = "haw"
49
+ HE = "he"
50
+ HI = "hi"
51
+ HU = "hu"
52
+ IS = "is"
53
+ ID = "id"
54
+ JA = "ja"
55
+ JW = "jw"
56
+ KN = "kn"
57
+ KK = "kk"
58
+ KM = "km"
22
59
  KO = "ko"
60
+ LO = "lo"
61
+ LA = "la"
62
+ LV = "lv"
63
+ LN = "ln"
64
+ LT = "lt"
65
+ LB = "lb"
66
+ MK = "mk"
67
+ MG = "mg"
68
+ MS = "ms"
69
+ ML = "ml"
70
+ MT = "mt"
71
+ MI = "mi"
72
+ MR = "mr"
73
+ MN = "mn"
74
+ NE = "ne"
75
+ NO = "no"
76
+ NN = "nn"
77
+ OC = "oc"
78
+ PA = "pa"
79
+ PS = "ps"
80
+ FA = "fa"
23
81
  PL = "pl"
82
+ RO = "ro"
24
83
  RU = "ru"
84
+ SA = "sa"
85
+ SR = "sr"
86
+ SN = "sn"
87
+ SD = "sd"
88
+ SI = "si"
89
+ SK = "sk"
90
+ SL = "sl"
91
+ SO = "so"
92
+ SU = "su"
93
+ SW = "sw"
94
+ SV = "sv"
95
+ TL = "tl"
96
+ TG = "tg"
97
+ TA = "ta"
98
+ TT = "tt"
99
+ TE = "te"
100
+ TH = "th"
101
+ BO = "bo"
25
102
  TR = "tr"
103
+ TK = "tk"
26
104
  UK = "uk"
105
+ UR = "ur"
106
+ UZ = "uz"
27
107
  VI = "vi"
108
+ CY = "cy"
109
+ YI = "yi"
110
+ YO = "yo"
28
111
  end
29
112
  end
30
113
  end
@@ -2,31 +2,41 @@
2
2
 
3
3
  require_relative "page_details"
4
4
  require_relative "transcript_list_item"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
- # A list of transcripts. Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
10
+ # A list of transcripts. Transcripts are sorted from newest to oldest. The
11
+ # previous URL always points to a page with older transcripts.
10
12
  class TranscriptList
11
- attr_reader :page_details, :transcripts, :additional_properties
13
+ # @return [AssemblyAI::Transcripts::PageDetails]
14
+ attr_reader :page_details
15
+ # @return [Array<AssemblyAI::Transcripts::TranscriptListItem>]
16
+ attr_reader :transcripts
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
12
22
 
13
- # @param page_details [Transcripts::PageDetails]
14
- # @param transcripts [Array<Transcripts::TranscriptListItem>]
23
+ OMIT = Object.new
24
+
25
+ # @param page_details [AssemblyAI::Transcripts::PageDetails]
26
+ # @param transcripts [Array<AssemblyAI::Transcripts::TranscriptListItem>]
15
27
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
- # @return [Transcripts::TranscriptList]
28
+ # @return [AssemblyAI::Transcripts::TranscriptList]
17
29
  def initialize(page_details:, transcripts:, additional_properties: nil)
18
- # @type [Transcripts::PageDetails]
19
30
  @page_details = page_details
20
- # @type [Array<Transcripts::TranscriptListItem>]
21
31
  @transcripts = transcripts
22
- # @type [OpenStruct] Additional properties unmapped to the current class definition
23
32
  @additional_properties = additional_properties
33
+ @_field_set = { "page_details": page_details, "transcripts": transcripts }
24
34
  end
25
35
 
26
36
  # Deserialize a JSON object to an instance of TranscriptList
27
37
  #
28
- # @param json_object [JSON]
29
- # @return [Transcripts::TranscriptList]
38
+ # @param json_object [String]
39
+ # @return [AssemblyAI::Transcripts::TranscriptList]
30
40
  def self.from_json(json_object:)
31
41
  struct = JSON.parse(json_object, object_class: OpenStruct)
32
42
  parsed_json = JSON.parse(json_object)
@@ -34,28 +44,34 @@ module AssemblyAI
34
44
  page_details = nil
35
45
  else
36
46
  page_details = parsed_json["page_details"].to_json
37
- page_details = Transcripts::PageDetails.from_json(json_object: page_details)
47
+ page_details = AssemblyAI::Transcripts::PageDetails.from_json(json_object: page_details)
38
48
  end
39
49
  transcripts = parsed_json["transcripts"]&.map do |v|
40
50
  v = v.to_json
41
- Transcripts::TranscriptListItem.from_json(json_object: v)
51
+ AssemblyAI::Transcripts::TranscriptListItem.from_json(json_object: v)
42
52
  end
43
- new(page_details: page_details, transcripts: transcripts, additional_properties: struct)
53
+ new(
54
+ page_details: page_details,
55
+ transcripts: transcripts,
56
+ additional_properties: struct
57
+ )
44
58
  end
45
59
 
46
60
  # Serialize an instance of TranscriptList to a JSON object
47
61
  #
48
- # @return [JSON]
62
+ # @return [String]
49
63
  def to_json(*_args)
50
- { "page_details": @page_details, "transcripts": @transcripts }.to_json
64
+ @_field_set&.to_json
51
65
  end
52
66
 
53
- # 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.
67
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
68
+ # hash and check each fields type against the current object's property
69
+ # definitions.
54
70
  #
55
71
  # @param obj [Object]
56
72
  # @return [Void]
57
73
  def self.validate_raw(obj:)
58
- Transcripts::PageDetails.validate_raw(obj: obj.page_details)
74
+ AssemblyAI::Transcripts::PageDetails.validate_raw(obj: obj.page_details)
59
75
  obj.transcripts.is_a?(Array) != false || raise("Passed value for field obj.transcripts is not the expected type, validation failed.")
60
76
  end
61
77
  end
@@ -2,83 +2,108 @@
2
2
 
3
3
  require_relative "transcript_status"
4
4
  require "date"
5
+ require "ostruct"
5
6
  require "json"
6
7
 
7
8
  module AssemblyAI
8
9
  class Transcripts
9
10
  class TranscriptListItem
10
- attr_reader :id, :resource_url, :status, :created, :completed, :audio_url, :error, :additional_properties
11
+ # @return [String]
12
+ attr_reader :id
13
+ # @return [String]
14
+ attr_reader :resource_url
15
+ # @return [AssemblyAI::Transcripts::TranscriptStatus]
16
+ attr_reader :status
17
+ # @return [DateTime]
18
+ attr_reader :created
19
+ # @return [DateTime]
20
+ attr_reader :completed
21
+ # @return [String]
22
+ attr_reader :audio_url
23
+ # @return [String] Error message of why the transcript failed
24
+ attr_reader :error
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 id [String]
13
34
  # @param resource_url [String]
14
- # @param status [Transcripts::TranscriptStatus]
35
+ # @param status [AssemblyAI::Transcripts::TranscriptStatus]
15
36
  # @param created [DateTime]
16
37
  # @param completed [DateTime]
17
38
  # @param audio_url [String]
18
39
  # @param error [String] Error message of why the transcript failed
19
40
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
20
- # @return [Transcripts::TranscriptListItem]
21
- def initialize(id:, resource_url:, status:, created:, completed:, audio_url:, error: nil,
41
+ # @return [AssemblyAI::Transcripts::TranscriptListItem]
42
+ def initialize(id:, resource_url:, status:, created:, completed:, audio_url:, error: OMIT,
22
43
  additional_properties: nil)
23
- # @type [String]
24
44
  @id = id
25
- # @type [String]
26
45
  @resource_url = resource_url
27
- # @type [Transcripts::TranscriptStatus]
28
46
  @status = status
29
- # @type [DateTime]
30
47
  @created = created
31
- # @type [DateTime]
32
48
  @completed = completed
33
- # @type [String]
34
49
  @audio_url = audio_url
35
- # @type [String] Error message of why the transcript failed
36
- @error = error
37
- # @type [OpenStruct] Additional properties unmapped to the current class definition
50
+ @error = error if error != OMIT
38
51
  @additional_properties = additional_properties
52
+ @_field_set = {
53
+ "id": id,
54
+ "resource_url": resource_url,
55
+ "status": status,
56
+ "created": created,
57
+ "completed": completed,
58
+ "audio_url": audio_url,
59
+ "error": error
60
+ }.reject do |_k, v|
61
+ v == OMIT
62
+ end
39
63
  end
40
64
 
41
65
  # Deserialize a JSON object to an instance of TranscriptListItem
42
66
  #
43
- # @param json_object [JSON]
44
- # @return [Transcripts::TranscriptListItem]
67
+ # @param json_object [String]
68
+ # @return [AssemblyAI::Transcripts::TranscriptListItem]
45
69
  def self.from_json(json_object:)
46
70
  struct = JSON.parse(json_object, object_class: OpenStruct)
47
- parsed_json = JSON.parse(json_object)
48
- id = struct.id
49
- resource_url = struct.resource_url
50
- status = struct.status
71
+ id = struct["id"]
72
+ resource_url = struct["resource_url"]
73
+ status = struct["status"]
51
74
  created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
52
75
  completed = (DateTime.parse(parsed_json["completed"]) unless parsed_json["completed"].nil?)
53
- audio_url = struct.audio_url
54
- error = struct.error
55
- new(id: id, resource_url: resource_url, status: status, created: created, completed: completed,
56
- audio_url: audio_url, error: error, additional_properties: struct)
76
+ audio_url = struct["audio_url"]
77
+ error = struct["error"]
78
+ new(
79
+ id: id,
80
+ resource_url: resource_url,
81
+ status: status,
82
+ created: created,
83
+ completed: completed,
84
+ audio_url: audio_url,
85
+ error: error,
86
+ additional_properties: struct
87
+ )
57
88
  end
58
89
 
59
90
  # Serialize an instance of TranscriptListItem to a JSON object
60
91
  #
61
- # @return [JSON]
92
+ # @return [String]
62
93
  def to_json(*_args)
63
- {
64
- "id": @id,
65
- "resource_url": @resource_url,
66
- "status": @status,
67
- "created": @created,
68
- "completed": @completed,
69
- "audio_url": @audio_url,
70
- "error": @error
71
- }.to_json
94
+ @_field_set&.to_json
72
95
  end
73
96
 
74
- # 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.
97
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
98
+ # hash and check each fields type against the current object's property
99
+ # definitions.
75
100
  #
76
101
  # @param obj [Object]
77
102
  # @return [Void]
78
103
  def self.validate_raw(obj:)
79
104
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
80
105
  obj.resource_url.is_a?(String) != false || raise("Passed value for field obj.resource_url is not the expected type, validation failed.")
81
- obj.status.is_a?(Transcripts::TranscriptStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
106
+ obj.status.is_a?(AssemblyAI::Transcripts::TranscriptStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
82
107
  obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
83
108
  obj.completed.is_a?(DateTime) != false || raise("Passed value for field obj.completed is not the expected type, validation failed.")
84
109
  obj.audio_url.is_a?(String) != false || raise("Passed value for field obj.audio_url is not the expected type, validation failed.")