Class: OpenAI::Resources::Audio::Transcriptions
- Inherits:
-
Object
- Object
- OpenAI::Resources::Audio::Transcriptions
- Defined in:
- lib/openai/resources/audio/transcriptions.rb,
sig/openai/resources/audio/transcriptions.rbs
Overview
Turn audio into text or text into audio.
Instance Method Summary collapse
-
#create(file:, model:, chunking_strategy: nil, include: nil, keywords: nil, known_speaker_names: nil, known_speaker_references: nil, language: nil, languages: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {}) ⇒ OpenAI::Models::Audio::Transcription, ...
See OpenAI::Resources::Audio::Transcriptions#create_streaming for streaming counterpart.
-
#create_streaming(file:, model:, chunking_strategy: nil, include: nil, keywords: nil, known_speaker_names: nil, known_speaker_references: nil, language: nil, languages: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {}) ⇒ OpenAI::Internal::Stream<OpenAI::Models::Audio::TranscriptionTextSegmentEvent, OpenAI::Models::Audio::TranscriptionTextDeltaEvent, OpenAI::Models::Audio::TranscriptionTextDoneEvent>
See OpenAI::Resources::Audio::Transcriptions#create for non-streaming counterpart.
-
#initialize(client:) ⇒ Transcriptions
constructor
private
A new instance of Transcriptions.
Constructor Details
#initialize(client:) ⇒ Transcriptions
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Transcriptions.
265 266 267 |
# File 'lib/openai/resources/audio/transcriptions.rb', line 265 def initialize(client:) @client = client end |
Instance Method Details
#create(file:, model:, chunking_strategy: nil, include: nil, keywords: nil, known_speaker_names: nil, known_speaker_references: nil, language: nil, languages: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {}) ⇒ OpenAI::Models::Audio::Transcription, ...
See OpenAI::Resources::Audio::Transcriptions#create_streaming for streaming counterpart.
Transcribes audio into the input language.
Returns a transcription object in json, diarized_json, or verbose_json
format, or a stream of transcript events.
String, StringIO, and pathless IO inputs are sent with generic upload
metadata. Use OpenAI::FilePart when you need to override the filename or
content type.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/openai/resources/audio/transcriptions.rb', line 114 def create(params) parsed, = OpenAI::Audio::TranscriptionCreateParams.dump_request(params) if parsed[:stream] = "Please use `#create_streaming` for the streaming use case." raise ArgumentError.new() end @client.request( method: :post, path: "audio/transcriptions", headers: {"content-type" => "multipart/form-data"}, body: parsed, model: OpenAI::Models::Audio::TranscriptionCreateResponse, security: {bearer_auth: true}, options: ) end |
#create_streaming(file:, model:, chunking_strategy: nil, include: nil, keywords: nil, known_speaker_names: nil, known_speaker_references: nil, language: nil, languages: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {}) ⇒ OpenAI::Internal::Stream<OpenAI::Models::Audio::TranscriptionTextSegmentEvent, OpenAI::Models::Audio::TranscriptionTextDeltaEvent, OpenAI::Models::Audio::TranscriptionTextDoneEvent>
See OpenAI::Resources::Audio::Transcriptions#create for non-streaming counterpart.
Transcribes audio into the input language.
Returns a transcription object in json, diarized_json, or verbose_json
format, or a stream of transcript events.
String, StringIO, and pathless IO inputs are sent with generic upload
metadata. Use OpenAI::FilePart when you need to override the filename or
content type.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/openai/resources/audio/transcriptions.rb', line 238 def create_streaming(params) parsed, = OpenAI::Audio::TranscriptionCreateParams.dump_request(params) unless parsed.fetch(:stream, true) = "Please use `#create` for the non-streaming use case." raise ArgumentError.new() end parsed.store(:stream, true) @client.request( method: :post, path: "audio/transcriptions", headers: { "content-type" => "multipart/form-data", "accept" => "text/event-stream", "accept-encoding" => "identity" }, body: parsed, stream: OpenAI::Internal::Stream, model: OpenAI::Audio::TranscriptionStreamEvent, security: {bearer_auth: true}, options: ) end |