Module: RubyLLM::Providers::XAI::Transcription
- Included in:
- ChatCompletions, Responses
- Defined in:
- lib/ruby_llm/providers/xai/transcription.rb
Overview
Transcription dialect for the xAI Voice API. The /v1/stt endpoint is model-less multipart with the audio file last in the form; giving speaker names turns on diarization, which labels each word with a numeric speaker index.
Class Method Summary collapse
- .parse_transcription_response(response, model:) ⇒ Object
-
.render_transcription_payload(file_part, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) ⇒ Object
rubocop:disable-next Lint/UnusedMethodArgument.
- .transcription_url ⇒ Object
Instance Method Summary collapse
Class Method Details
.parse_transcription_response(response, model:) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby_llm/providers/xai/transcription.rb', line 33 def parse_transcription_response(response, model:) data = response.body RubyLLM::Transcription.new( text: data['text'], model: model, language: data['language'], duration: data['duration'], segments: data['channels'], words: data['words'] ) end |
.render_transcription_payload(file_part, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) ⇒ Object
rubocop:disable-next Lint/UnusedMethodArgument
24 25 26 27 28 29 30 31 |
# File 'lib/ruby_llm/providers/xai/transcription.rb', line 24 def render_transcription_payload(file_part, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) payload = {} payload[:language] = language if language payload[:diarize] = true if speaker_names payload.merge().merge(file: file_part) end |
.transcription_url ⇒ Object
19 20 21 |
# File 'lib/ruby_llm/providers/xai/transcription.rb', line 19 def transcription_url 'stt' end |
Instance Method Details
#render_transcription_options(timestamps:) ⇒ Object
11 12 13 14 15 |
# File 'lib/ruby_llm/providers/xai/transcription.rb', line 11 def (timestamps:, **) return {} if .nil? || == :word raise ArgumentError, 'xAI transcription timestamps must be word' end |