()
| 39 | |
| 40 | |
| 41 | async def main() -> None: |
| 42 | load_dotenv() |
| 43 | |
| 44 | HUME_API_KEY = os.getenv("HUME_API_KEY") |
| 45 | HUME_CONFIG_ID = os.getenv("HUME_CONFIG_ID") |
| 46 | |
| 47 | client = AsyncHumeClient(api_key=HUME_API_KEY) |
| 48 | stream = Stream.new() |
| 49 | |
| 50 | async with client.empathic_voice.chat.connect(config_id=HUME_CONFIG_ID) as socket: |
| 51 | print("WebSocket connection opened.") |
| 52 | |
| 53 | async def handle_messages(): |
| 54 | async for message in socket: |
| 55 | await on_message(message, stream) |
| 56 | |
| 57 | await asyncio.gather( |
| 58 | handle_messages(), |
| 59 | MicrophoneInterface.start(socket, allow_user_interrupt=False, byte_stream=stream), |
| 60 | ) |
| 61 | |
| 62 | print("WebSocket connection closed.") |
| 63 | |
| 64 | |
| 65 | if __name__ == "__main__": |
no test coverage detected