from pathlib import Path from config import client def text_to_speech(text: str, voice: str = "Aaliyah-PlayAI", fmt: str = "wav"): speech_path = Path("audio/temp/output." + fmt) response = client.audio.speech.create( model="playai-tts", voice=voice, response_format=fmt, input=text, ) response.stream_to_file(speech_path) return speech_path