Class: Telnyx::Resources::SpeechToText

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/speech_to_text.rb,
sig/telnyx/resources/speech_to_text.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SpeechToText

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

Parameters:



113
114
115
# File 'lib/telnyx/resources/speech_to_text.rb', line 113

def initialize(client:)
  @client = client
end

Instance Method Details

#list_providers(provider: nil, service_type: nil, request_options: {}) ⇒ Telnyx::Models::SpeechToTextListProvidersResponse

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

Retrieve the canonical list of supported speech-to-text providers, models, accepted language codes, and the service types each model supports.

Service types:

  • streaming — standalone WebSocket transcription via /speech-to-text/transcription.
  • file_based — file-based transcription via /ai/audio/transcriptions.
  • in_call — live call transcription via Call Control transcription_start.
  • ai_assistant — STT configured on a Call Control AI Assistant via voice-assistant TranscriptionConfig (covers both live-streaming and non-streaming/batch models).

Use this endpoint to discover which (provider, model) combinations are available for the surface you need, and which language codes each accepts. auto in a languages array indicates the provider performs language detection.

Parameters:

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/telnyx/resources/speech_to_text.rb', line 37

def list_providers(params = {})
  parsed, options = Telnyx::SpeechToTextListProvidersParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  path =
    @client.base_url_overridden? ? "speech-to-text/providers" : "https://api.telnyx.com/v2/speech-to-text/providers"
  @client.request(
    method: :get,
    path: path,
    query: query,
    model: Telnyx::Models::SpeechToTextListProvidersResponse,
    options: options
  )
end

#retrieve_transcription(input_format:, transcription_engine:, endpointing: nil, interim_results: nil, keyterm: nil, keywords: nil, language: nil, model: nil, redact: nil, request_options: {}) ⇒ nil

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

Open a WebSocket connection to stream audio and receive transcriptions in real-time. Authentication is provided via the standard Authorization: Bearer <API_KEY> header.

Supported engines: Azure, Deepgram, Google, Telnyx, xAI, Speechmatics, Soniox, Parakeet.

Connection flow:

  1. Open WebSocket with query parameters specifying engine, input format, and language.
  2. Send binary audio frames (mp3/wav format).
  3. Receive JSON transcript frames with transcript, is_final, and confidence fields.
  4. Close connection when done.

Parameters:

Returns:

  • (nil)

See Also:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/telnyx/resources/speech_to_text.rb', line 95

def retrieve_transcription(params)
  parsed, options = Telnyx::SpeechToTextRetrieveTranscriptionParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  path =
    @client.base_url_overridden? ? "speech-to-text/transcription" : "wss://api.telnyx.com/v2/speech-to-text/transcription"
  @client.request(
    method: :get,
    path: path,
    query: query,
    headers: {"content-type" => "application/octet-stream"},
    model: NilClass,
    options: options
  )
end