Skip to content

Commit 3222cd8

Browse files
authored
upd code snippets in readme, add examples (#471)
1 parent 4787939 commit 3222cd8

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ client = HumeClient(api_key="YOUR_API_KEY")
5858
client.empathic_voice.configs.list_configs()
5959
```
6060

61+
### Examples
62+
63+
Starter projects that use this SDK:
64+
65+
- **[EVI Python quickstart](https://github.com/HumeAI/hume-api-examples/tree/main/evi/evi-python-quickstart)** — Empathic Voice Interface
66+
- **[TTS Python quickstart](https://github.com/HumeAI/hume-api-examples/tree/main/tts/tts-python-quickstart)** — Text-to-speech
67+
- **[Expression Measurement streaming (Python)](https://github.com/HumeAI/hume-api-examples/tree/main/expression-measurement/streaming/python-streaming-example)** — Streaming expression measurement
68+
6169
## Async Client
6270

6371
The SDK also exports an async client so that you can make non-blocking calls to our API.
@@ -104,7 +112,7 @@ from hume.client import HumeClient
104112

105113
client = HumeClient(api_key="YOUR_API_KEY")
106114

107-
client.emapthic_voice. # APIs specific to Empathic Voice
115+
client.empathic_voice. # APIs specific to Empathic Voice
108116
client.tts. # APIs specific to Text-to-speech
109117
client.expression_measurement. # APIs specific to Expression Measurement
110118
```
@@ -114,26 +122,28 @@ client.expression_measurement. # APIs specific to Expression Measurement
114122
All errors thrown by the SDK will be subclasses of [`ApiError`](./src/hume/core/api_error.py).
115123

116124
```python
117-
import hume.client
125+
from hume.client import HumeClient
126+
from hume.core import ApiError
118127

128+
client = HumeClient(api_key="YOUR_API_KEY")
119129
try:
120-
client.expression_measurement.batch.get_job_predictions(...)
121-
except hume.core.ApiError as e: # Handle all errors
122-
print(e.status_code)
123-
print(e.body)
130+
client.expression_measurement.batch.get_job_predictions(id="my-job-id")
131+
except ApiError as e:
132+
print(e.status_code)
133+
print(e.body)
124134
```
125135

126136
## Pagination
127137

128138
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object. For example, `list_tools` will return a generator over `ReturnUserDefinedTool` and handle the pagination behind the scenes:
129139

130140
```python
131-
import hume.client
141+
from hume.client import HumeClient
132142

133143
client = HumeClient(api_key="YOUR_API_KEY")
134144

135145
for tool in client.empathic_voice.tools.list_tools():
136-
print(tool)
146+
print(tool)
137147
```
138148

139149
you could also iterate page-by-page:
@@ -161,16 +171,17 @@ We expose a websocket client for interacting with the EVI API as well as Express
161171
When interacting with these clients, you can use them very similarly to how you'd use the common `websockets` library:
162172

163173
```python
164-
from hume import StreamDataModels
174+
import os
165175

166-
client = AsyncHumeClient(api_key=os.getenv("HUME_API_KEY"))
176+
from hume import AsyncHumeClient
167177

168-
async with client.expression_measurement.stream.connect(
169-
options={"config": StreamDataModels(...)}
170-
) as hume_socket:
178+
client = AsyncHumeClient(api_key=os.getenv("HUME_API_KEY"))
179+
async with client.expression_measurement.stream.connect() as hume_socket:
171180
print(await hume_socket.get_job_details())
172181
```
173182

183+
Model configuration (e.g. face, language, prosody) is sent per payload when you send data (e.g. via `send_publish()`, `send_text()`, or `send_file()`), not at connect time.
184+
174185
The underlying connection, in this case `hume_socket`, will support intellisense/autocomplete for the different functions that are available on the socket!
175186

176187
### Advanced

0 commit comments

Comments
 (0)