Skip to content

Commit fe7cbaf

Browse files
Voice SDK (#117)
1 parent 6ab00b9 commit fe7cbaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1968
-593
lines changed

.github/workflows/ci.yaml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
with:
2828
python-version: ${{ matrix.python-version }}
2929

30+
- name: Install system dependencies
31+
shell: bash
32+
run: |
33+
sudo apt-get --yes update
34+
sudo apt-get --yes install ffmpeg
35+
3036
- name: Install Python dependencies
3137
shell: bash
3238
run: |
@@ -57,7 +63,7 @@ jobs:
5763
env:
5864
HUME_DEV_API_KEY: ${{ secrets.HUME_DEV_API_KEY }}
5965
run: |
60-
poetry run pytest tests --cov=hume --cov-report=html --cov-report=xml --cov-branch -m "not service"
66+
poetry run pytest tests --cov=hume --cov-report=html --cov-report=xml --cov-branch -m "(not service) and (not microphone)"
6167
6268
- name: Run pydocstyle
6369
shell: bash
@@ -84,13 +90,24 @@ jobs:
8490
build-service:
8591
runs-on: ubuntu-latest
8692

93+
strategy:
94+
matrix:
95+
python-version:
96+
- "3.10"
97+
8798
steps:
8899
- uses: actions/checkout@v2
89100

90-
- name: Python 3.10 Setup
101+
- name: Python ${{ matrix.python-version }} Setup
91102
uses: actions/setup-python@v2
92103
with:
93-
python-version: "3.10"
104+
python-version: ${{ matrix.python-version }}
105+
106+
- name: Install system dependencies
107+
shell: bash
108+
run: |
109+
sudo apt-get --yes update
110+
sudo apt-get --yes install ffmpeg
94111
95112
- name: Install Python dependencies
96113
shell: bash
@@ -124,3 +141,40 @@ jobs:
124141
shell: bash
125142
run: |
126143
poetry run covcheck coverage.xml --config pyproject.toml --group service
144+
145+
build-microphone:
146+
runs-on: ubuntu-latest
147+
148+
strategy:
149+
matrix:
150+
python-version:
151+
- "3.10"
152+
153+
steps:
154+
- uses: actions/checkout@v2
155+
156+
- name: Python ${{ matrix.python-version }} Setup
157+
uses: actions/setup-python@v2
158+
with:
159+
python-version: ${{ matrix.python-version }}
160+
161+
- name: Install system dependencies
162+
shell: bash
163+
run: |
164+
sudo apt-get --yes update
165+
sudo apt-get --yes install libasound2-dev libportaudio2 ffmpeg
166+
167+
- name: Install Python dependencies
168+
shell: bash
169+
run: |
170+
pip install poetry
171+
if [ -d /poetryenvs ]; then rm -rf ~/poetryenvs; fi
172+
poetry config virtualenvs.path ~/poetryenvs
173+
poetry install -E microphone
174+
175+
- name: Run pytest
176+
shell: bash
177+
env:
178+
HUME_DEV_API_KEY: ${{ secrets.HUME_DEV_API_KEY }}
179+
run: |
180+
poetry run pytest tests --cov=hume --cov-report=html --cov-report=xml --cov-branch -m microphone

.vscode/settings.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
"[markdown]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
44
"[python]": { "editor.defaultFormatter": "ms-python.black-formatter" },
55
"[toml]": { "editor.defaultFormatter": "tamasfe.even-better-toml" },
6-
"editor.codeActionsOnSave": {
7-
"source.organizeImports": "explicit"
8-
},
6+
"editor.codeActionsOnSave": { "source.organizeImports": "explicit" },
97
"black-formatter.args": ["--config", "pyproject.toml"],
108
"flake8.args": ["--max-line-length", "120"],
119
"editor.defaultFormatter": "esbenp.prettier-vscode",
1210
"editor.detectIndentation": true,
13-
"editor.formatOnSave": true,
11+
// "editor.formatOnSave": true,
1412
"editor.insertSpaces": true,
1513
"editor.rulers": [120],
1614
"isort.args": ["--settings-file", "pyproject.toml"],
@@ -19,5 +17,6 @@
1917
"pylint.path": ["pylint"],
2018
"pylint.args": ["--rcfile", "pyproject.toml"],
2119
"python.analysis.extraPaths": ["tests"],
22-
"python.testing.cwd": "tests"
20+
"python.testing.cwd": "tests",
21+
"cSpell.words": ["agen", "cffi", "deepgram", "indata", "samplerate", "simpleaudio", "sounddevice"]
2322
}

docs/batch/batch-job-details.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: hume._batch.batch_job_details.BatchJobDetails
1+
::: hume._measurement.batch.batch_job_details.BatchJobDetails

docs/batch/batch-job-state.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: hume._batch.batch_job_state.BatchJobState
1+
::: hume._measurement.batch.batch_job_state.BatchJobState

docs/batch/batch-job-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: hume._batch.batch_job_status.BatchJobStatus
1+
::: hume._measurement.batch.batch_job_status.BatchJobStatus

docs/batch/batch-job.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: hume._batch.batch_job.BatchJob
1+
::: hume._measurement.batch.batch_job.BatchJob

docs/batch/hume-batch-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: hume._batch.hume_batch_client.HumeBatchClient
1+
::: hume._measurement.batch.hume_batch_client.HumeBatchClient

docs/batch/transcription-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: hume._batch.transcription_config.TranscriptionConfig
1+
::: hume._measurement.batch.transcription_config.TranscriptionConfig

docs/index.md

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,106 @@ Basic installation:
1212
pip install hume
1313
```
1414

15-
WebSocket and streaming features can be enabled with:
15+
## Requirements
16+
17+
To use the basic functionality of `HumeVoiceClient`, `HumeBatchClient` or `HumeStreamClient` there are no additional system dependencies, however using the audio playback functionality of the EVI `MicrophoneInterface` may require a few extra dependencies depending on your operating system.
18+
19+
### Linux
20+
21+
- `libasound2-dev`
22+
- `libportaudio2`
23+
24+
You can install these dependencies with:
1625

1726
```bash
18-
pip install "hume[stream]"
27+
sudo apt-get --yes update
28+
sudo apt-get --yes install libasound2-dev libportaudio2
1929
```
2030

2131
## Basic Usage
2232

2333
Jupyter example notebooks can be found in the [Python SDK GitHub repo](https://github.com/HumeAI/hume-python-sdk/tree/main/examples/README.md).
2434

35+
### Stream an EVI chat session
36+
37+
Start a new session using your device's microphone:
38+
39+
> Note: to use audio playback functionality in the MicrophoneInterface run `pip install hume[microphone]`
40+
41+
```python
42+
import asyncio
43+
44+
from hume import HumeVoiceClient, MicrophoneInterface
45+
46+
async def main() -> None:
47+
client = HumeVoiceClient("<your-api-key>")
48+
49+
async with client.connect() as socket:
50+
await MicrophoneInterface.start(socket)
51+
52+
asyncio.run(main())
53+
```
54+
55+
Using a custom voice config:
56+
57+
```py
58+
import asyncio
59+
60+
from hume import HumeVoiceClient, MicrophoneInterface
61+
62+
async def main() -> None:
63+
client = HumeVoiceClient("<your-api-key>")
64+
65+
async with client.connect(config_id="<your-config-id>") as socket:
66+
await MicrophoneInterface.start(socket)
67+
68+
asyncio.run(main())
69+
```
70+
71+
### Managing voice configs
72+
73+
Create a new config:
74+
75+
```py
76+
from hume import HumeVoiceClient, VoiceConfig
77+
78+
client = HumeVoiceClient("<your-api-key">)
79+
config: VoiceConfig = client.create_config(
80+
name=f"silly-poet",
81+
prompt="you are a silly poet",
82+
)
83+
print("Created config: ", config.id)
84+
```
85+
86+
Get an existing config:
87+
88+
```py
89+
from hume import HumeVoiceClient
90+
91+
client = HumeVoiceClient("<your-api-key">)
92+
config = client.get_config("<YOUR CONFIG ID>")
93+
print("Fetched config: ", config.name)
94+
```
95+
96+
List all your configs:
97+
98+
```py
99+
from hume import HumeVoiceClient
100+
101+
client = HumeVoiceClient("<your-api-key">)
102+
for config in client.iter_configs():
103+
print(f"- {config.name} ({config.id})")
104+
```
105+
106+
Delete a config:
107+
108+
```py
109+
from hume import HumeVoiceClient
110+
111+
client = HumeVoiceClient("<your-api-key">)
112+
client.delete_config("<YOUR CONFIG ID>")
113+
```
114+
25115
### Submit a new batch job
26116

27117
> Note: Your personal API key can be found in the profile section of [beta.hume.ai](https://beta.hume.ai)
@@ -64,8 +154,6 @@ print(job)
64154

65155
### Stream predictions over a WebSocket
66156

67-
> Note: `pip install "hume[stream]"` is required to use WebSocket features
68-
69157
```python
70158
import asyncio
71159

docs/stream/hume-stream-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
::: hume._stream.hume_stream_client.HumeStreamClient
1+
::: hume._measurement.stream.hume_stream_client.HumeStreamClient

0 commit comments

Comments
 (0)