Skip to content

Commit

Permalink
add more timing and fix count
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 30, 2024
1 parent 8a98268 commit 3dca55d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ export class Room {
console.log('%s strings to generate', strings.size);
const arr = Array.from(strings);
// console.log(arr);
const start = Date.now();
const results = await Promise.allSettled(
arr.map(async (str, i) => {
// Call the API to pregenerate the voice clips
Expand All @@ -1174,17 +1175,18 @@ export class Room {
redisCount('aiVoice');
return url;
}
return null;
throw new Error('no output URL');
}),
);
const end = Date.now();
this.addChatMessage(undefined, {
id: '',
name: 'System',
msg:
results.filter(Boolean).length +
results.filter(r => r.status === 'fulfilled').length +
'/' +
results.length +
' voices generated!',
' voices generated in ' + (end - start) + ' ms',
});
}
}
Expand Down

0 comments on commit 3dca55d

Please sign in to comment.