Skip to content

Commit 85480cb

Browse files
Remove sliding_window, add granularity for language (#41)
1 parent 51657cb commit 85480cb

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

hume/_batch/hume_batch_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,15 @@ def submit_prosody(
151151
def submit_language(
152152
self,
153153
urls: List[str],
154-
sliding_window: Optional[bool] = None,
154+
granularity: Optional[str] = None,
155155
identify_speakers: Optional[bool] = None,
156156
) -> BatchJob:
157157
"""Submit a new job for language emotion.
158158
159159
Args:
160160
urls (List[str]): URLs to process.
161-
sliding_window (Optional[float]): Whether to generate predictions for each word in the text or
162-
for the entire text in aggregate.
161+
granularity (Optional[str]): The granularity at which to generate predictions.
162+
Values are `word`, `sentence`, or `passage`. Default value is `word`.
163163
identify_speakers (Optional[bool]): Whether to return identifiers for speakers over time.
164164
If true, unique identifiers will be assigned to spoken words to differentiate different speakers.
165165
If false, all speakers will be tagged with an "unknown" ID.
@@ -171,7 +171,7 @@ def submit_language(
171171
BatchJob: Batch job.
172172
"""
173173
config = LanguageConfig(
174-
sliding_window=sliding_window,
174+
granularity=granularity,
175175
identify_speakers=identify_speakers,
176176
)
177177
return self._submit(urls, [config])

hume/_common/config/language_config.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ class LanguageConfig(JobConfigBase["LanguageConfig"]):
1111
def __init__(
1212
self,
1313
*,
14-
sliding_window: Optional[float] = None,
14+
granularity: Optional[str] = None,
1515
identify_speakers: Optional[bool] = None,
1616
):
1717
"""Construct a `LanguageConfig`.
1818
1919
Args:
20-
sliding_window (Optional[float]): Whether to generate predictions for each word in the text or
21-
for the entire text in aggregate.
20+
granularity (Optional[str]): The granularity at which to generate predictions.
21+
Values are `word`, `sentence`, or `passage`. Default value is `word`.
2222
identify_speakers (Optional[bool]): Whether to return identifiers for speakers over time.
2323
If true, unique identifiers will be assigned to spoken words to differentiate different speakers.
2424
If false, all speakers will be tagged with an "unknown" ID.
2525
"""
26-
self.sliding_window = sliding_window
26+
self.granularity = granularity
2727
self.identify_speakers = identify_speakers
2828

2929
@classmethod
@@ -42,7 +42,7 @@ def serialize(self) -> Dict[str, Any]:
4242
Dict[str, Any]: Serialized `LanguageConfig` object.
4343
"""
4444
return {
45-
"sliding_window": self.sliding_window,
45+
"granularity": self.granularity,
4646
"identify_speakers": self.identify_speakers,
4747
}
4848

@@ -57,6 +57,6 @@ def deserialize(cls, request_dict: Dict[str, Any]) -> "LanguageConfig":
5757
LanguageConfig: Deserialized `LanguageConfig` object.
5858
"""
5959
return cls(
60-
sliding_window=request_dict.get("sliding_window"),
60+
granularity=request_dict.get("granularity"),
6161
identify_speakers=request_dict.get("identify_speakers"),
6262
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ license = "Proprietary"
2525
name = "hume"
2626
readme = "README.md"
2727
repository = "https://github.com/HumeAI/hume-python-sdk"
28-
version = "0.1.6"
28+
version = "0.1.7"
2929

3030
[tool.poetry.dependencies]
3131
python = ">=3.8.1,<4"

tests/batch/test_batch_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ def test_language(self, batch_client: HumeBatchClient):
7474
mock_url = "mock-url"
7575
job = batch_client.submit_language(
7676
[mock_url],
77-
sliding_window=False,
77+
granularity="word",
7878
identify_speakers=True,
7979
)
8080
assert isinstance(job, BatchJob)
8181
assert job.id == "mock-job-id"
8282
batch_client.start_job.assert_called_once_with({
8383
"models": {
8484
"language": {
85-
"sliding_window": False,
85+
"granularity": "word",
8686
"identify_speakers": True,
8787
},
8888
},

tests/stream/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def mock_send(message: str) -> None:
4242
"models": {
4343
"language": {
4444
"identify_speakers": None,
45-
"sliding_window": None,
45+
"granularity": None,
4646
},
4747
},
4848
}

0 commit comments

Comments
 (0)