Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌿 Fern Regeneration -- June 27, 2024 #36

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module AssemblyAI
class Streaming
class Realtime
# The encoding of the audio data
class Streaming
class Realtime
PCM_S16LE = "pcm_s16le"
PCM_MULAW = "pcm_mulaw"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# frozen_string_literal: true

require "json"
require_relative "../../realtime/types/session_begins"
require_relative "../../realtime/types/partial_transcript"
require_relative "../../realtime/types/final_transcript"
require_relative "../../realtime/types/session_information"
require_relative "../../realtime/types/session_terminated"
require_relative "../../realtime/types/realtime_error"
require_relative "session_begins"
require_relative "partial_transcript"
require_relative "final_transcript"
require_relative "session_information"
require_relative "session_terminated"
require_relative "realtime_error"

module AssemblyAI
class Streaming
class Realtime
# Receive messages from the WebSocket
class ReceiveMessage
# Deserialize a JSON object to an instance of ReceiveMessage
#
# @param json_object [String]
# @return [AssemblyAI::Streaming::ReceiveMessage]
# @return [AssemblyAI::Realtime::ReceiveMessage]
def self.from_json(json_object:)
struct = JSON.parse(json_object, object_class: OpenStruct)
begin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# frozen_string_literal: true

require "json"
require_relative "../../realtime/types/terminate_session"
require_relative "../../realtime/types/force_end_utterance"
require_relative "../../realtime/types/configure_end_utterance_silence_threshold"
require_relative "terminate_session"
require_relative "force_end_utterance"
require_relative "configure_end_utterance_silence_threshold"

module AssemblyAI
class Streaming
class Realtime
# Send messages to the WebSocket
class SendMessage
# Deserialize a JSON object to an instance of SendMessage
#
# @param json_object [String]
# @return [AssemblyAI::Streaming::SendMessage]
# @return [AssemblyAI::Realtime::SendMessage]
def self.from_json(json_object:)
struct = JSON.parse(json_object, object_class: OpenStruct)
begin
Expand Down
6 changes: 3 additions & 3 deletions lib/assemblyai/transcripts/types/paragraphs_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ParagraphsResponse
attr_reader :id
# @return [Float]
attr_reader :confidence
# @return [Float]
# @return [Integer]
attr_reader :audio_duration
# @return [Array<AssemblyAI::Transcripts::TranscriptParagraph>]
attr_reader :paragraphs
Expand All @@ -25,7 +25,7 @@ class ParagraphsResponse

# @param id [String]
# @param confidence [Float]
# @param audio_duration [Float]
# @param audio_duration [Integer]
# @param paragraphs [Array<AssemblyAI::Transcripts::TranscriptParagraph>]
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
# @return [AssemblyAI::Transcripts::ParagraphsResponse]
Expand Down Expand Up @@ -77,7 +77,7 @@ def to_json(*_args)
def self.validate_raw(obj:)
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
obj.audio_duration.is_a?(Float) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
obj.audio_duration.is_a?(Integer) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
obj.paragraphs.is_a?(Array) != false || raise("Passed value for field obj.paragraphs is not the expected type, validation failed.")
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require_relative "redacted_audio_response"

module AssemblyAI
class Transcripts
REDACTED_AUDIO_NOTIFICATION = AssemblyAI::Transcripts::RedactedAudioResponse
end
end
6 changes: 3 additions & 3 deletions lib/assemblyai/transcripts/types/sentences_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SentencesResponse
attr_reader :id
# @return [Float]
attr_reader :confidence
# @return [Float]
# @return [Integer]
attr_reader :audio_duration
# @return [Array<AssemblyAI::Transcripts::TranscriptSentence>]
attr_reader :sentences
Expand All @@ -25,7 +25,7 @@ class SentencesResponse

# @param id [String]
# @param confidence [Float]
# @param audio_duration [Float]
# @param audio_duration [Integer]
# @param sentences [Array<AssemblyAI::Transcripts::TranscriptSentence>]
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
# @return [AssemblyAI::Transcripts::SentencesResponse]
Expand Down Expand Up @@ -77,7 +77,7 @@ def to_json(*_args)
def self.validate_raw(obj:)
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
obj.audio_duration.is_a?(Float) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
obj.audio_duration.is_a?(Integer) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
obj.sentences.is_a?(Array) != false || raise("Passed value for field obj.sentences is not the expected type, validation failed.")
end
end
Expand Down
30 changes: 19 additions & 11 deletions lib/assemblyai/transcripts/types/transcript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Transcript
# @return [Float] The confidence score for the transcript, between 0.0 (low confidence) and 1.0
# (high confidence)
attr_reader :confidence
# @return [Float] The duration of this transcript object's media file, in seconds
# @return [Integer] The duration of this transcript object's media file, in seconds
attr_reader :audio_duration
# @return [Boolean] Whether Automatic Punctuation is enabled, either true or false
attr_reader :punctuate
Expand All @@ -67,14 +67,18 @@ class Transcript
attr_reader :dual_channel
# @return [AssemblyAI::Transcripts::SpeechModel]
attr_reader :speech_model
# @return [String] The URL to which we send webhooks upon transcription completion
# @return [String] The URL to which we send webhook requests.
# We sends two different types of webhook requests.
# One request when a transcript is completed or failed, and one request when the
# redacted audio is ready if redact_pii_audio is enabled.
attr_reader :webhook_url
# @return [Integer] The status code we received from your server when delivering your webhook, if a
# webhook URL was provided
# @return [Integer] The status code we received from your server when delivering the transcript
# completed or failed webhook request, if a webhook URL was provided
attr_reader :webhook_status_code
# @return [Boolean] Whether webhook authentication details were provided
attr_reader :webhook_auth
# @return [String] The header name which should be sent back with webhook calls
# @return [String] The header name to be sent with the transcript completed or failed webhook
# requests
attr_reader :webhook_auth_header_name
# @return [Boolean] Whether speed boost is enabled
attr_reader :speed_boost
Expand Down Expand Up @@ -223,18 +227,22 @@ class Transcript
# more information.
# @param confidence [Float] The confidence score for the transcript, between 0.0 (low confidence) and 1.0
# (high confidence)
# @param audio_duration [Float] The duration of this transcript object's media file, in seconds
# @param audio_duration [Integer] The duration of this transcript object's media file, in seconds
# @param punctuate [Boolean] Whether Automatic Punctuation is enabled, either true or false
# @param format_text [Boolean] Whether Text Formatting is enabled, either true or false
# @param dual_channel [Boolean] Whether [Dual channel
# ://www.assemblyai.com/docs/models/speech-recognition#dual-channel-transcription)
# was enabled in the transcription request, either true or false
# @param speech_model [AssemblyAI::Transcripts::SpeechModel]
# @param webhook_url [String] The URL to which we send webhooks upon transcription completion
# @param webhook_status_code [Integer] The status code we received from your server when delivering your webhook, if a
# webhook URL was provided
# @param webhook_url [String] The URL to which we send webhook requests.
# We sends two different types of webhook requests.
# One request when a transcript is completed or failed, and one request when the
# redacted audio is ready if redact_pii_audio is enabled.
# @param webhook_status_code [Integer] The status code we received from your server when delivering the transcript
# completed or failed webhook request, if a webhook URL was provided
# @param webhook_auth [Boolean] Whether webhook authentication details were provided
# @param webhook_auth_header_name [String] The header name which should be sent back with webhook calls
# @param webhook_auth_header_name [String] The header name to be sent with the transcript completed or failed webhook
# requests
# @param speed_boost [Boolean] Whether speed boost is enabled
# @param auto_highlights [Boolean] Whether Key Phrases is enabled, either true or false
# @param auto_highlights_result [AssemblyAI::Transcripts::AutoHighlightsResult]
Expand Down Expand Up @@ -618,7 +626,7 @@ def self.validate_raw(obj:)
obj.words&.is_a?(Array) != false || raise("Passed value for field obj.words is not the expected type, validation failed.")
obj.utterances&.is_a?(Array) != false || raise("Passed value for field obj.utterances is not the expected type, validation failed.")
obj.confidence&.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.")
obj.audio_duration&.is_a?(Float) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
obj.audio_duration&.is_a?(Integer) != false || raise("Passed value for field obj.audio_duration is not the expected type, validation failed.")
obj.punctuate&.is_a?(Boolean) != false || raise("Passed value for field obj.punctuate is not the expected type, validation failed.")
obj.format_text&.is_a?(Boolean) != false || raise("Passed value for field obj.format_text is not the expected type, validation failed.")
obj.dual_channel&.is_a?(Boolean) != false || raise("Passed value for field obj.dual_channel is not the expected type, validation failed.")
Expand Down
18 changes: 10 additions & 8 deletions lib/assemblyai/transcripts/types/transcript_optional_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ class TranscriptOptionalParams
attr_reader :dual_channel
# @return [AssemblyAI::Transcripts::SpeechModel]
attr_reader :speech_model
# @return [String] The URL to which AssemblyAI send webhooks upon transcription completion
# @return [String]
attr_reader :webhook_url
# @return [String] The header name which should be sent back with webhook calls
# @return [String] The header name to be sent with the transcript completed or failed webhook
# requests
attr_reader :webhook_auth_header_name
# @return [String] Specify a header name and value to send back with a webhook call for added
# security
# @return [String] The header value to send back with the transcript completed or failed webhook
# requests for added security
attr_reader :webhook_auth_header_value
# @return [Boolean] Enable Key Phrases, either true or false
attr_reader :auto_highlights
Expand Down Expand Up @@ -134,10 +135,11 @@ class TranscriptOptionalParams
# ://www.assemblyai.com/docs/models/speech-recognition#dual-channel-transcription)
# transcription, can be true or false.
# @param speech_model [AssemblyAI::Transcripts::SpeechModel]
# @param webhook_url [String] The URL to which AssemblyAI send webhooks upon transcription completion
# @param webhook_auth_header_name [String] The header name which should be sent back with webhook calls
# @param webhook_auth_header_value [String] Specify a header name and value to send back with a webhook call for added
# security
# @param webhook_url [String]
# @param webhook_auth_header_name [String] The header name to be sent with the transcript completed or failed webhook
# requests
# @param webhook_auth_header_value [String] The header value to send back with the transcript completed or failed webhook
# requests for added security
# @param auto_highlights [Boolean] Enable Key Phrases, either true or false
# @param audio_start_from [Integer] The point in time, in milliseconds, to begin transcribing in your media file
# @param audio_end_at [Integer] The point in time, in milliseconds, to stop transcribing in your media file
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

require "json"
require_relative "transcript_ready_notification"
require_relative "redacted_audio_response"

module AssemblyAI
class Transcripts
# The notifications sent to the webhook URL.
class TranscriptWebhookNotification
# Deserialize a JSON object to an instance of TranscriptWebhookNotification
#
# @param json_object [String]
# @return [AssemblyAI::Transcripts::TranscriptWebhookNotification]
def self.from_json(json_object:)
struct = JSON.parse(json_object, object_class: OpenStruct)
begin
AssemblyAI::Transcripts::TranscriptReadyNotification.validate_raw(obj: struct)
unless json_object.nil?
return AssemblyAI::Transcripts::TranscriptReadyNotification.from_json(json_object: json_object)
end

return nil
rescue StandardError
# noop
end
begin
AssemblyAI::Transcripts::RedactedAudioResponse.validate_raw(obj: struct)
unless json_object.nil?
return AssemblyAI::Transcripts::RedactedAudioResponse.from_json(json_object: json_object)
end

return nil
rescue StandardError
# noop
end
struct
end

# 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.
#
# @param obj [Object]
# @return [Void]
def self.validate_raw(obj:)
begin
return AssemblyAI::Transcripts::TranscriptReadyNotification.validate_raw(obj: obj)
rescue StandardError
# noop
end
begin
return AssemblyAI::Transcripts::RedactedAudioResponse.validate_raw(obj: obj)
rescue StandardError
# noop
end
raise("Passed value matched no type within the union, validation failed.")
end
end
end
end
16 changes: 9 additions & 7 deletions lib/types_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require_relative "assemblyai/files/types/uploaded_file"
require_relative "assemblyai/transcripts/types/transcript_ready_notification"
require_relative "assemblyai/transcripts/types/redacted_audio_response"
require_relative "assemblyai/transcripts/types/redacted_audio_notification"
require_relative "assemblyai/transcripts/types/transcript_webhook_notification"
require_relative "assemblyai/transcripts/types/redacted_audio_status"
require_relative "assemblyai/transcripts/types/subtitle_format"
require_relative "assemblyai/transcripts/types/word_search_response"
Expand Down Expand Up @@ -46,22 +48,25 @@
require_relative "assemblyai/transcripts/types/transcript_list_item"
require_relative "assemblyai/transcripts/types/transcript_list"
require_relative "assemblyai/transcripts/types/audio_intelligence_model_status"
require_relative "assemblyai/realtime/types/realtime_base_message"
require_relative "assemblyai/realtime/types/realtime"
require_relative "assemblyai/realtime/types/session_begins"
require_relative "assemblyai/realtime/types/partial_transcript"
require_relative "assemblyai/realtime/types/final_transcript"
require_relative "assemblyai/realtime/types/session_information"
require_relative "assemblyai/realtime/types/session_terminated"
require_relative "assemblyai/realtime/types/realtime_error"
require_relative "assemblyai/realtime/types/receive_message"
require_relative "assemblyai/realtime/types/terminate_session"
require_relative "assemblyai/realtime/types/force_end_utterance"
require_relative "assemblyai/realtime/types/configure_end_utterance_silence_threshold"
require_relative "assemblyai/realtime/types/send_message"
require_relative "assemblyai/realtime/types/realtime_base_message"
require_relative "assemblyai/realtime/types/realtime_message"
require_relative "assemblyai/realtime/types/message_type"
require_relative "assemblyai/realtime/types/realtime_transcript_type"
require_relative "assemblyai/realtime/types/realtime_transcript"
require_relative "assemblyai/realtime/types/realtime_base_transcript"
require_relative "assemblyai/realtime/types/word"
require_relative "assemblyai/realtime/types/force_end_utterance"
require_relative "assemblyai/realtime/types/configure_end_utterance_silence_threshold"
require_relative "assemblyai/realtime/types/terminate_session"
require_relative "assemblyai/realtime/types/audio_encoding"
require_relative "assemblyai/realtime/types/realtime_temporary_token_response"
require_relative "assemblyai/lemur/types/purge_lemur_request_data_response"
Expand All @@ -78,7 +83,4 @@
require_relative "assemblyai/lemur/types/lemur_question"
require_relative "assemblyai/lemur/types/lemur_model"
require_relative "assemblyai/lemur/types/lemur_usage"
require_relative "assemblyai/streaming/types/streaming"
require_relative "assemblyai/streaming/types/receive_message"
require_relative "assemblyai/streaming/types/send_message"
require_relative "assemblyai/types/error"