-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): releases from DevDay; assistants, multimodality, tools, da…
…ll-e-3, tts, and more (#433)
- Loading branch information
1 parent
74bf336
commit fb92f5e
Showing
62 changed files
with
4,585 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
configured_endpoints: 28 | ||
configured_endpoints: 57 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env -S npm run tsn -T | ||
|
||
import OpenAI, { toFile } from 'openai'; | ||
import fs from 'fs/promises'; | ||
import path from 'path'; | ||
|
||
// gets API Key from environment variable OPENAI_API_KEY | ||
const openai = new OpenAI(); | ||
|
||
const speechFile = path.resolve(__dirname, './speech.mp3'); | ||
|
||
async function main() { | ||
const mp3 = await openai.audio.speech.create({ | ||
model: 'tts-1', | ||
voice: 'alloy', | ||
input: 'the quick brown fox jumped over the lazy dogs', | ||
}); | ||
|
||
const buffer = Buffer.from(await mp3.arrayBuffer()); | ||
await fs.writeFile(speechFile, buffer); | ||
|
||
const transcription = await openai.audio.transcriptions.create({ | ||
file: await toFile(buffer, 'speech.mp3'), | ||
model: 'whisper-1', | ||
}); | ||
console.log(transcription.text); | ||
|
||
const translation = await openai.audio.translations.create({ | ||
file: await toFile(buffer, 'speech.mp3'), | ||
model: 'whisper-1', | ||
}); | ||
console.log(translation.text); | ||
} | ||
|
||
main(); |
Oops, something went wrong.