diff --git a/assemblyai/__version__.py b/assemblyai/__version__.py index d6a282f..b775394 100644 --- a/assemblyai/__version__.py +++ b/assemblyai/__version__.py @@ -1 +1 @@ -__version__ = "1.10.12" +__version__ = "1.10.13" diff --git a/assemblyai/types.py b/assemblyai/types.py index 4c36780..f7ccb65 100644 --- a/assemblyai/types.py +++ b/assemblyai/types.py @@ -1726,7 +1726,7 @@ def custom_spelling(self) -> Optional[Dict[str, Union[str, List[str]]]]: custom_spellings[_to] = custom_spelling["from"] - return custom_spellings if custom_spelling else None + return custom_spellings if custom_spellings else None @property def disfluencies(self) -> Optional[bool]: diff --git a/tests/unit/test_empty_custom_spelling.py b/tests/unit/test_empty_custom_spelling.py new file mode 100644 index 0000000..891e2e6 --- /dev/null +++ b/tests/unit/test_empty_custom_spelling.py @@ -0,0 +1,48 @@ +import pytest + +import assemblyai as aai + + +def test_empty_custom_spelling_constructor(): + assert aai.TranscriptionConfig(custom_spelling={}).custom_spelling is None + + +@pytest.mark.parametrize("override", [False, True]) +def test_empty_custom_spelling_setter_when_unset(override): + config = aai.TranscriptionConfig() + assert config.set_custom_spelling({}, override=override) is config + assert config.custom_spelling is None + + +def test_empty_custom_spelling_clears_existing(): + config = aai.TranscriptionConfig(custom_spelling={"AssemblyAI": "assemblyAI"}) + config.set_custom_spelling({}) + assert config.custom_spelling is None + + +def test_empty_custom_spelling_merge_keeps_existing(): + config = aai.TranscriptionConfig(custom_spelling={"AssemblyAI": "assemblyAI"}) + config.set_custom_spelling({}, override=False) + assert config.custom_spelling == {"AssemblyAI": ["assemblyAI"]} + + +@pytest.mark.parametrize("override", [False, True]) +def test_none_custom_spelling_controls(override): + assert aai.TranscriptionConfig(custom_spelling=None).custom_spelling is None + config = aai.TranscriptionConfig(custom_spelling={"AssemblyAI": "assemblyAI"}) + config.set_custom_spelling(None, override=override) + assert config.custom_spelling is None + + +def test_nonempty_custom_spelling_merge(): + config = aai.TranscriptionConfig(custom_spelling={"AssemblyAI": "assemblyAI"}) + config.set_custom_spelling({"Kubernetes": ["k8s", "kubernetes"]}, override=False) + assert config.custom_spelling == { + "AssemblyAI": ["assemblyAI"], + "Kubernetes": ["k8s", "kubernetes"], + } + config.set_custom_spelling({"AssemblyAI": ["assembly ai"]}, override=False) + assert config.custom_spelling == { + "AssemblyAI": ["assembly ai"], + "Kubernetes": ["k8s", "kubernetes"], + }