Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
  • Loading branch information
elitan committed Nov 7, 2023
1 parent e3473b3 commit fd7fd2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion worker/src/4-openai-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function main() {
n: 1,
quality: 'standard',
size: '1792x1024',
style: 'natural',
style: 'vivid',
});

if (!image.data[0].b64_json) {
Expand Down
11 changes: 10 additions & 1 deletion worker/src/5-openai-tts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@ async function main() {
const voices = ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'];
const randomIndex = Math.floor(Math.random() * voices.length);

const voice = voices[randomIndex] as any;
console.log(article.body);
console.log({ voice });

const mp3 = await openai.audio.speech.create({
model: 'tts-1-hd',
voice: voices[randomIndex] as any,
voice: 'alloy',
input: article.body,
response_format: 'mp3',
speed: 1,
});

console.log('mp3');
console.log(mp3);

const fileName = `audio/${article.id}.mp3`;
const buffer = Buffer.from(await mp3.arrayBuffer());

Expand All @@ -49,6 +56,8 @@ async function main() {

const audioUrl = `https://nyheter.ams3.cdn.digitaloceanspaces.com/${fileName}`;

console.log({ audioUrl });

await db
.updateTable('articleTranslations')
.set({
Expand Down
2 changes: 1 addition & 1 deletion worker/src/utils/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export async function generateArticle(transcribedText: string) {
function_call: {
name: FUNCTIONS.getNewsArticleInformation.name,
},
model: 'gpt-4',
model: 'gpt-4-0613',
temperature: 0.7,
max_tokens: 1200,
});
Expand Down

0 comments on commit fd7fd2c

Please sign in to comment.