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 assemblyai/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.10.12"
__version__ = "1.10.13"
2 changes: 1 addition & 1 deletion assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
48 changes: 48 additions & 0 deletions tests/unit/test_empty_custom_spelling.py
Original file line number Diff line number Diff line change
@@ -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"],
}