Skip to content

Commit 949a759

Browse files
groq docs updated
1 parent c1b72de commit 949a759

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

integrations/llms/groq.mdx

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,131 @@ curl -X POST "https://api.portkey.ai/v1/chat/completions" \
214214

215215

216216

217+
218+
219+
220+
221+
### Groq Speech to Text (Whisper)
222+
223+
OpenAI's Audio API converts speech to text using the Whisper model. It offers transcription in the original language and translation to English, supporting multiple file formats and languages with high accuracy.
224+
225+
<CodeGroup>
226+
```python Python
227+
audio_file= open("/path/to/file.mp3", "rb")
228+
229+
# Transcription
230+
transcription = portkey.audio.transcriptions.create(
231+
model="whisper-large-v3",
232+
file=audio_file
233+
)
234+
print(transcription.text)
235+
236+
# Translation
237+
translation = portkey.audio.translations.create(
238+
model="whisper-large-v3",
239+
file=audio_file
240+
)
241+
print(translation.text)
242+
```
243+
244+
```javascript Node.js
245+
import fs from "fs";
246+
247+
// Transcription
248+
async function transcribe() {
249+
const transcription = await portkey.audio.transcriptions.create({
250+
file: fs.createReadStream("/path/to/file.mp3"),
251+
model: "whisper-large-v3",
252+
});
253+
console.log(transcription.text);
254+
}
255+
transcribe();
256+
257+
// Translation
258+
async function translate() {
259+
const translation = await portkey.audio.translations.create({
260+
file: fs.createReadStream("/path/to/file.mp3"),
261+
model: "whisper-large-v3",
262+
});
263+
console.log(translation.text);
264+
}
265+
translate();
266+
```
267+
268+
```curl REST
269+
# Transcription
270+
curl -X POST "https://api.portkey.ai/v1/audio/transcriptions" \
271+
-H "Authorization: Bearer YOUR_PORTKEY_API_KEY" \
272+
-H "Content-Type: multipart/form-data" \
273+
-F "file=@/path/to/file.mp3" \
274+
-F "model=whisper-large-v3"
275+
276+
# Translation
277+
curl -X POST "https://api.portkey.ai/v1/audio/translations" \
278+
-H "Authorization: Bearer YOUR_PORTKEY_API_KEY" \
279+
-H "Content-Type: multipart/form-data" \
280+
-F "file=@/path/to/file.mp3" \
281+
-F "model=whisper-large-v3"
282+
```
283+
</CodeGroup>
284+
285+
286+
---
287+
288+
### Groq Text to Speech
289+
290+
Groq's Text to Speech (TTS) API converts written text into natural-sounding audio using six distinct voices. It supports multiple languages, streaming capabilities, and various audio formats for different use cases.
291+
292+
<CodeGroup>
293+
```python Python
294+
from pathlib import Path
295+
296+
speech_file_path = Path(__file__).parent / "speech.mp3"
297+
response = portkey.audio.speech.create(
298+
model="playai-tts",
299+
voice="Fritz-PlayAI",
300+
input="Today is a wonderful day to build something people love!"
301+
)
302+
303+
with open(speech_file_path, "wb") as f:
304+
f.write(response.content)
305+
```
306+
307+
```javascript Node.js
308+
import path from 'path';
309+
import fs from 'fs';
310+
311+
const speechFile = path.resolve("./speech.mp3");
312+
313+
async function main() {
314+
const mp3 = await portkey.audio.speech.createCertainly! I'll continue with the Text to Speech section and then move on to the additional features and sections:
315+
316+
```javascript Node.js
317+
({
318+
model: "playai-tts",
319+
voice: "Fritz-PlayAI",
320+
input: "Today is a wonderful day to build something people love!",
321+
});
322+
const buffer = Buffer.from(await mp3.arrayBuffer());
323+
await fs.promises.writeFile(speechFile, buffer);
324+
}
325+
326+
main();
327+
```
328+
329+
```curl REST
330+
curl -X POST "https://api.portkey.ai/v1/audio/speech" \
331+
-H "Authorization: Bearer YOUR_PORTKEY_API_KEY" \
332+
-H "Content-Type: application/json" \
333+
-d '{
334+
"model": "playai-tts",
335+
"voice": "Fritz-PlayAI",
336+
"input": "Today is a wonderful day to build something people love!"
337+
}' \
338+
--output speech.mp3
339+
```
340+
</CodeGroup>
341+
217342
---
218343
219344
You'll find more information in the relevant sections:

0 commit comments

Comments
 (0)