Skip to content

Commit 8423964

Browse files
authored
Added example how to use transcribe with Ruby on Rails and Active Storage
1 parent 3c9411f commit 8423964

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,20 @@ puts response["text"]
12001200
# => "Transcription of the text"
12011201
```
12021202

1203+
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):
1204+
```ruby
1205+
user.media.blob.open do |file|
1206+
response = client.audio.transcribe(
1207+
parameters: {
1208+
model: "whisper-1",
1209+
file: File.open(temp_file, "rb"),
1210+
language: "en" # Optional
1211+
})
1212+
puts response["text"]
1213+
# => "Transcription of the text"
1214+
end
1215+
```
1216+
12031217
#### Speech
12041218

12051219
The speech API takes as input the text and a voice and returns the content of an audio file you can listen to.

0 commit comments

Comments
 (0)