Skip to content

Commit 98cb49b

Browse files
s0h3ylAssemblyAI
andauthored
fix: handle multiple words when using .word_search(...) (#11)
Co-authored-by: AssemblyAI <[email protected]>
1 parent 82effe8 commit 98cb49b

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

assemblyai/api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import BinaryIO, List, Optional
2+
from urllib.parse import urlencode
23

34
import httpx
45

@@ -142,9 +143,11 @@ def word_search(
142143
) -> types.WordSearchMatchResponse:
143144
response = client.get(
144145
f"/transcript/{transcript_id}/word-search",
145-
params={
146-
"words": words,
147-
},
146+
params=urlencode(
147+
{
148+
"words": ",".join(words),
149+
}
150+
),
148151
)
149152

150153
if response.status_code != httpx.codes.ok:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name="assemblyai",
10-
version="0.5.0",
10+
version="0.5.1",
1111
description="AssemblyAI Python SDK",
1212
author="AssemblyAI",
1313
author_email="[email protected]",

tests/unit/test_transcript.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Any, Dict, List
2+
from urllib.parse import urlencode
23

34
import httpx
45
import pytest
@@ -114,9 +115,12 @@ def test_word_search_succeeds(httpx_mock: HTTPXMock):
114115
factories.WordSearchMatchResponseFactory
115116
)()
116117

118+
search_words = {
119+
"words": ",".join(["test", "me"]),
120+
}
117121
# mock the specific endpoints
118122
url = httpx.URL(
119-
f"{aai.settings.base_url}/transcript/{transcript.id}/word-search?words=test",
123+
f"{aai.settings.base_url}/transcript/{transcript.id}/word-search?{urlencode(search_words)}",
120124
)
121125

122126
httpx_mock.add_response(
@@ -127,7 +131,7 @@ def test_word_search_succeeds(httpx_mock: HTTPXMock):
127131
)
128132

129133
# mimic the SDK call
130-
matches = transcript.word_search(words=["test"])
134+
matches = transcript.word_search(words=["test", "me"])
131135

132136
# check integrity of the response
133137

0 commit comments

Comments
 (0)