@@ -442,8 +442,10 @@ def __init__(
442
442
self ,
443
443
* ,
444
444
client : _client .Client ,
445
+ config : types .TranscriptionConfig ,
445
446
) -> None :
446
447
self ._client = client
448
+ self .config = config
447
449
448
450
def transcribe_url (
449
451
self ,
@@ -517,7 +519,7 @@ def transcribe(
517
519
poll : bool ,
518
520
) -> Transcript :
519
521
if config is None :
520
- config = types . TranscriptionConfig ()
522
+ config = self . config
521
523
522
524
if urlparse (data ).scheme in {"http" , "https" }:
523
525
return self .transcribe_url (
@@ -536,9 +538,12 @@ def transcribe_group(
536
538
self ,
537
539
* ,
538
540
data : List [str ],
539
- config : types .TranscriptionConfig ,
541
+ config : Optional [ types .TranscriptionConfig ] ,
540
542
poll : bool ,
541
543
) -> TranscriptGroup :
544
+ if config is None :
545
+ config = self .config
546
+
542
547
executor = concurrent .futures .ThreadPoolExecutor (max_workers = 8 )
543
548
future_transcripts : Dict [concurrent .futures .Future [Transcript ], str ] = {}
544
549
@@ -576,6 +581,7 @@ def __init__(
576
581
self ,
577
582
* ,
578
583
client : Optional [_client .Client ] = None ,
584
+ config : Optional [types .TranscriptionConfig ] = None ,
579
585
max_workers : Optional [int ] = None ,
580
586
) -> None :
581
587
"""
@@ -584,13 +590,29 @@ def __init__(
584
590
Args:
585
591
`client`: The `Client` to use for the `Transcriber`. If `None` is given, the
586
592
default settings for the `Client` will be used.
593
+ `config`: The default configuration for the `Transcriber`. If `None` is given,
594
+ the default configuration of a `TranscriptionConfig` will be used.
587
595
`max_workers`: The maximum number of parallel jobs when using the `_async`
588
596
methods on the `Transcriber`. By default it uses `os.cpu_count() - 1`
597
+
598
+ Example:
599
+ To use the `Transcriber` with the default settings, you can simply do:
600
+ ```
601
+ transcriber = aai.Transcriber()
602
+ ```
603
+
604
+ To use the `Transcriber` with a custom configuration, you can do:
605
+ ```
606
+ config = aai.TranscriptionConfig(punctuate=False, format_text=False)
607
+
608
+ transcriber = aai.Transcriber(config=config)
609
+ ```
589
610
"""
590
611
self ._client = client or _client .Client .get_default ()
591
612
592
613
self ._impl = _TranscriberImpl (
593
614
client = self ._client ,
615
+ config = config or types .TranscriptionConfig (),
594
616
)
595
617
596
618
if not max_workers :
@@ -600,6 +622,23 @@ def __init__(
600
622
max_workers = max_workers ,
601
623
)
602
624
625
+ @property
626
+ def config (self ) -> types .TranscriptionConfig :
627
+ """
628
+ Returns the default configuration of the `Transcriber`.
629
+ """
630
+ return self ._impl .config
631
+
632
+ @config .setter
633
+ def config (self , config : types .TranscriptionConfig ) -> None :
634
+ """
635
+ Sets the default configuration of the `Transcriber`.
636
+
637
+ Args:
638
+ `config`: The new default configuration.
639
+ """
640
+ self ._impl .config = config
641
+
603
642
def submit (
604
643
self ,
605
644
data : str ,
@@ -610,7 +649,8 @@ def submit(
610
649
611
650
Args:
612
651
data: An URL or a local file (as path)
613
- config: Transcription options and features.
652
+ config: Transcription options and features. If `None` is given, the Transcriber's
653
+ default configuration will be used.
614
654
"""
615
655
return self ._impl .transcribe (
616
656
data = data ,
@@ -628,8 +668,8 @@ def transcribe(
628
668
629
669
Args:
630
670
data: An URL or a local file (as path)
631
- config: Transcription options and features.
632
- poll: Whether the transcript should be polled for its completion .
671
+ config: Transcription options and features. If `None` is given, the Transcriber's
672
+ default configuration will be used .
633
673
"""
634
674
635
675
return self ._impl .transcribe (
@@ -648,8 +688,8 @@ def transcribe_async(
648
688
649
689
Args:
650
690
data: An URL or a local file (as path)
651
- config: Transcription options and features.
652
- poll: Whether the transcript should be polled for its completion .
691
+ config: Transcription options and features. If `None` is given, the Transcriber's
692
+ default configuration will be used .
653
693
"""
654
694
655
695
return self ._executor .submit (
@@ -669,11 +709,9 @@ def transcribe_group(
669
709
670
710
Args:
671
711
data: A list of paths or URLs (can be mixed)
672
- config: Transcription options and features.
673
- poll: Whether the transcripts should be polled for their completion .
712
+ config: Transcription options and features. If `None` is given, the Transcriber's
713
+ default configuration will be used .
674
714
"""
675
- if config is None :
676
- config = types .TranscriptionConfig ()
677
715
678
716
return self ._impl .transcribe_group (
679
717
data = data ,
@@ -683,7 +721,7 @@ def transcribe_group(
683
721
684
722
def transcribe_group_async (
685
723
self ,
686
- data : str ,
724
+ data : List [ str ] ,
687
725
config : Optional [types .TranscriptionConfig ] = None ,
688
726
) -> concurrent .futures .Future [TranscriptGroup ]:
689
727
"""
@@ -692,8 +730,8 @@ def transcribe_group_async(
692
730
693
731
Args:
694
732
data: A list of paths or URLs (can be mixed)
695
- config: Transcription options and features.
696
- poll: Whether the transcripts should be polled for their completion .
733
+ config: Transcription options and features. If `None` is given, the Transcriber's
734
+ default configuration will be used .
697
735
"""
698
736
699
737
return self ._executor .submit (
0 commit comments