Class: LLM::DeepInfra::Audio
- Inherits:
-
Object
- Object
- LLM::DeepInfra::Audio
- Defined in:
- lib/llm/providers/deepinfra/audio.rb
Instance Method Summary collapse
- #create_speech(input:, model: "hexgrad/Kokoro-82M", **params) ⇒ LLM::Response
- #create_transcription(file:, model: "openai/whisper-large-v3", **params) ⇒ LLM::Response
- #create_translation ⇒ Object
- #initialize(provider) ⇒ LLM::DeepInfra::Audio constructor
Constructor Details
#initialize(provider) ⇒ LLM::DeepInfra::Audio
9 10 11 |
# File 'lib/llm/providers/deepinfra/audio.rb', line 9 def initialize(provider) @provider = provider end |
Instance Method Details
#create_speech(input:, model: "hexgrad/Kokoro-82M", **params) ⇒ LLM::Response
22 23 24 25 26 27 28 29 30 |
# File 'lib/llm/providers/deepinfra/audio.rb', line 22 def create_speech(input:, model: "hexgrad/Kokoro-82M", **params) path = path("/v1/inference/#{model}", base_path: false) req = LLM::Transport::Request.post(path, headers) req.body = JSON.dump(params.merge(text: input)) res, span, tracer = execute(request: req, operation: "request") res = ResponseAdapter.adapt LLM::Response.new(res), type: :audio tracer.on_request_finish(operation: "request", model:, res:, span:) res end |
#create_transcription(file:, model: "openai/whisper-large-v3", **params) ⇒ LLM::Response
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/llm/providers/deepinfra/audio.rb', line 42 def create_transcription(file:, model: "openai/whisper-large-v3", **params) path = path("/v1/inference/#{model}", base_path: false) multi = LLM::Multipart.new(params.merge!(audio: LLM.File(file))) req = LLM::Transport::Request.post(path, headers) req["content-type"] = multi.content_type transport.set_body_stream(req, multi.body) res, span, tracer = execute(request: req, operation: "request") res = LLM::Response.new(res) tracer.on_request_finish(operation: "request", model:, res:, span:) res end |
#create_translation ⇒ Object
56 57 58 |
# File 'lib/llm/providers/deepinfra/audio.rb', line 56 def create_translation(...) raise NotImplementedError end |