diff --git a/README.md b/README.md index 4bd3c43..c42052a 100644 --- a/README.md +++ b/README.md @@ -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( [ diff --git a/assemblyai/__version__.py b/assemblyai/__version__.py index 3043a40..8b19221 100644 --- a/assemblyai/__version__.py +++ b/assemblyai/__version__.py @@ -1 +1 @@ -__version__ = "0.54.1" +__version__ = "0.55.0" diff --git a/assemblyai/streaming/v3/models.py b/assemblyai/streaming/v3/models.py index 3f9b4c7..2b9c9f7 100644 --- a/assemblyai/streaming/v3/models.py +++ b/assemblyai/streaming/v3/models.py @@ -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 diff --git a/assemblyai/transcriber.py b/assemblyai/transcriber.py index 863fa27..9a319d4 100644 --- a/assemblyai/transcriber.py +++ b/assemblyai/transcriber.py @@ -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( diff --git a/assemblyai/types.py b/assemblyai/types.py index 0a0c145..88cb71a 100644 --- a/assemblyai/types.py +++ b/assemblyai/types.py @@ -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, ) @@ -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. """ @@ -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: ``` diff --git a/tests/unit/test_streaming.py b/tests/unit/test_streaming.py index 94c05e5..2532812 100644 --- a/tests/unit/test_streaming.py +++ b/tests/unit/test_streaming.py @@ -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 ( @@ -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)}" @@ -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)}" @@ -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, @@ -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)}" @@ -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") @@ -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", @@ -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, @@ -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, ) @@ -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 = { diff --git a/tests/unit/test_transcriber.py b/tests/unit/test_transcriber.py index 9f5c845..6500199 100644 --- a/tests/unit/test_transcriber.py +++ b/tests/unit/test_transcriber.py @@ -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 @@ -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 diff --git a/tests/unit/test_transcript.py b/tests/unit/test_transcript.py index e490885..e5fb27c 100644 --- a/tests/unit/test_transcript.py +++ b/tests/unit/test_transcript.py @@ -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