From 84239643f36f491a7d77712fade5afd697af8415 Mon Sep 17 00:00:00 2001 From: Web3 Jobs <5325909+AndreyAzimov@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:48:45 +0100 Subject: [PATCH] Added example how to use transcribe with Ruby on Rails and Active Storage --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f7141309..74a3714e 100644 --- a/README.md +++ b/README.md @@ -1200,6 +1200,20 @@ puts response["text"] # => "Transcription of the text" ``` +If you are using Ruby on Rails with Active Storage, you would need to send an audio or video file like this (User has_one_attached): +```ruby +user.media.blob.open do |file| + response = client.audio.transcribe( + parameters: { + model: "whisper-1", + file: File.open(temp_file, "rb"), + language: "en" # Optional + }) + puts response["text"] + # => "Transcription of the text" +end +``` + #### Speech The speech API takes as input the text and a voice and returns the content of an audio file you can listen to.