@@ -24,7 +24,7 @@ Save audio samples as reusable voices. Once created, a voice can be referenced b
2424``` python
2525import base64
2626from pathlib import Path
27- from mistralai import Mistral
27+ from mistralai.client import Mistral
2828
2929client = Mistral(api_key = " your-api-key" )
3030
@@ -151,25 +151,27 @@ curl -X POST "https://api.mistral.ai/v1/audio/voices" \
151151 <TabItem value="v1" label="V1" default>
152152
153153``` python
154- from mistralai import Mistral
154+ from mistralai.client import Mistral
155155
156156client = Mistral(api_key = " your-api-key" )
157157
158- result = client.audio.voices.list(limit = 10 , offset = 0 )
159-
160- print (f " Total voices: { result.total} " )
161- for voice in result.items:
162- print (f " - { voice.name} ( { voice.id} ) languages= { voice.languages} " )
163-
164- # Paginate through all voices
158+ limit = 10
165159offset = 0
166160all_voices = []
161+
167162while True :
168- page = client.audio.voices.list(limit = 10 , offset = offset)
169- all_voices.extend(page.items)
170- if offset + len (page.items) >= page.total:
163+ page = client.audio.voices.list(limit = limit, offset = offset)
164+ items = page.items or []
165+ all_voices.extend(items)
166+
167+ if offset + len (items) >= page.total:
171168 break
172- offset += len (page.items)
169+
170+ offset += len (items)
171+
172+ print (f " Total voices: { len (all_voices)} " )
173+ for voice in all_voices:
174+ print (f " - { voice.name} ( { voice.id} ) languages= { voice.languages} " )
173175```
174176
175177 </TabItem>
@@ -180,21 +182,23 @@ from mistralai.client import Mistral
180182
181183client = Mistral(api_key = " your-api-key" )
182184
183- result = client.audio.voices.list(limit = 10 , offset = 0 )
184-
185- print (f " Total voices: { result.total} " )
186- for voice in result.items:
187- print (f " - { voice.name} ( { voice.id} ) languages= { voice.languages} " )
188-
189- # Paginate through all voices
185+ limit = 10
190186offset = 0
191187all_voices = []
188+
192189while True :
193- page = client.audio.voices.list(limit = 10 , offset = offset)
194- all_voices.extend(page.items)
195- if offset + len (page.items) >= page.total:
190+ page = client.audio.voices.list(limit = limit, offset = offset)
191+ items = page.items or []
192+ all_voices.extend(items)
193+
194+ if offset + len (items) >= page.total:
196195 break
197- offset += len (page.items)
196+
197+ offset += len (items)
198+
199+ print (f " Total voices: { len (all_voices)} " )
200+ for voice in all_voices:
201+ print (f " - { voice.name} ( { voice.id} ) languages= { voice.languages} " )
198202```
199203
200204 </TabItem>
@@ -206,21 +210,24 @@ while True:
206210
207211const client = new Mistral ({ apiKey: " your-api-key" });
208212
209- const result = await client .audio .voices .list ({ limit: 10 , offset: 0 });
210-
211- console .log (` Total voices: ${result .total } ` );
212- for (const voice of result .items ?? []) {
213- console .log (` - ${voice .name } (${voice .id }) languages=${voice .languages } ` );
214- }
215-
216- // Paginate through all voices
213+ const limit = 10 ;
217214let offset = 0 ;
218215const allVoices = [];
216+
219217while (true ) {
220- const page = await client .audio .voices .list ({ limit: 10 , offset });
221- allVoices .push (... (page .items ?? []));
222- if (offset + (page .items ?.length ?? 0 ) >= page .total ) break ;
223- offset += page .items ?.length ?? 0 ;
218+ const page = await client .audio .voices .list ({ limit , offset });
219+ const items = page .items ?? [];
220+
221+ allVoices .push (... items );
222+
223+ if (offset + items .length >= page .total ) break ;
224+
225+ offset += items .length ;
226+ }
227+
228+ console .log (` Total voices: ${allVoices .length } ` );
229+ for (const voice of allVoices ) {
230+ console .log (` - ${voice .name } (${voice .id }) languages=${voice .languages } ` );
224231}
225232```
226233
@@ -268,7 +275,7 @@ curl "https://api.mistral.ai/v1/audio/voices?limit=10&offset=0" \
268275 <TabItem value="v1" label="V1" default>
269276
270277``` python
271- from mistralai import Mistral
278+ from mistralai.client import Mistral
272279
273280client = Mistral(api_key = " your-api-key" )
274281
@@ -349,7 +356,7 @@ curl "https://api.mistral.ai/v1/audio/voices/$VOICE_ID" \
349356 <TabItem value="v1" label="V1" default>
350357
351358``` python
352- from mistralai import Mistral
359+ from mistralai.client import Mistral
353360
354361client = Mistral(api_key = " your-api-key" )
355362
@@ -447,7 +454,7 @@ curl -X PATCH "https://api.mistral.ai/v1/audio/voices/$VOICE_ID" \
447454 <TabItem value="v1" label="V1" default>
448455
449456``` python
450- from mistralai import Mistral
457+ from mistralai.client import Mistral
451458
452459client = Mistral(api_key = " your-api-key" )
453460
@@ -517,7 +524,7 @@ curl -X DELETE "https://api.mistral.ai/v1/audio/voices/$VOICE_ID" \
517524
518525``` python
519526from pathlib import Path
520- from mistralai import Mistral
527+ from mistralai.client import Mistral
521528
522529client = Mistral(api_key = " your-api-key" )
523530
0 commit comments