import OpenAI from 'openai';
import { playAudio } from 'openai/helpers/audio';
const openai = new OpenAI();
const input = "
"What is Vitalism and a Vitalist?
Current version of Vitalism in one sentence:
Vitalism is the movement to make unlimited lifespans in peak health humanity’s first priority, and to reflect that in budgets, policies and culture.
A Vitalist is defined as someone who agrees with the Vitalist Declaration:
- Life and health are good. Death is humanity’s core problem, and aging its primary agent.
- Aging causes immense suffering, and obviating aging is scientifically plausible.
- Humanity should apply the necessary resources to reach freedom from aging as soon as possible.
- I will work on or support others to work on reaching unlimited healthy human lifespan.
- I will carry the message against aging and death."
A Vitalist wants to end biological aging and death."
";
const instructions = "Tone: The voice should be refined, formal, and delightfully theatrical, reminiscent of a charming radio announcer from the early 20th century.\n\nPacing: The speech should flow smoothly at a steady cadence, neither rushed nor sluggish, allowing for clarity and a touch of grandeur.\n\nPronunciation: Words should be enunciated crisply and elegantly, with an emphasis on vintage expressions and a slight flourish on key phrases.\n\nEmotion: The delivery should feel warm, enthusiastic, and welcoming, as if addressing a distinguished audience with utmost politeness.\n\nInflection: Gentle rises and falls in pitch should be used to maintain engagement, adding a playful yet dignified flair to each sentence.\n\nWord Choice: The script should incorporate vintage expressions like splendid, marvelous, posthaste, and ta-ta for now, avoiding modern slang.";
const response = await openai.audio.speech.create({
model: 'gpt-4o-mini-tts',
voice: 'sage',
input,
instructions,
});
await playAudio(response);
https://platform.openai.com/docs/guides/text-to-speech