Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ print(result.response)
```python
import assemblyai as aai

# Create a transcript and a corresponding LeMUR request that may contain senstive information.
# Create a transcript and a corresponding LeMUR request that may contain sensitive information.
transcriber = aai.Transcriber()
transcript_group = transcriber.transcribe_group(
[
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.54.1"
__version__ = "0.55.0"
2 changes: 1 addition & 1 deletion assemblyai/streaming/v3/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __str__(self):
class StreamingParameters(StreamingSessionParameters):
sample_rate: int
encoding: Optional[Encoding] = None
speech_model: Optional[SpeechModel] = None
speech_model: SpeechModel
language_detection: Optional[bool] = None
inactivity_timeout: Optional[int] = None
webhook_url: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion assemblyai/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def config(self) -> types.TranscriptionConfig:
"Returns the configuration from the internal Transcript object"
if self.transcript is None:
raise ValueError(
"Canot access the configuration. The internal Transcript object is None."
"Cannot access the configuration. The internal Transcript object is None."
)

return types.TranscriptionConfig(
Expand Down
6 changes: 3 additions & 3 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def __getattribute__(self, item):
]
if item in languages:
warn(
"LanuageCode Enum is deprecated and will be removed in 1.0.0. Use a string instead.",
"LanguageCode Enum is deprecated and will be removed in 1.0.0. Use a string instead.",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -165,7 +165,7 @@ def __getattribute__(self, item):

class LanguageCode(str, Enum, metaclass=DeprecatedLanguageCodeMeta):
"""
DeprecationWarning: LanuageCode is deprecated and will be removed in 1.0.0. Use a string instead.
DeprecationWarning: LanguageCode is deprecated and will be removed in 1.0.0. Use a string instead.

Supported languages for transcribing audio.
"""
Expand Down Expand Up @@ -1780,7 +1780,7 @@ def set_custom_spelling(
Args:
replacement: A dictionary that contains the replacement object (see below example).
For each key-value pair, the key is the 'to' field, and the value is the 'from' field.
override: If `True` `replacement` gets overriden with the given `replacement` argument, otherwise merged.
override: If `True` `replacement` gets overridden with the given `replacement` argument, otherwise merged.

Example:
```
Expand Down
30 changes: 27 additions & 3 deletions tests/unit/test_streaming.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from urllib.parse import urlencode

import pytest
from pydantic import ValidationError
from pytest_mock import MockFixture

from assemblyai.streaming.v3 import (
Expand Down Expand Up @@ -43,11 +45,15 @@ def mocked_websocket_connect(
options = StreamingClientOptions(api_key="test", api_host="api.example.com")
client = StreamingClient(options)

params = StreamingParameters(sample_rate=16000)
params = StreamingParameters(
sample_rate=16000,
speech_model=SpeechModel.universal_streaming_english,
)
client.connect(params)

expected_headers = {
"sample_rate": params.sample_rate,
"speech_model": str(params.speech_model),
}

assert actual_url == f"wss://api.example.com/v3/ws?{urlencode(expected_headers)}"
Expand Down Expand Up @@ -81,11 +87,15 @@ def mocked_websocket_connect(
options = StreamingClientOptions(token="test", api_host="api.example.com")
client = StreamingClient(options)

params = StreamingParameters(sample_rate=16000)
params = StreamingParameters(
sample_rate=16000,
speech_model=SpeechModel.universal_streaming_english,
)
client.connect(params)

expected_headers = {
"sample_rate": params.sample_rate,
"speech_model": str(params.speech_model),
}

assert actual_url == f"wss://api.example.com/v3/ws?{urlencode(expected_headers)}"
Expand Down Expand Up @@ -121,6 +131,7 @@ def mocked_websocket_connect(

params = StreamingParameters(
sample_rate=16000,
speech_model=SpeechModel.universal_streaming_english,
end_of_turn_confidence_threshold=0.5,
min_end_of_turn_silence_when_confident=2000,
max_turn_silence=3000,
Expand All @@ -133,6 +144,7 @@ def mocked_websocket_connect(
"min_end_of_turn_silence_when_confident": params.min_end_of_turn_silence_when_confident,
"max_turn_silence": params.max_turn_silence,
"sample_rate": params.sample_rate,
"speech_model": str(params.speech_model),
}

assert actual_url == f"wss://api.example.com/v3/ws?{urlencode(expected_headers)}"
Expand Down Expand Up @@ -167,7 +179,10 @@ def mocked_websocket_connect(
options = StreamingClientOptions(api_key="test", api_host="api.example.com")
client = StreamingClient(options)

params = StreamingParameters(sample_rate=16000)
params = StreamingParameters(
sample_rate=16000,
speech_model=SpeechModel.universal_streaming_english,
)
client.connect(params)
client.stream(b"test audio data")

Expand Down Expand Up @@ -200,6 +215,7 @@ def mocked_websocket_connect(

params = StreamingParameters(
sample_rate=16000,
speech_model=SpeechModel.universal_streaming_english,
webhook_url="https://example.com/webhook",
webhook_auth_header_name="X-Webhook-Secret",
webhook_auth_header_value="my-secret",
Expand All @@ -209,6 +225,7 @@ def mocked_websocket_connect(

expected_params = {
"sample_rate": params.sample_rate,
"speech_model": str(params.speech_model),
"webhook_url": params.webhook_url,
"webhook_auth_header_name": params.webhook_auth_header_name,
"webhook_auth_header_value": params.webhook_auth_header_value,
Expand Down Expand Up @@ -287,6 +304,7 @@ def mocked_websocket_connect(

params = StreamingParameters(
sample_rate=16000,
speech_model=SpeechModel.universal_streaming_english,
speaker_labels=True,
max_speakers=3,
)
Expand Down Expand Up @@ -355,6 +373,12 @@ def test_turn_event_without_speaker_label():
assert event.speaker_label is None


def test_speech_model_required():
"""Test that omitting speech_model raises a validation error."""
with pytest.raises(ValidationError):
StreamingParameters(sample_rate=16000)


def test_speech_started_event():
"""Test SpeechStarted event parsing (u3-rt-pro only)"""
data = {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_upload_file_fails(httpx_mock: HTTPXMock):
with pytest.raises(aai.TranscriptError) as excinfo:
aai.Transcriber().upload_file(os.urandom(10))

# check wheter the TranscriptError contains the specified error message
# check whether the TranscriptError contains the specified error message
assert returned_error_message in str(excinfo.value)
assert httpx.codes.INTERNAL_SERVER_ERROR == excinfo.value.status_code

Expand Down Expand Up @@ -148,7 +148,7 @@ def test_submit_file_fails_due_api_error(httpx_mock: HTTPXMock):
with pytest.raises(aai.TranscriptError) as excinfo:
transcriber.transcribe("audio.wav")

# check wheter the Exception contains the specified error message
# check whether the Exception contains the specified error message
assert "something went wrong" in str(excinfo.value)
assert httpx.codes.INTERNAL_SERVER_ERROR == excinfo.value.status_code

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def test_get_by_id_fails(httpx_mock: HTTPXMock):
with pytest.raises(aai.TranscriptError) as excinfo:
aai.Transcript.get_by_id(test_id)

# check wheter the TranscriptError contains the specified error message
# check whether the TranscriptError contains the specified error message
assert response_json["error"] in str(excinfo.value)
assert len(httpx_mock.get_requests()) == 1

Expand Down