Switch from PlayHT to LMNT and get free credits.
pip install -U lmnt
from pyht import Client from dotenv import load_dotenv from pyht.client import TTSOptions, Format import os load_dotenv() client = Client( user_id="PlayHT user id", api_key="PlayHT API key", ) options= TTSOptions(voice="s3://voice-cloning-zero-shot/d9ff78ba-d016-47f6-b0ef-dd630f59414e/female-cs/manifest.json", format=Format.FORMAT_MP3) with open("/Users/yourname/Downloads/audio.mp3", mode='wb') as f: for chunk in client.tts("Hello world!", options): f.write(chunk)
import asyncio from lmnt import AsyncLmnt text = 'Hello world!' voice_id = 'leah' language = 'en' async def main(): client = AsyncLmnt() response = await client.speech.generate( text=text, voice=voice_id, language=language, ) with open('audio.mp3', 'wb') as f: f.write(await response.read()) asyncio.run(main())
import asyncio from lmnt import AsyncLmnt async def main(): client = AsyncLmnt() voices = await client.speech.list_voices() name_id_list = [(voice.name, voice.id) for voice in voices] for name, id_ in name_id_list: print(f"Name: {name} | ID: {id_}") asyncio.run(main())
Was this page helpful?