Posted by
Best online store shop
on
- Get link
- X
- Other Apps
from openai import AsyncOpenAI
from openai.helpers import LocalAudioPlayer
openai = AsyncOpenAI()
input = """Every time Aldred looked at them, a voice in his mind whispered:\nThey’re waiting. Waiting for you to falter so they can take everything.\n\nIt started as a passing thought.\nThen a suspicion.\nThen, an unshakable certainty.\n\n[Conflict Escalation – The Test of Devotion]\n\nOne evening, the king called them into the great hall.\nThe torches spat and flickered, casting tall, twitching shadows on the walls—like ghosts of the past come to watch.\nHis children stood before him, uneasy under his gaze.\n\n"""
instructions = """Affect/personality: A cheerful guide \n\nTone: Friendly, clear, and reassuring, creating a calm atmosphere and making the listener feel confident and comfortable.\n\nPronunciation: Clear, articulate, and steady, ensuring each instruction is easily understood while maintaining a natural, conversational flow.\n\nPause: Brief, purposeful pauses after key instructions (e.g., \"cross the street\" and \"turn right\") to allow time for the listener to process the information and follow along.\n\nEmotion: Warm and supportive, conveying empathy and care, ensuring the listener feels guided and safe throughout the journey."""
async def main() -> None:
async with openai.audio.speech.with_streaming_response.create(
model="gpt-4o-mini-tts",
voice="coral",
input=input,
instructions=instructions,
response_format="pcm",
) as response:
await LocalAudioPlayer().play(response)
if __name__ == "__main__":
asyncio.run(main())
Comments
Post a Comment