Class: Telnyx::Resources::AI::Audio

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/ai/audio.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Audio

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 Audio.

Parameters:



50
51
52
# File 'lib/telnyx/resources/ai/audio.rb', line 50

def initialize(client:)
  @client = client
end

Instance Method Details

#transcribe(model:, file: nil, file_url: nil, language: nil, model_config: nil, response_format: nil, timestamp_granularities: nil, request_options: {}) ⇒ Telnyx::Models::AI::AudioTranscribeResponse

Some parameter documentations has been truncated, see Models::AI::AudioTranscribeParams for more details.

Transcribe speech to text. This endpoint is consistent with the [OpenAI Transcription API](platform.openai.com/docs/api-reference/audio/createTranscription) and may be used with the OpenAI JS or Python SDK.

Parameters:

  • model (Symbol, Telnyx::Models::AI::AudioTranscribeParams::Model)

    ID of the model to use. ‘distil-whisper/distil-large-v2` is lower latency but En

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

    The audio file object to transcribe, in one of these formats: flac, mp3, mp4, mp

  • file_url (String)

    Link to audio file in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg

  • language (String)

    The language of the audio to be transcribed. For ‘deepgram/nova-3`, only English

  • model_config (Hash{Symbol=>Object})

    Additional model-specific configuration parameters. Only allowed with ‘deepgram/

  • response_format (Symbol, Telnyx::Models::AI::AudioTranscribeParams::ResponseFormat)

    The format of the transcript output. Use ‘verbose_json` to take advantage of tim

  • timestamp_granularities (Symbol, Telnyx::Models::AI::AudioTranscribeParams::TimestampGranularities)

    The timestamp granularities to populate for this transcription. ‘response_format

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

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/telnyx/resources/ai/audio.rb', line 35

def transcribe(params)
  parsed, options = Telnyx::AI::AudioTranscribeParams.dump_request(params)
  @client.request(
    method: :post,
    path: "ai/audio/transcriptions",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: Telnyx::Models::AI::AudioTranscribeResponse,
    options: options
  )
end