Class: OpenAI::Resources::Audio::Transcriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/audio/transcriptions.rb

Instance Method Summary collapse

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.

Parameters:



118
119
120
# File 'lib/openai/resources/audio/transcriptions.rb', line 118

def initialize(client:)
  @client = client
end

Instance Method Details

#create(file:, model:, chunking_strategy: nil, include: nil, known_speaker_names: nil, known_speaker_references: nil, language: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {}) ⇒ OpenAI::Models::Audio::Transcription, ...

See #create_streaming for streaming counterpart.

Some parameter documentations has been truncated, see Models::Audio::TranscriptionCreateParams for more details.

Transcribes audio into the input language.

Parameters:

  • file (Pathname, StringIO, IO, String, OpenAI::FilePart)

    The audio file object (not file name) to transcribe, in one of these formats: fl

  • model (String, Symbol, OpenAI::Models::AudioModel)

    ID of the model to use. The options are ‘gpt-4o-transcribe`, `gpt-4o-mini-transc

  • chunking_strategy (Symbol, :auto, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig, nil)

    Controls how the audio is cut into chunks. When set to ‘“auto”`, the server firs

  • include (Array<Symbol, OpenAI::Models::Audio::TranscriptionInclude>)

    Additional information to include in the transcription response.

  • known_speaker_names (Array<String>)

    Optional list of speaker names that correspond to the audio samples provided in

  • known_speaker_references (Array<String>)

    Optional list of audio samples (as [data URLs](developer.mozilla.org/en-

  • language (String)

    The language of the input audio. Supplying the input language in [ISO-639-1](htt

  • prompt (String)

    An optional text to guide the model’s style or continue a previous audio segment

  • response_format (Symbol, OpenAI::Models::AudioResponseFormat)

    The format of the output, in one of these options: ‘json`, `text`, `srt`, `verbo

  • temperature (Float)

    The sampling temperature, between 0 and 1. Higher values like 0.8 will make the

  • timestamp_granularities (Array<Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity>)

    The timestamp granularities to populate for this transcription. ‘response_format

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/openai/resources/audio/transcriptions.rb', line 44

def create(params)
  parsed, options = OpenAI::Audio::TranscriptionCreateParams.dump_request(params)
  if parsed[:stream]
    message = "Please use `#create_streaming` for the streaming use case."
    raise ArgumentError.new(message)
  end
  @client.request(
    method: :post,
    path: "audio/transcriptions",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Models::Audio::TranscriptionCreateResponse,
    options: options
  )
end

#create_streaming(file:, model:, chunking_strategy: nil, include: nil, known_speaker_names: nil, known_speaker_references: nil, language: 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 #create for non-streaming counterpart.

Some parameter documentations has been truncated, see Models::Audio::TranscriptionCreateParams for more details.

Transcribes audio into the input language.

Parameters:

  • file (Pathname, StringIO, IO, String, OpenAI::FilePart)

    The audio file object (not file name) to transcribe, in one of these formats: fl

  • model (String, Symbol, OpenAI::Models::AudioModel)

    ID of the model to use. The options are ‘gpt-4o-transcribe`, `gpt-4o-mini-transc

  • chunking_strategy (Symbol, :auto, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig, nil)

    Controls how the audio is cut into chunks. When set to ‘“auto”`, the server firs

  • include (Array<Symbol, OpenAI::Models::Audio::TranscriptionInclude>)

    Additional information to include in the transcription response.

  • known_speaker_names (Array<String>)

    Optional list of speaker names that correspond to the audio samples provided in

  • known_speaker_references (Array<String>)

    Optional list of audio samples (as [data URLs](developer.mozilla.org/en-

  • language (String)

    The language of the input audio. Supplying the input language in [ISO-639-1](htt

  • prompt (String)

    An optional text to guide the model’s style or continue a previous audio segment

  • response_format (Symbol, OpenAI::Models::AudioResponseFormat)

    The format of the output, in one of these options: ‘json`, `text`, `srt`, `verbo

  • temperature (Float)

    The sampling temperature, between 0 and 1. Higher values like 0.8 will make the

  • timestamp_granularities (Array<Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity>)

    The timestamp granularities to populate for this transcription. ‘response_format

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/openai/resources/audio/transcriptions.rb', line 97

def create_streaming(params)
  parsed, options = OpenAI::Audio::TranscriptionCreateParams.dump_request(params)
  unless parsed.fetch(:stream, true)
    message = "Please use `#create` for the non-streaming use case."
    raise ArgumentError.new(message)
  end
  parsed.store(:stream, true)
  @client.request(
    method: :post,
    path: "audio/transcriptions",
    headers: {"content-type" => "multipart/form-data", "accept" => "text/event-stream"},
    body: parsed,
    stream: OpenAI::Internal::Stream,
    model: OpenAI::Audio::TranscriptionStreamEvent,
    options: options
  )
end