hume-python-sdk
hume-python-sdk copied to clipboard
In the latest SDK versions json_streaming does not work
Try this with version 0.9.1 ✅ Try this with latest versions: 0.11.3 ❌ Breaking change for anyone not using fixed versions.
`from dotenv import load_dotenv import os from hume import AsyncHumeClient import asyncio from hume.tts import PostedUtterance from hume.tts import PostedUtteranceVoiceWithName, FormatPcm
load_dotenv() api_key = os.getenv("HUME_API_KEY") if not api_key: raise EnvironmentError("HUME_API_KEY not found in environment variables")
hume = AsyncHumeClient(api_key=api_key)
async def main() -> None: try: async for snippet in hume.tts.synthesize_json_streaming( utterances=[ PostedUtterance( text="Take an arrow from the quiver.", voice=PostedUtteranceVoiceWithName( name="Male English Actor", provider="HUME_AI", ) ) ], format=FormatPcm(type="pcm") ): print( f"KEYPOINT streaming generate_TTS for {snippet}" ) except Exception as e: print("Error during streaming:", e)
if name == "main": asyncio.run(main()) print("Done") `