Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ transcriber, which owns the connection pool.
a worker thread. The request sets `Content-Length` when the size is known. A large file
never blocks the loop and never loads fully into memory.

**LeMUR** is sync-only. An `AsyncTranscript` works as a `LemurSource`, but the LeMUR call
blocks. Run it off the loop, for example with `asyncio.to_thread`.

## Sync transcription (pre-recorded, single request)

`SyncTranscriber` posts a whole audio file and returns the finished transcript in one
Expand Down Expand Up @@ -167,7 +164,7 @@ pass a path/bytes or use `Transcriber` for URL ingestion.
```python
config = aai.SyncTranscriptionConfig(
prompt="Transcribe verbatim. Preserve disfluencies.", # max 4096 chars
keyterms_prompt=["AssemblyAI", "Lemur", "U3-Pro"], # max 2048 chars total
keyterms_prompt=["AssemblyAI", "Universal", "U3-Pro"], # max 2048 chars total
language_codes=["es"], # or e.g. ["en", "es"] for multilingual; defaults to English
)
result = aai.SyncTranscriber().transcribe("./call.wav", config=config)
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ aai.settings.api_key = "<YOUR_API_KEY>"

config = aai.SyncTranscriptionConfig(
prompt="Transcribe verbatim. Preserve disfluencies.", # max 4096 chars
keyterms_prompt=["AssemblyAI", "Lemur", "U3-Pro"], # max 2048 chars total
keyterms_prompt=["AssemblyAI", "Universal", "U3-Pro"], # max 2048 chars total
conversation_context=[
# prior turns from the same conversation, oldest first
"I'd like to book a flight to Denver.",
Expand Down Expand Up @@ -1259,7 +1259,7 @@ aai.settings.polling_interval = 10.0

## Playground

Visit our Playground to try our all of our Speech AI models and LeMUR for free:
Visit our Playground to try our all of our Speech AI models for free:

- [Playground](https://www.assemblyai.com/dashboard/playground/)

Expand Down Expand Up @@ -1355,8 +1355,6 @@ Notes:
work at `max_concurrency`, which defaults to 8.
- Neither group method drops a failure. Either the first error is raised, or you pass
`return_failures=True` and get `(transcripts, errors)`.
- LeMUR is sync-only. An `AsyncTranscript` works as a `LemurSource`, but the LeMUR call
blocks. Run it in a thread, for example with `asyncio.to_thread`.

For real-time streaming, use `assemblyai.streaming.v3.AsyncStreamingClient`.

Expand Down
32 changes: 0 additions & 32 deletions assemblyai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .__version__ import __version__
from .async_client import AsyncClient
from .client import Client
from .lemur import Lemur
from .prerecorded.v2 import AsyncTranscriber, AsyncTranscript
from .sync import SyncTranscriber
from .transcriber import Transcriber, Transcript, TranscriptGroup
Expand All @@ -25,21 +24,6 @@
KeytermsPromptOptions,
LanguageCode,
LanguageDetectionOptions,
LemurActionItemsResponse,
LemurError,
LemurModel,
LemurPurgeRequest,
LemurPurgeResponse,
LemurQuestion,
LemurQuestionAnswer,
LemurQuestionResponse,
LemurSource,
LemurSourceType,
LemurStringResponse,
LemurSummaryResponse,
LemurTaskResponse,
LemurTranscriptSource,
LemurUsage,
ListTranscriptParameters,
ListTranscriptResponse,
PageDetails,
Expand Down Expand Up @@ -114,22 +98,6 @@
"KeytermsPromptOptions",
"LanguageCode",
"LanguageDetectionOptions",
"Lemur",
"LemurActionItemsResponse",
"LemurError",
"LemurModel",
"LemurPurgeRequest",
"LemurPurgeResponse",
"LemurSource",
"LemurSourceType",
"LemurTranscriptSource",
"LemurQuestion",
"LemurQuestionAnswer",
"LemurQuestionResponse",
"LemurStringResponse",
"LemurSummaryResponse",
"LemurTaskResponse",
"LemurUsage",
"ListTranscriptParameters",
"ListTranscriptResponse",
"PageDetails",
Expand Down
2 changes: 1 addition & 1 deletion assemblyai/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.65.00"
__version__ = "0.66.00"
138 changes: 1 addition & 137 deletions assemblyai/api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from typing import BinaryIO, Optional, Union
from typing import BinaryIO, Union

import httpx

from . import types

ENDPOINT_UPLOAD = "/v2/upload"
ENDPOINT_LEMUR_BASE = "/lemur/v3"
ENDPOINT_LEMUR = f"{ENDPOINT_LEMUR_BASE}/generate"


def _get_error_message(response: httpx.Response) -> str:
Expand Down Expand Up @@ -54,140 +52,6 @@ def upload_file(
return response.json()["upload_url"]


def lemur_question(
client: httpx.Client,
request: types.LemurQuestionRequest,
http_timeout: Optional[float],
) -> types.LemurQuestionResponse:
response = client.post(
f"{ENDPOINT_LEMUR}/question-answer",
json=request.dict(
exclude_none=True,
),
timeout=http_timeout,
)

if response.status_code != httpx.codes.OK:
raise types.LemurError(
f"failed to call Lemur questions: {_get_error_message(response)}",
response.status_code,
)

return types.LemurQuestionResponse.parse_obj(response.json())


def lemur_summarize(
client: httpx.Client,
request: types.LemurSummaryRequest,
http_timeout: Optional[float],
) -> types.LemurSummaryResponse:
response = client.post(
f"{ENDPOINT_LEMUR}/summary",
json=request.dict(
exclude_none=True,
),
timeout=http_timeout,
)

if response.status_code != httpx.codes.OK:
raise types.LemurError(
f"failed to call Lemur summary: {_get_error_message(response)}",
response.status_code,
)

return types.LemurSummaryResponse.parse_obj(response.json())


def lemur_action_items(
client: httpx.Client,
request: types.LemurActionItemsRequest,
http_timeout: Optional[float],
) -> types.LemurActionItemsResponse:
response = client.post(
f"{ENDPOINT_LEMUR}/action-items",
json=request.dict(
exclude_none=True,
),
timeout=http_timeout,
)

if response.status_code != httpx.codes.OK:
raise types.LemurError(
f"failed to call Lemur action items: {_get_error_message(response)}",
response.status_code,
)

return types.LemurActionItemsResponse.parse_obj(response.json())


def lemur_task(
client: httpx.Client,
request: types.LemurTaskRequest,
http_timeout: Optional[float],
) -> types.LemurTaskResponse:
response = client.post(
f"{ENDPOINT_LEMUR}/task",
json=request.dict(
exclude_none=True,
),
timeout=http_timeout,
)

if response.status_code != httpx.codes.OK:
raise types.LemurError(
f"failed to call Lemur task: {_get_error_message(response)}",
response.status_code,
)

return types.LemurTaskResponse.parse_obj(response.json())


def lemur_purge_request_data(
client: httpx.Client,
request: types.LemurPurgeRequest,
http_timeout: Optional[float],
) -> types.LemurPurgeResponse:
response = client.delete(
f"{ENDPOINT_LEMUR_BASE}/{request.request_id}",
timeout=http_timeout,
)

if response.status_code != httpx.codes.OK:
raise types.LemurError(
f"Failed to purge LeMUR request data for provided request ID: {request.request_id}. Error: {_get_error_message(response)}",
response.status_code,
)

return types.LemurPurgeResponse.parse_obj(response.json())


def lemur_get_response_data(
client: httpx.Client,
request_id: str,
http_timeout: Optional[float],
) -> Union[
types.LemurStringResponse,
types.LemurQuestionResponse,
]:
response = client.get(
f"{ENDPOINT_LEMUR_BASE}/{request_id}",
timeout=http_timeout,
)

if response.status_code != httpx.codes.OK:
raise types.LemurError(
f"Failed to get LeMUR response data for provided request ID: {request_id}. Error: {_get_error_message(response)}",
response.status_code,
)

json_data = response.json()

if isinstance(json_data.get("response"), list):
return types.LemurQuestionResponse.parse_obj(json_data)

return types.LemurStringResponse.parse_obj(json_data)


# Canonical location for the prerecorded transcript endpoints is
# ``assemblyai.prerecorded.v2.api``.
from .prerecorded.v2.api import ( # noqa: E402, F401
Expand Down
Loading
Loading