@@ -521,7 +521,7 @@ class RawTranscriptionConfig(BaseModel):
521
521
iab_categories : Optional [bool ]
522
522
"Enable Topic Detection."
523
523
524
- custom_spelling : Optional [List [Dict [str , List [str ]]]]
524
+ custom_spelling : Optional [List [Dict [str , Union [ str , List [str ] ]]]]
525
525
"Customize how words are spelled and formatted using to and from values"
526
526
527
527
disfluencies : Optional [bool ]
@@ -649,10 +649,11 @@ def __init__(
649
649
speech_threshold: Reject audio files that contain less than this fraction of speech. Valid values are in the range [0,1] inclusive.
650
650
raw_transcription_config: Create the config from a `RawTranscriptionConfig`
651
651
"""
652
- self ._raw_transcription_config = raw_transcription_config
653
-
654
- if raw_transcription_config is None :
655
- self ._raw_transcription_config = RawTranscriptionConfig ()
652
+ self ._raw_transcription_config = (
653
+ raw_transcription_config
654
+ if raw_transcription_config is not None
655
+ else RawTranscriptionConfig ()
656
+ )
656
657
657
658
# explicit configurations have higher priority if `raw_transcription_config` has been passed as well
658
659
self .language_code = language_code
@@ -914,17 +915,21 @@ def iab_categories(self, enable: Optional[bool]) -> None:
914
915
self ._raw_transcription_config .iab_categories = enable
915
916
916
917
@property
917
- def custom_spelling (self ) -> Optional [Dict [str , List [str ]]]:
918
+ def custom_spelling (self ) -> Optional [Dict [str , Union [ str , List [str ] ]]]:
918
919
"Returns the current set custom spellings."
919
920
920
921
if self ._raw_transcription_config .custom_spelling is None :
921
922
return None
922
923
923
924
custom_spellings = {}
924
925
for custom_spelling in self ._raw_transcription_config .custom_spelling :
925
- custom_spellings [custom_spelling ["from" ]] = custom_spelling ["to" ]
926
+ _from = custom_spelling ["from" ]
927
+ if isinstance (_from , str ):
928
+ custom_spellings [_from ] = custom_spelling ["to" ]
929
+ else :
930
+ raise ValueError ("`from` argument must be a string!" )
926
931
927
- return custom_spellings
932
+ return custom_spellings if custom_spelling else None
928
933
929
934
@property
930
935
def disfluencies (self ) -> Optional [bool ]:
@@ -938,8 +943,6 @@ def disfluencies(self, enable: Optional[bool]) -> None:
938
943
939
944
self ._raw_transcription_config .disfluencies = enable
940
945
941
- return self
942
-
943
946
@property
944
947
def sentiment_analysis (self ) -> Optional [bool ]:
945
948
"Returns the status of the Sentiment Analysis feature."
@@ -953,7 +956,7 @@ def sentiment_analysis(self, enable: Optional[bool]) -> None:
953
956
self ._raw_transcription_config .sentiment_analysis = enable
954
957
955
958
@property
956
- def auto_chapters (self ) -> bool :
959
+ def auto_chapters (self ) -> Optional [ bool ] :
957
960
"Returns the status of the Auto Chapters feature."
958
961
959
962
return self ._raw_transcription_config .auto_chapters
@@ -971,7 +974,7 @@ def auto_chapters(self, enable: Optional[bool]) -> None:
971
974
self ._raw_transcription_config .auto_chapters = enable
972
975
973
976
@property
974
- def entity_detection (self ) -> bool :
977
+ def entity_detection (self ) -> Optional [ bool ] :
975
978
"Returns whether Entity Detection feature is enabled or not."
976
979
977
980
return self ._raw_transcription_config .entity_detection
@@ -1076,7 +1079,7 @@ def set_casing_and_formatting(
1076
1079
1077
1080
def set_speaker_diarization (
1078
1081
self ,
1079
- enable : bool = True ,
1082
+ enable : Optional [ bool ] = True ,
1080
1083
speakers_expected : Optional [int ] = None ,
1081
1084
) -> Self :
1082
1085
"""
@@ -1261,7 +1264,7 @@ def set_custom_spelling(
1261
1264
1262
1265
def set_summarize (
1263
1266
self ,
1264
- enable : bool = True ,
1267
+ enable : Optional [ bool ] = True ,
1265
1268
model : Optional [SummarizationModel ] = None ,
1266
1269
type : Optional [SummarizationType ] = None ,
1267
1270
) -> Self :
@@ -1866,13 +1869,6 @@ def source(self) -> Sourcable:
1866
1869
"""
1867
1870
return self ._source
1868
1871
1869
- @property
1870
- def context (self ) -> Optional [Union [str , Dict [str , Any ]]]:
1871
- """
1872
- An optional context on the source (can be a string or an arbitrary dictionary)
1873
- """
1874
- return self ._context
1875
-
1876
1872
@property
1877
1873
def type (self ) -> LemurSourceType :
1878
1874
"""
0 commit comments