Skip to content

Commit ab9d0c6

Browse files
committed
fix(gen): switch order
1 parent 36f6aaf commit ab9d0c6

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

pages/generative-apis/how-to/query-audio-models.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,21 @@ client = OpenAI(
7070

7171
### Transcribing audio
7272

73-
You can now generate a text transcription of a given audio file using the Chat Completions API. This audio file can be local or remote.
73+
You can now generate a text transcription of a given audio file using the Chat Completions API. This audio file can be remote or local.
7474

75-
#### Transcribing a local audio file
75+
#### Transcribing a remote audio file
7676

77-
In the example below, a local audio file [scaleway-ai-revolution.mp3](https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3) is base-64 encoded and sent to the model, alongside a transcription prompt. The resulting text transcription is printed to the screen.
77+
In the example below, an audio file from a remote URL (`https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3`) is downloaded using the `requests` library, base64-encoded, and then sent to the model in a chat completion request alongside a transcription prompt. The resulting text transcription is printed to the screen.
7878

7979
```python
8080
import base64
81+
import requests
8182

8283
MODEL = "voxtral-small-24b-2507"
8384

84-
with open('scaleway-ai-revolution.mp3', 'rb') as raw_file:
85-
audio_data = raw_file.read()
85+
url = "https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3"
86+
response = requests.get(url)
87+
audio_data = response.content
8688
encoded_string = base64.b64encode(audio_data).decode("utf-8")
8789

8890
content = [
@@ -118,19 +120,17 @@ print(response.choices[0].message.content)
118120

119121
Various parameters such as `temperature` and `max_tokens` control the output. See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) for a full list of all available parameters.
120122

121-
#### Transcribing a remote audio file
123+
#### Transcribing a local audio file
122124

123-
In the example below, an audio file from a remote URL (`https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3`) is downloaded using the `requests` library, base64-encoded, and then sent to the model in a chat completion request alongside a transcription prompt. The resulting text transcription is printed to the screen.
125+
In the example below, a local audio file [scaleway-ai-revolution.mp3](https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3) is base-64 encoded and sent to the model, alongside a transcription prompt. The resulting text transcription is printed to the screen.
124126

125127
```python
126128
import base64
127-
import requests
128129

129130
MODEL = "voxtral-small-24b-2507"
130131

131-
url = "https://genapi-documentation-assets.s3.fr-par.scw.cloud/scaleway-ai-revolution.mp3"
132-
response = requests.get(url)
133-
audio_data = response.content
132+
with open('scaleway-ai-revolution.mp3', 'rb') as raw_file:
133+
audio_data = raw_file.read()
134134
encoded_string = base64.b64encode(audio_data).decode("utf-8")
135135

136136
content = [
@@ -164,4 +164,4 @@ response = client.chat.completions.create(
164164
print(response.choices[0].message.content)
165165
```
166166

167-
Various parameters such as `temperature` and `max_tokens` control the output. See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) for a full list of all available parameters.
167+
Various parameters such as `temperature` and `max_tokens` control the output. See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) for a full list of all available parameters.

0 commit comments

Comments
 (0)