Skip to content

Commit 651fe99

Browse files
authored
Merge pull request #520 from AndreyAzimov/main
Add an example how to use transcribe with Ruby on Rails and Active Storage
2 parents 0cb3290 + 8423964 commit 651fe99

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
@@ -1674,6 +1674,20 @@ puts response["text"]
16741674
# => "Transcription of the text"
16751675
```
16761676

1677+
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):
1678+
```ruby
1679+
user.media.blob.open do |file|
1680+
response = client.audio.transcribe(
1681+
parameters: {
1682+
model: "whisper-1",
1683+
file: File.open(temp_file, "rb"),
1684+
language: "en" # Optional
1685+
})
1686+
puts response["text"]
1687+
# => "Transcription of the text"
1688+
end
1689+
```
1690+
16771691
#### Speech
16781692

16791693
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)