hume


Namehume JSON
Version 0.7.5 PyPI version JSON
download
home_pageNone
SummaryA Python SDK for Hume AI
upload_time2024-12-04 00:30:23
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.9
licenseMIT
keywords hume ai evi empathic multimodal expression analysis sentiment voice recognition detection emotion interface speech audio vision expressive embeddings communication learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <img src="https://storage.googleapis.com/hume-public-logos/hume/hume-banner.png">
  <h1>Hume AI Python SDK</h1>

  <p>
    <strong>Integrate Hume APIs directly into your Python application</strong>
  </p>

  <br>
  <div>
    <a href="https://pypi.python.org/pypi/hume"><img src="https://img.shields.io/pypi/v/hume"></a>
    <a href="https://buildwithfern.com/"><img src="https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen"></a>
  </div>
  <br>
</div>

## Migration Guide for Version 0.7.0 and Above

We've released version `0.7.0` of the SDK with significant architectural changes. This update introduces `AsyncHumeClient` and `HumeClient`, improves type safety and async support, and provides more granular configuration options. To help you transition, we've prepared a comprehensive migration guide:

**[View the Migration Guide](https://github.com/HumeAI/hume-python-sdk/wiki/Python-SDK-Migration-Guide)**

Please review this guide before updating, as it covers breaking changes and provides examples for updating your code. Legacy functionality is preserved for backward compatibility. If you have any questions, please open an issue or contact our support team.

## Documentation

API reference documentation is available [here](https://dev.hume.ai/reference/).

## Compatibility

The Hume Python SDK is compatible across several Python versions and operating systems.

- For the Empathic Voice Interface, Python versions `3.9` through `3.11` are supported on macOS and Linux.

- For Expression Measurement, Python versions `3.9` through `3.12` are supported on macOS, Linux, and Windows.

Below is a table which shows the version and operating system compatibilities by product:

|                          | Python Version                | Operating System      |
| ------------------------ | ----------------------------- | --------------------- |
| Empathic Voice Interface | `3.9`, `3.10`, `3.11`         | macOS, Linux          |
| Expression Measurement   | `3.9`, `3.10`, `3.11`, `3.12` | macOS, Linux, Windows |

## Installation

```sh
pip install hume
# or
poetry add hume
```

## Other Resources

```python
from hume.client import HumeClient

client = HumeClient(
    api_key="YOUR_API_KEY", # Defaults to HUME_API_KEY
)
client.empathic_voice.configs.list_configs()
```

## Async Client

The SDK also exports an async client so that you can make non-blocking calls to our API.

```python
import asyncio

from hume.client import AsyncHumeClient

client = AsyncHumeClient(
    api_key="YOUR_API_KEY",
)

async def main() -> None:
    await client.empathic_voice.configs.list_configs()

asyncio.run(main())
```

### Writing File

Writing files with an async stream of bytes can be tricky in Python! `aiofiles` can simplify this some. For example,
you can download your job artifacts like so:

```python
import aiofiles

from hume import AsyncHumeClient

client = AsyncHumeClient()
async with aiofiles.open('artifacts.zip', mode='wb') as file:
    async for chunk in client.expression_measurement.batch.get_job_artifacts(id="my-job-id"):
        await file.write(chunk)
```

## Legacy SDK

If you want to continue using the legacy SDKs, simply import them from
the `hume.legacy` module.

```python
from hume.legacy import HumeVoiceClient, VoiceConfig

client = HumeVoiceClient("<your-api-key>")
config = client.empathic_voice.configs.get_config_version(
    id="id",
    version=1,
)
```

## Namespaces

This SDK contains the APIs for expression measurement, empathic voice and custom models. Even
if you do not plan on using more than one API to start, the SDK provides easy access in
case you find additional APIs in the future.

Each API is namespaced accordingly:

```python
from hume.client import HumeClient

client = HumeClient(
    api_key="YOUR_API_KEY",
)

client.expression_measurement. # APIs specific to Expression Measurement

client.emapthic_voice.         # APIs specific to Empathic Voice
```

## Exception Handling

All errors thrown by the SDK will be subclasses of [`ApiError`](./src/hume/core/api_error.py).

```python
import hume.client

try:
  client.expression_measurement.batch.get_job_predictions(...)
except hume.core.ApiError as e: # Handle all errors
  print(e.status_code)
  print(e.body)
```

## Pagination

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:

```python
import hume.client

client = HumeClient(
    api_key="YOUR_API_KEY",
)

for tool in client.empathic_voice.tools.list_tools():
  print(tool)
```

you could also iterate page-by-page:

```python
for page in client.empathic_voice.tools.list_tools().iter_pages():
  print(page.items)
```

or manually:

```python
pager = client.empathic_voice.tools.list_tools()
# First page
print(pager.items)
# Second page
pager = pager.next_page()
print(pager.items)
```

## WebSockets

We expose a websocket client for interacting with the EVI API as well as Expression Measurement.

When interacting with these clients, you can use them very similarly to how you'd use the common `websockets` library:

```python
from hume import StreamDataModels

client = AsyncHumeClient(api_key=os.getenv("HUME_API_KEY"))

async with client.expression_measurement.stream.connect(
    options={"config": StreamDataModels(...)}
) as hume_socket:
    print(await hume_socket.get_job_details())
```

The underlying connection, in this case `hume_socket`, will support intellisense/autocomplete for the different functions that are available on the socket!

### Advanced

#### Retries

The Hume SDK is instrumented with automatic retries with exponential backoff. A request will be
retried as long as the request is deemed retriable and the number of retry attempts has not grown larger
than the configured retry limit.

A request is deemed retriable when any of the following HTTP status codes is returned:

- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)

Use the `max_retries` request option to configure this behavior.

```python
from hume.client import HumeClient
from hume.core import RequestOptions

client = HumeClient(...)

# Override retries for a specific method
client.expression_measurement.batch.get_job_predictions(...,
    request_options=RequestOptions(max_retries=5)
)
```

#### Timeouts

By default, requests time out after 60 seconds. You can configure this with a
timeout option at the client or request level.

```python
from hume.client import HumeClient
from hume.core import RequestOptions

client = HumeClient(
    # All timeouts are 20 seconds
    timeout=20.0,
)

# Override timeout for a specific method
client.expression_measurement.batch.get_job_predictions(...,
    request_options=RequestOptions(timeout_in_seconds=20)
)
```

#### Custom HTTP client

You can override the httpx client to customize it for your use-case. Some common use-cases
include support for proxies and transports.

```python
import httpx

from hume.client import HumeClient

client = HumeClient(
    http_client=httpx.Client(
        proxies="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)
```

## Contributing

While we value open-source contributions to this SDK, this library is generated programmatically.

Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hume",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.9",
    "maintainer_email": null,
    "keywords": "hume, ai, evi, empathic, multimodal, expression, analysis, sentiment, voice, recognition, detection, emotion, interface, speech, audio, vision, expressive, embeddings, communication, learning",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d6/44/5c52938568704f5904b4e5c952894302b58af31040b6ea6375beca1e8cab/hume-0.7.5.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <img src=\"https://storage.googleapis.com/hume-public-logos/hume/hume-banner.png\">\n  <h1>Hume AI Python SDK</h1>\n\n  <p>\n    <strong>Integrate Hume APIs directly into your Python application</strong>\n  </p>\n\n  <br>\n  <div>\n    <a href=\"https://pypi.python.org/pypi/hume\"><img src=\"https://img.shields.io/pypi/v/hume\"></a>\n    <a href=\"https://buildwithfern.com/\"><img src=\"https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen\"></a>\n  </div>\n  <br>\n</div>\n\n## Migration Guide for Version 0.7.0 and Above\n\nWe've released version `0.7.0` of the SDK with significant architectural changes. This update introduces `AsyncHumeClient` and `HumeClient`, improves type safety and async support, and provides more granular configuration options. To help you transition, we've prepared a comprehensive migration guide:\n\n**[View the Migration Guide](https://github.com/HumeAI/hume-python-sdk/wiki/Python-SDK-Migration-Guide)**\n\nPlease review this guide before updating, as it covers breaking changes and provides examples for updating your code. Legacy functionality is preserved for backward compatibility. If you have any questions, please open an issue or contact our support team.\n\n## Documentation\n\nAPI reference documentation is available [here](https://dev.hume.ai/reference/).\n\n## Compatibility\n\nThe Hume Python SDK is compatible across several Python versions and operating systems.\n\n- For the Empathic Voice Interface, Python versions `3.9` through `3.11` are supported on macOS and Linux.\n\n- For Expression Measurement, Python versions `3.9` through `3.12` are supported on macOS, Linux, and Windows.\n\nBelow is a table which shows the version and operating system compatibilities by product:\n\n|                          | Python Version                | Operating System      |\n| ------------------------ | ----------------------------- | --------------------- |\n| Empathic Voice Interface | `3.9`, `3.10`, `3.11`         | macOS, Linux          |\n| Expression Measurement   | `3.9`, `3.10`, `3.11`, `3.12` | macOS, Linux, Windows |\n\n## Installation\n\n```sh\npip install hume\n# or\npoetry add hume\n```\n\n## Other Resources\n\n```python\nfrom hume.client import HumeClient\n\nclient = HumeClient(\n    api_key=\"YOUR_API_KEY\", # Defaults to HUME_API_KEY\n)\nclient.empathic_voice.configs.list_configs()\n```\n\n## Async Client\n\nThe SDK also exports an async client so that you can make non-blocking calls to our API.\n\n```python\nimport asyncio\n\nfrom hume.client import AsyncHumeClient\n\nclient = AsyncHumeClient(\n    api_key=\"YOUR_API_KEY\",\n)\n\nasync def main() -> None:\n    await client.empathic_voice.configs.list_configs()\n\nasyncio.run(main())\n```\n\n### Writing File\n\nWriting files with an async stream of bytes can be tricky in Python! `aiofiles` can simplify this some. For example,\nyou can download your job artifacts like so:\n\n```python\nimport aiofiles\n\nfrom hume import AsyncHumeClient\n\nclient = AsyncHumeClient()\nasync with aiofiles.open('artifacts.zip', mode='wb') as file:\n    async for chunk in client.expression_measurement.batch.get_job_artifacts(id=\"my-job-id\"):\n        await file.write(chunk)\n```\n\n## Legacy SDK\n\nIf you want to continue using the legacy SDKs, simply import them from\nthe `hume.legacy` module.\n\n```python\nfrom hume.legacy import HumeVoiceClient, VoiceConfig\n\nclient = HumeVoiceClient(\"<your-api-key>\")\nconfig = client.empathic_voice.configs.get_config_version(\n    id=\"id\",\n    version=1,\n)\n```\n\n## Namespaces\n\nThis SDK contains the APIs for expression measurement, empathic voice and custom models. Even\nif you do not plan on using more than one API to start, the SDK provides easy access in\ncase you find additional APIs in the future.\n\nEach API is namespaced accordingly:\n\n```python\nfrom hume.client import HumeClient\n\nclient = HumeClient(\n    api_key=\"YOUR_API_KEY\",\n)\n\nclient.expression_measurement. # APIs specific to Expression Measurement\n\nclient.emapthic_voice.         # APIs specific to Empathic Voice\n```\n\n## Exception Handling\n\nAll errors thrown by the SDK will be subclasses of [`ApiError`](./src/hume/core/api_error.py).\n\n```python\nimport hume.client\n\ntry:\n  client.expression_measurement.batch.get_job_predictions(...)\nexcept hume.core.ApiError as e: # Handle all errors\n  print(e.status_code)\n  print(e.body)\n```\n\n## Pagination\n\nPaginated 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:\n\n```python\nimport hume.client\n\nclient = HumeClient(\n    api_key=\"YOUR_API_KEY\",\n)\n\nfor tool in client.empathic_voice.tools.list_tools():\n  print(tool)\n```\n\nyou could also iterate page-by-page:\n\n```python\nfor page in client.empathic_voice.tools.list_tools().iter_pages():\n  print(page.items)\n```\n\nor manually:\n\n```python\npager = client.empathic_voice.tools.list_tools()\n# First page\nprint(pager.items)\n# Second page\npager = pager.next_page()\nprint(pager.items)\n```\n\n## WebSockets\n\nWe expose a websocket client for interacting with the EVI API as well as Expression Measurement.\n\nWhen interacting with these clients, you can use them very similarly to how you'd use the common `websockets` library:\n\n```python\nfrom hume import StreamDataModels\n\nclient = AsyncHumeClient(api_key=os.getenv(\"HUME_API_KEY\"))\n\nasync with client.expression_measurement.stream.connect(\n    options={\"config\": StreamDataModels(...)}\n) as hume_socket:\n    print(await hume_socket.get_job_details())\n```\n\nThe underlying connection, in this case `hume_socket`, will support intellisense/autocomplete for the different functions that are available on the socket!\n\n### Advanced\n\n#### Retries\n\nThe Hume SDK is instrumented with automatic retries with exponential backoff. A request will be\nretried as long as the request is deemed retriable and the number of retry attempts has not grown larger\nthan the configured retry limit.\n\nA request is deemed retriable when any of the following HTTP status codes is returned:\n\n- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)\n- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)\n- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)\n- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)\n\nUse the `max_retries` request option to configure this behavior.\n\n```python\nfrom hume.client import HumeClient\nfrom hume.core import RequestOptions\n\nclient = HumeClient(...)\n\n# Override retries for a specific method\nclient.expression_measurement.batch.get_job_predictions(...,\n    request_options=RequestOptions(max_retries=5)\n)\n```\n\n#### Timeouts\n\nBy default, requests time out after 60 seconds. You can configure this with a\ntimeout option at the client or request level.\n\n```python\nfrom hume.client import HumeClient\nfrom hume.core import RequestOptions\n\nclient = HumeClient(\n    # All timeouts are 20 seconds\n    timeout=20.0,\n)\n\n# Override timeout for a specific method\nclient.expression_measurement.batch.get_job_predictions(...,\n    request_options=RequestOptions(timeout_in_seconds=20)\n)\n```\n\n#### Custom HTTP client\n\nYou can override the httpx client to customize it for your use-case. Some common use-cases\ninclude support for proxies and transports.\n\n```python\nimport httpx\n\nfrom hume.client import HumeClient\n\nclient = HumeClient(\n    http_client=httpx.Client(\n        proxies=\"http://my.test.proxy.example.com\",\n        transport=httpx.HTTPTransport(local_address=\"0.0.0.0\"),\n    ),\n)\n```\n\n## Contributing\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically.\n\nAdditions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!\n\nOn the other hand, contributions to the README are always very welcome!\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python SDK for Hume AI",
    "version": "0.7.5",
    "project_urls": null,
    "split_keywords": [
        "hume",
        " ai",
        " evi",
        " empathic",
        " multimodal",
        " expression",
        " analysis",
        " sentiment",
        " voice",
        " recognition",
        " detection",
        " emotion",
        " interface",
        " speech",
        " audio",
        " vision",
        " expressive",
        " embeddings",
        " communication",
        " learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c401a7c1d633d2dee7cfd1699fbb08f441371116f602e033cfc13d1d658362bb",
                "md5": "ef5ef5f0a2986c9edffaeaed86ce837c",
                "sha256": "8d4cc03af17eccf6b1668765b04e2912e573ab57072c003bcc360ee1b8da1717"
            },
            "downloads": -1,
            "filename": "hume-0.7.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ef5ef5f0a2986c9edffaeaed86ce837c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.9",
            "size": 296940,
            "upload_time": "2024-12-04T00:30:22",
            "upload_time_iso_8601": "2024-12-04T00:30:22.243685Z",
            "url": "https://files.pythonhosted.org/packages/c4/01/a7c1d633d2dee7cfd1699fbb08f441371116f602e033cfc13d1d658362bb/hume-0.7.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6445c52938568704f5904b4e5c952894302b58af31040b6ea6375beca1e8cab",
                "md5": "f39b77e17ba8d18c5a2928f52041a718",
                "sha256": "917bdfad64f88083d8ebfff7debc6d6903a67e21f0ecf36c7c46e89a202df56e"
            },
            "downloads": -1,
            "filename": "hume-0.7.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f39b77e17ba8d18c5a2928f52041a718",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.9",
            "size": 122828,
            "upload_time": "2024-12-04T00:30:23",
            "upload_time_iso_8601": "2024-12-04T00:30:23.755308Z",
            "url": "https://files.pythonhosted.org/packages/d6/44/5c52938568704f5904b4e5c952894302b58af31040b6ea6375beca1e8cab/hume-0.7.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-04 00:30:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "hume"
}
        
Elapsed time: 0.38810s