Skip to main content

Create Speech

from pathlib import Path
from openai import OpenAI
import dokumetry

client = OpenAI(
  api_key = "YOUR_OPENAI_API_KEY"
)

# Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")

speech_file_path = Path(__file__).parent / "speech.mp3"
response = client.audio.speech.create(
  model= "tts-1",
  voice= "alloy",
  input= "The quick brown fox jumped over the lazy dog."
)
response.stream_to_file(speech_file_path)