Skip to content

chore: sync code base with OSS repository #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024
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
2 changes: 1 addition & 1 deletion assemblyai/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.33.0"
70 changes: 37 additions & 33 deletions assemblyai/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,19 +550,17 @@ class RawTranscriptionConfig(BaseModel):
"""
Identify the dominant language that's spoken in an audio file, and route the file to the appropriate model for the detected language.

Automatic Language Detection is supported for the following languages:
See the docs for supported languages: https://www.assemblyai.com/docs/getting-started/supported-languages
"""

- English
- Spanish
- French
- German
- Italian
- Portuguese
- Dutch
language_confidence_threshold: Optional[float]
"""
The confidence threshold that must be reached if `language_detection` is enabled. An error will be returned
if the language confidence is below this threshold. Valid values are in the range [0,1] inclusive.
"""

speech_threshold: Optional[float]
"Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive"
"Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive."

speech_model: Optional[SpeechModel]
"""
Expand Down Expand Up @@ -608,6 +606,7 @@ def __init__(
summary_type: Optional[SummarizationType] = None,
auto_highlights: Optional[bool] = None,
language_detection: Optional[bool] = None,
language_confidence_threshold: Optional[float] = None,
speech_threshold: Optional[float] = None,
raw_transcription_config: Optional[RawTranscriptionConfig] = None,
speech_model: Optional[SpeechModel] = None,
Expand Down Expand Up @@ -644,8 +643,10 @@ def __init__(
summary_model: The summarization model to use in case `summarization` is enabled
summary_type: The summarization type to use in case `summarization` is enabled
auto_highlights: Detect important phrases and words in your transcription text.
language_detection: Identify the dominant language that’s spoken in an audio file, and route the file to the appropriate model for the detected language.
speech_threshold: Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive
language_detection: Identify the dominant language that's spoken in an audio file, and route the file to the appropriate model for the detected language.
language_confidence_threshold: The confidence threshold that must be reached if `language_detection` is enabled.
An error will be returned if the language confidence is below this threshold. Valid values are in the range [0,1] inclusive.
speech_threshold: Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive.
raw_transcription_config: Create the config from a `RawTranscriptionConfig`
"""
self._raw_transcription_config = raw_transcription_config
Expand Down Expand Up @@ -691,6 +692,7 @@ def __init__(
)
self.auto_highlights = auto_highlights
self.language_detection = language_detection
self.language_confidence_threshold = language_confidence_threshold
self.speech_threshold = speech_threshold
self.speech_model = speech_model

Expand Down Expand Up @@ -1021,19 +1023,26 @@ def language_detection(self, enable: Optional[bool]) -> None:
"""
Identify the dominant language that's spoken in an audio file, and route the file to the appropriate model for the detected language.

Automatic Language Detection is supported for the following languages:

- English
- Spanish
- French
- German
- Italian
- Portuguese
- Dutch
See the docs for supported languages: https://www.assemblyai.com/docs/getting-started/supported-languages
"""

self._raw_transcription_config.language_detection = enable

@property
def language_confidence_threshold(self) -> Optional[float]:
"Returns the confidence threshold that must be reached for automatic language detection."

return self._raw_transcription_config.language_confidence_threshold

@language_confidence_threshold.setter
def language_confidence_threshold(self, threshold: Optional[float]) -> None:
"""
Set the confidence threshold that must be reached if `language_detection` is enabled. An error will be returned
if the language confidence is below this threshold. Valid values are in the range [0,1] inclusive.
"""

self._raw_transcription_config.language_confidence_threshold = threshold

@property
def speech_threshold(self) -> Optional[float]:
"Returns the current speech threshold."
Expand All @@ -1042,10 +1051,7 @@ def speech_threshold(self) -> Optional[float]:

@speech_threshold.setter
def speech_threshold(self, threshold: Optional[float]) -> None:
"Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive"

if threshold is not None and (threshold < 0 or threshold > 1):
raise ValueError("speech_threshold must be between 0 and 1 (inclusive).")
"Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive."

self._raw_transcription_config.speech_threshold = threshold

Expand Down Expand Up @@ -1638,17 +1644,15 @@ class BaseTranscript(BaseModel):
"""
Identify the dominant language that's spoken in an audio file, and route the file to the appropriate model for the detected language.

Automatic Language Detection is supported for the following languages:

- English
- Spanish
- French
- German
- Italian
- Portuguese
- Dutch
See the docs for supported languages: https://www.assemblyai.com/docs/getting-started/supported-languages
"""

language_confidence_threshold: Optional[float]
"The confidence threshold that must be reached if `language_detection` is enabled."

language_confidence: Optional[float]
"The confidence score for the detected language, between 0.0 (low confidence) and 1.0 (high confidence)."

speech_threshold: Optional[float]
"Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive"

Expand Down
11 changes: 0 additions & 11 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,3 @@ def test_configuration_are_none_by_default():
pytest.fail(
f"Configuration field {name} is {value} and not None by default."
)


def test_speech_threshold_fails_if_outside_range():
"""
Tests that an exception is raised if the value for speech_threshold is outside the range of [0, 1].
"""

with pytest.raises(ValueError, match="speech_threshold"):
aai.TranscriptionConfig(speech_threshold=1.5)
with pytest.raises(ValueError, match="speech_threshold"):
aai.TranscriptionConfig(speech_threshold=-0.5)
Loading