Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example how to use transcribe with Ruby on Rails and Active Storage #520

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is temp_file supposed to be file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

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.
Expand Down