Skip to content

Commit 3da217a

Browse files
authored
Merge pull request #445 from alexrudall/improve-whisper-readme-lang
Improve Whisper language selection README
2 parents 3677ff4 + 028eeb8 commit 3da217a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,12 +506,12 @@ To create a new assistant (see [API documentation](https://platform.openai.com/d
506506
response = client.assistants.create(
507507
parameters: {
508508
model: "gpt-3.5-turbo-1106", # Retrieve via client.models.list. Assistants need 'gpt-3.5-turbo-1106' or later.
509-
name: "OpenAI-Ruby test assistant",
509+
name: "OpenAI-Ruby test assistant",
510510
description: nil,
511511
instructions: "You are a helpful assistant for coding a OpenAI API client using the OpenAI-Ruby gem.",
512512
tools: [
513513
{ type: 'retrieval' }, # Allow access to files attached using file_ids
514-
{ type: 'code_interpreter' }, # Allow access to Python code interpreter
514+
{ type: 'code_interpreter' }, # Allow access to Python code interpreter
515515
],
516516
"file_ids": ["file-123"], # See Files section above for how to upload files
517517
"metadata": { my_internal_version_id: '1.0.0' }
@@ -555,7 +555,7 @@ Once you have created an assistant as described above, you need to prepare a `Th
555555
```ruby
556556
# Create thread
557557
response = client.threads.create # Note: Once you create a thread, there is no way to list it
558-
# or recover it currently (as of 2023-12-10). So hold onto the `id`
558+
# or recover it currently (as of 2023-12-10). So hold onto the `id`
559559
thread_id = response["id"]
560560

561561
# Add initial message from user (see https://platform.openai.com/docs/api-reference/messages/createMessage)
@@ -582,7 +582,6 @@ client.threads.delete(id: thread_id)
582582
client.messages.retrieve(thread_id: thread_id, id: message_id) # -> Fails after thread is deleted
583583
```
584584

585-
586585
### Runs
587586

588587
To submit a thread to be evaluated with the model of an assistant, create a `Run` as follows (Note: This is one place where OpenAI will take your money):
@@ -604,7 +603,7 @@ The `status` response can include the following strings `queued`, `in_progress`,
604603

605604
```ruby
606605
while true do
607-
606+
608607
response = client.runs.retrieve(id: run_id, thread_id: thread_id)
609608
status = response['status']
610609

@@ -676,7 +675,7 @@ def get_current_weather(location:, unit: "celsius")
676675
return unit == "celsius" ? "The weather is nice 🌞 at 27°C" : "The weather is nice 🌞 at 80°F"
677676
else
678677
return unit == "celsius" ? "The weather is icy 🥶 at -5°C" : "The weather is icy 🥶 at 23°F"
679-
end
678+
end
680679
end
681680

682681
if status == 'requires_action'
@@ -690,7 +689,7 @@ if status == 'requires_action'
690689
tool.dig("function", "arguments"),
691690
{ symbolize_names: true },
692691
)
693-
692+
694693
tool_output = case function_name
695694
when "get_current_weather"
696695
get_current_weather(**arguments)
@@ -707,7 +706,7 @@ Note that you have 10 minutes to submit your tool output before the run expires.
707706

708707
### Image Generation
709708

710-
Generate images using DALL·E 2 or DALL·E 3!
709+
Generate images using DALL·E 2 or DALL·E 3!
711710

712711
#### DALL·E 2
713712

@@ -733,7 +732,6 @@ puts response.dig("data", 0, "url")
733732

734733
![Ruby](https://i.ibb.co/z2tCKv9/img-Goio0l-S0i81-NUNa-BIx-Eh-CT6-L.png)
735734

736-
737735
### Image Edit
738736

739737
Fill in the transparent part of an image, or upload a mask with transparent sections to indicate the parts of an image that can be changed according to your prompt...
@@ -791,12 +789,14 @@ puts response["text"]
791789

792790
The transcriptions API takes as input the audio file you want to transcribe and returns the text in the desired output file format.
793791

792+
You can pass the language of the audio file to improve transcription quality. Supported languages are listed [here](https://github.com/openai/whisper#available-models-and-languages). You need to provide the language as an ISO-639-1 code, eg. "en" for English or "ne" for Nepali. You can look up the codes [here](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).
793+
794794
```ruby
795795
response = client.audio.transcribe(
796796
parameters: {
797797
model: "whisper-1",
798798
file: File.open("path_to_file", "rb"),
799-
language: "en"
799+
language: "en" # Optional.
800800
})
801801
puts response["text"]
802802
# => "Transcription of the text"

0 commit comments

Comments
 (0)