You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -12,7 +12,7 @@ Scaleway's Generative APIs service allows users to interact with powerful audio
12
12
13
13
There are several ways to interact with audio models:
14
14
- The Scaleway [console](https://console.scaleway.com) provides a complete [playground](/generative-apis/how-to/query-language-models/#accessing-the-playground), aiming to test models, adapt parameters, and observe how these changes affect the output in real-time.
15
-
- Via the [Chat Completions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion)
15
+
- Via the [Chat Completions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) or the [Audio Transcriptions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-audio-create-an-audio-transcription)
16
16
17
17
<Requirements />
18
18
@@ -21,7 +21,7 @@ There are several ways to interact with audio models:
21
21
- A valid [API key](/iam/how-to/create-api-keys/) for API authentication
22
22
- Python 3.7+ installed on your system
23
23
24
-
## Accessing the Playground
24
+
## Accessing the playground
25
25
26
26
Scaleway provides a web playground for instruct-based models hosted on Generative APIs.
27
27
@@ -46,6 +46,20 @@ You can also use the upload button to send supported audio file formats, such as
46
46
You can query the models programmatically using your favorite tools or languages.
47
47
In the example that follows, we will use the OpenAI Python client.
48
48
49
+
### Audio Transcriptions API or Chat Completions API?
50
+
51
+
Both the [Audio Transcriptions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-audio-create-an-audio-transcription) and the [Chat Completions API](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-a-chat-completion) are OpenAI-compatible REST APIs that accept audio input.
52
+
53
+
The **Audio Transcriptions API** is designed for pure speech-to-text (audio transcription) tasks, such as transcribing a voice note or meeting recording file. It can be used with compatible audio models, such as `whisper-large-v3`.
54
+
55
+
The **Chat Completions API** is more suitable for understanding audio input as part of a broader task, rather than a pure transcription task. For example, building a voice chat assistant which listens and responds in natural language, or sending multiple inputs (audio and text) to be interpreted or classified (answering questions like "Is this audio a ringtone?"). This API can be used for audio tasks with compatible multimodal models, such as `voxtral-small-24b`.
56
+
57
+
<Messagetype="note">
58
+
Scaleway's support for the Audio Transcriptions API is currently at beta stage. Support of the full feature set will be incremental.
59
+
</Message>
60
+
61
+
For full details on these APIs, see the [reference documentation](https://www.scaleway.com/en/developers/api/generative-apis/).
62
+
49
63
### Installing the OpenAI SDK
50
64
51
65
Install the OpenAI SDK using pip:
@@ -70,98 +84,131 @@ client = OpenAI(
70
84
71
85
### Transcribing audio
72
86
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.
87
+
You can now generate a text transcription of a given audio file using a suitable API / model combination of your choice.
74
88
75
-
#### Transcribing a remote audio file
89
+
<Tabsid="transcribing-audio">
76
90
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.
91
+
<TabsTablabel="Audio Transcriptions API (Beta)">
92
+
93
+
<Messagetype="note">
94
+
The Audio Transcriptions API expects audio files to be found locally. It does not support passing the URL of a remote audio file.
max_tokens=2048, # Limits the length of the output
115
-
top_p=0.95# Controls diversity through nucleus sampling. You usually only need to use temperature.
116
-
)
97
+
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 sent to the model. The resulting text transcription is printed to the screen.
117
98
118
-
print(response.choices[0].message.content)
119
-
```
99
+
```python
100
+
MODEL="openai/whisper-large-v3:fp16"
101
+
AUDIO='scaleway-ai-revolution.mp3'
120
102
121
-
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.
103
+
audio_file =open(AUDIO, "rb")
122
104
123
-
#### Transcribing a local audio file
105
+
response = client.audio.transcriptions.create(
106
+
model=MODEL,
107
+
file=audio_file,
108
+
language='en'
109
+
)
124
110
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.
111
+
print(response.text)
112
+
```
126
113
127
-
```python
128
-
import base64
129
-
130
-
MODEL="voxtral-small-24b-2507"
131
-
132
-
withopen('scaleway-ai-revolution.mp3', 'rb') as raw_file:
See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-audio-create-an-audio-transcription) for a full list of all available parameters.
115
+
116
+
</TabsTab>
117
+
118
+
<TabsTablabel="Chat Completions API">
119
+
120
+
#### Transcribing a remote audio file
121
+
122
+
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.
max_tokens=2048, # Limits the length of the output
161
-
top_p=0.95# Controls diversity through nucleus sampling. You usually only need to use temperature.
162
-
)
150
+
]
151
+
}
152
+
]
153
+
154
+
155
+
response = client.chat.completions.create(
156
+
model=MODEL,
157
+
messages=content,
158
+
temperature=0.2, # Adjusts creativity
159
+
max_tokens=2048, # Limits the length of the output
160
+
top_p=0.95# Controls diversity through nucleus sampling. You usually only need to use temperature.
161
+
)
162
+
163
+
print(response.choices[0].message.content)
164
+
```
165
+
166
+
See the [dedicated API documentation](https://www.scaleway.com/en/developers/api/generative-apis/#path-chat-completions-create-an) for a full list of all available parameters.
167
+
168
+
#### Transcribing a local audio file
169
+
170
+
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.
171
+
172
+
```python
173
+
import base64
174
+
175
+
MODEL="voxtral-small-24b-2507"
176
+
177
+
withopen('scaleway-ai-revolution.mp3', 'rb') as raw_file:
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.
201
+
response = client.chat.completions.create(
202
+
model=MODEL,
203
+
messages=content,
204
+
temperature=0.2, # Adjusts creativity
205
+
max_tokens=2048, # Limits the length of the output
206
+
top_p=0.95# Controls diversity through nucleus sampling. You usually only need to use temperature.
207
+
)
208
+
209
+
print(response.choices[0].message.content)
210
+
```
211
+
212
+
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