Skip to content

Commit 254582b

Browse files
committed
fix: set default polling interval to 3s
GitOrigin-RevId: 792a210f83e055f49b2404e40d902925aadf5a5b
1 parent 1e227e6 commit 254582b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ questions = [
222222

223223
results = transcript.lemur.question(questions)
224224

225-
for result in result:
225+
for result in results:
226226
print(f"Question: {result.question}")
227227
print(f"Answer: {result.answer}")
228228
```
@@ -531,3 +531,13 @@ The synchronous approach halts the application's flow until the transcription ha
531531
The asynchronous approach allows the application to continue running while the transcription is being processed. The caller receives a [`concurrent.futures.Future`](https://docs.python.org/3/library/concurrent.futures.html) object which can be used to check the status of the transcription at a later time.
532532

533533
You can identify those two approaches by the `_async` suffix in the `Transcriber`'s method name (e.g. `transcribe` vs `transcribe_async`).
534+
535+
## Polling Intervals
536+
537+
By default we poll the `Transcript`'s status each `3s`. In case you would like to adjust that interval:
538+
539+
```python
540+
import assemblyai as aai
541+
542+
aai.settings.polling_interval = 1.0
543+
```

assemblyai/transcriber.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def wait_for_completion(self) -> Self:
7777
):
7878
break
7979

80-
time.sleep(3)
80+
time.sleep(self._client.settings.polling_interval)
8181

8282
return self
8383

assemblyai/types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from enum import Enum
22
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
33

4-
from pydantic import BaseModel, BaseSettings, Extra
4+
from pydantic import BaseModel, BaseSettings, Extra, Field
55
from typing_extensions import Self
66

77

@@ -37,6 +37,9 @@ class Settings(BaseSettings):
3737
base_url: str = "https://api.assemblyai.com/v2"
3838
"The base URL for the AssemblyAI API"
3939

40+
polling_interval: float = Field(default=3.0, gte=0.1)
41+
"The default polling interval for long-running requests (e.g. polling the `Transcript`'s status)"
42+
4043
class Config:
4144
env_prefix = "assemblyai_"
4245

0 commit comments

Comments
 (0)