


import itertools
import random
import unittest

import numpy as np

from transformers import BatchFeature, SpeechTaFeatureExtractor
from transformers.testing_utils import require_torch
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
 import torch


SCREAMING_SNAKE_CASE       :      Any												= random.Random()



def 				UpperCamelCase_(      lowerCamelCase_							, lowerCamelCase_=1.0							, lowerCamelCase_=None							, lowerCamelCase_=None )    ->						Any:
    if rng is None:
        _lowercase       :							Any      		=		global_rng

    _lowercase       :							Optional[Any]      		=		[]
    for batch_idx in range(shape[0] ):
        values.append([] )
        for _ in range(shape[1] ):
            values[-1].append(rng.random() * scale )

    return values






@require_torch
class _lowerCamelCase(						unittest.TestCase   ):
       def __init__(					self,      lowerCamelCase,      lowerCamelCase=7,      lowerCamelCase=4_00,      lowerCamelCase=20_00,      lowerCamelCase=1,      lowerCamelCase=0.0,      lowerCamelCase=1_60_00,      lowerCamelCase=True,      lowerCamelCase=80,      lowerCamelCase=16,      lowerCamelCase=64,      lowerCamelCase="hann_window",      lowerCamelCase=80,      lowerCamelCase=76_00,      lowerCamelCase=1E-10,      lowerCamelCase=True,      )       ->   List[str]:




           """simple docstring"""

           _lowercase       :							str      		=		parent
           _lowercase       :							List[Any]      		=		batch_size
           _lowercase       :							str      		=		min_seq_length
           _lowercase       :							Optional[Any]      		=		max_seq_length
           _lowercase       :							Dict      		=		(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
           _lowercase       :							List[Any]      		=		feature_size
           _lowercase       :							Union[str, Any]      		=		padding_value
           _lowercase       :							Any      		=		sampling_rate
           _lowercase       :							Tuple      		=		do_normalize
           _lowercase       :							int      		=		num_mel_bins
           _lowercase       :							Tuple      		=		hop_length
           _lowercase       :							Any      		=		win_length
           _lowercase       :							int      		=		win_function
           _lowercase       :							Optional[Any]      		=		fmin
           _lowercase       :							List[str]      		=		fmax
           _lowercase       :							Tuple      		=		mel_floor
           _lowercase       :							Dict      		=		return_attention_mask
       def 			UpperCamelCase     (					self)       ->   str:




           """simple docstring"""

           return {
               "feature_size": self.feature_size,
               "padding_value": self.padding_value,
               "sampling_rate": self.sampling_rate,
               "do_normalize": self.do_normalize,
               "num_mel_bins": self.num_mel_bins,
               "hop_length": self.hop_length,
               "win_length": self.win_length,
               "win_function": self.win_function,
               "fmin": self.fmin,
               "fmax": self.fmax,
               "mel_floor": self.mel_floor,
               "return_attention_mask": self.return_attention_mask,
           }
       def 			UpperCamelCase     (					self,      lowerCamelCase=False,      lowerCamelCase=False)       ->   List[Any]:




           """simple docstring"""

           def _flatten(lowerCamelCase):
               return list(itertools.chain(*lowerCamelCase))

           if equal_length:
               _lowercase       :							Optional[int]      		=		floats_list((self.batch_size, self.max_seq_length))
           else:
               # make sure that inputs increase in size
               _lowercase       :							List[str]      		=		[
                   _flatten(floats_list((x, self.feature_size)))
                   for x in range(self.min_seq_length,      self.max_seq_length,      self.seq_length_diff)
               ]

           if numpify:
               _lowercase       :							int      		=		[np.asarray(lowerCamelCase) for x in speech_inputs]

           return speech_inputs




       def 			UpperCamelCase     (					self,      lowerCamelCase=False,      lowerCamelCase=False)       ->   Any:




           """simple docstring"""

           if equal_length:
               _lowercase       :							int      		=		[floats_list((self.max_seq_length, self.num_mel_bins)) for _ in range(self.batch_size)]
           else:
               # make sure that inputs increase in size
               _lowercase       :							Dict      		=		[
                   floats_list((x, self.num_mel_bins))
                   for x in range(self.min_seq_length,      self.max_seq_length,      self.seq_length_diff)
               ]

           if numpify:
               _lowercase       :							Optional[Any]      		=		[np.asarray(lowerCamelCase) for x in speech_inputs]

           return speech_inputs






@require_torch
class _lowerCamelCase(						_a, unittest.TestCase   ):
       lowercase_ :	List[str]     =			SpeechTaFeatureExtractor
       def 			UpperCamelCase     (					self)       ->   Dict:




           """simple docstring"""

           _lowercase       :							str      		=		SpeechTaFeatureExtractionTester(self)
       def 			UpperCamelCase     (					self,      lowerCamelCase)       ->   str:




           """simple docstring"""

           self.assertTrue(np.all(np.mean(lowerCamelCase,      axis=0) < 1E-3))
           self.assertTrue(np.all(np.abs(np.var(lowerCamelCase,      axis=0) - 1) < 1E-3))
       def 			UpperCamelCase     (					self)       ->   str:




           """simple docstring"""

           _lowercase       :							Tuple      		=		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           # create three inputs of length 800, 1000, and 1200
           _lowercase       :							Dict      		=		[floats_list((1, x))[0] for x in range(8_00,      14_00,      2_00)]
           _lowercase       :							Any      		=		[np.asarray(lowerCamelCase) for speech_input in speech_inputs]

           # Test not batched input
           _lowercase       :							Optional[Any]      		=		feat_extract(speech_inputs[0],      return_tensors='np').input_values
           _lowercase       :							Union[str, Any]      		=		feat_extract(np_speech_inputs[0],      return_tensors='np').input_values
           self.assertTrue(np.allclose(lowerCamelCase,      lowerCamelCase,      atol=1E-3))

           # Test batched
           _lowercase       :							int      		=		feat_extract(lowerCamelCase,      return_tensors='np').input_values
           _lowercase       :							Tuple      		=		feat_extract(lowerCamelCase,      return_tensors='np').input_values
           for enc_seq_a, enc_seq_a in zip(lowerCamelCase,      lowerCamelCase):
               self.assertTrue(np.allclose(lowerCamelCase,      lowerCamelCase,      atol=1E-3))
       def 			UpperCamelCase     (					self)       ->   str:




           """simple docstring"""

           _lowercase       :							Tuple      		=		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           _lowercase       :							Union[str, Any]      		=		[floats_list((1, x))[0] for x in range(8_00,      14_00,      2_00)]

           _lowercase       :							str      		=		['longest', 'max_length', 'do_not_pad']
           _lowercase       :							List[str]      		=		[None, 16_00, None]
           for max_length, padding in zip(lowerCamelCase,      lowerCamelCase):
               _lowercase       :							Any      		=		feat_extract(lowerCamelCase,      padding=lowerCamelCase,      max_length=lowerCamelCase,      return_tensors='np')
               _lowercase       :							Optional[Any]      		=		processed.input_values

               self._check_zero_mean_unit_variance(input_values[0][:8_00])
               self.assertTrue(input_values[0][8_00:].sum() < 1E-6)
               self._check_zero_mean_unit_variance(input_values[1][:10_00])
               self.assertTrue(input_values[0][10_00:].sum() < 1E-6)
               self._check_zero_mean_unit_variance(input_values[2][:12_00])
       def 			UpperCamelCase     (					self)       ->   Tuple:




           """simple docstring"""

           _lowercase       :							Dict      		=		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           _lowercase       :							Tuple      		=		range(8_00,      14_00,      2_00)
           _lowercase       :							Optional[int]      		=		[floats_list((1, x))[0] for x in lengths]

           _lowercase       :							Optional[Any]      		=		['longest', 'max_length', 'do_not_pad']
           _lowercase       :							Optional[int]      		=		[None, 16_00, None]

           for max_length, padding in zip(lowerCamelCase,      lowerCamelCase):
               _lowercase       :							Union[str, Any]      		=		feat_extract(lowerCamelCase,      max_length=lowerCamelCase,      padding=lowerCamelCase)
               _lowercase       :							List[Any]      		=		processed.input_values

               self._check_zero_mean_unit_variance(input_values[0][:8_00])
               self._check_zero_mean_unit_variance(input_values[1][:10_00])
               self._check_zero_mean_unit_variance(input_values[2][:12_00])
       def 			UpperCamelCase     (					self)       ->   Optional[Any]:




           """simple docstring"""

           _lowercase       :							List[Any]      		=		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           _lowercase       :							Dict      		=		[floats_list((1, x))[0] for x in range(8_00,      14_00,      2_00)]
           _lowercase       :							Union[str, Any]      		=		feat_extract(
               lowerCamelCase,      truncation=lowerCamelCase,      max_length=10_00,      padding='max_length',      return_tensors='np')
           _lowercase       :							List[str]      		=		processed.input_values

           self._check_zero_mean_unit_variance(input_values[0, :8_00])
           self._check_zero_mean_unit_variance(input_values[1])
           self._check_zero_mean_unit_variance(input_values[2])
       def 			UpperCamelCase     (					self)       ->   List[Any]:




           """simple docstring"""

           _lowercase       :							Optional[int]      		=		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           _lowercase       :							Optional[Any]      		=		[floats_list((1, x))[0] for x in range(8_00,      14_00,      2_00)]
           _lowercase       :							int      		=		feat_extract(
               lowerCamelCase,      truncation=lowerCamelCase,      max_length=10_00,      padding='longest',      return_tensors='np')
           _lowercase       :							Dict      		=		processed.input_values

           self._check_zero_mean_unit_variance(input_values[0, :8_00])
           self._check_zero_mean_unit_variance(input_values[1, :10_00])
           self._check_zero_mean_unit_variance(input_values[2])

           # make sure that if max_length < longest -> then pad to max_length
           self.assertTrue(input_values.shape == (3, 10_00))

           _lowercase       :							Optional[int]      		=		[floats_list((1, x))[0] for x in range(8_00,      14_00,      2_00)]
           _lowercase       :							Any      		=		feat_extract(
               lowerCamelCase,      truncation=lowerCamelCase,      max_length=20_00,      padding='longest',      return_tensors='np')
           _lowercase       :							List[str]      		=		processed.input_values

           self._check_zero_mean_unit_variance(input_values[0, :8_00])
           self._check_zero_mean_unit_variance(input_values[1, :10_00])
           self._check_zero_mean_unit_variance(input_values[2])

           # make sure that if max_length > longest -> then pad to longest
           self.assertTrue(input_values.shape == (3, 12_00))
       def 			UpperCamelCase     (					self)       ->   Optional[int]:




           """simple docstring"""

           _lowercase       :							Optional[Any]      		=		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           _lowercase       :							Optional[Any]      		=		np.random.rand(1_00).astype(np.floataa)
           _lowercase       :							Any      		=		np_speech_inputs.tolist()

           for inputs in [py_speech_inputs, np_speech_inputs]:
               _lowercase       :							List[str]      		=		feature_extractor.pad([{'input_values': inputs}],      return_tensors='np')
               self.assertTrue(np_processed.input_values.dtype == np.floataa)
               _lowercase       :							List[str]      		=		feature_extractor.pad([{'input_values': inputs}],      return_tensors='pt')
               self.assertTrue(pt_processed.input_values.dtype == torch.floataa)
       def 			UpperCamelCase     (					self)       ->   str:




           """simple docstring"""

           _lowercase       :							int      		=		self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           # create three inputs of length 800, 1000, and 1200
           _lowercase       :							List[str]      		=		[floats_list((1, x))[0] for x in range(8_00,      14_00,      2_00)]
           _lowercase       :							Optional[int]      		=		[np.asarray(lowerCamelCase) for speech_input in speech_inputs]

           # Test feature size
           _lowercase       :							Optional[int]      		=		feature_extractor(audio_target=lowerCamelCase,      padding=lowerCamelCase,      return_tensors='np').input_values
           self.assertTrue(input_values.ndim == 3)
           self.assertTrue(input_values.shape[-1] == feature_extractor.num_mel_bins)

           # Test not batched input
           _lowercase       :							Union[str, Any]      		=		feature_extractor(speech_inputs[0],      return_tensors='np').input_values
           _lowercase       :							Tuple      		=		feature_extractor(np_speech_inputs[0],      return_tensors='np').input_values
           self.assertTrue(np.allclose(lowerCamelCase,      lowerCamelCase,      atol=1E-3))

           # Test batched
           _lowercase       :							int      		=		feature_extractor(lowerCamelCase,      return_tensors='np').input_values
           _lowercase       :							Union[str, Any]      		=		feature_extractor(lowerCamelCase,      return_tensors='np').input_values
           for enc_seq_a, enc_seq_a in zip(lowerCamelCase,      lowerCamelCase):
               self.assertTrue(np.allclose(lowerCamelCase,      lowerCamelCase,      atol=1E-3))

           # Test 2-D numpy arrays are batched.
           _lowercase       :							List[Any]      		=		[floats_list((1, x))[0] for x in (8_00, 8_00, 8_00)]
           _lowercase       :							Tuple      		=		np.asarray(lowerCamelCase)
           _lowercase       :							int      		=		feature_extractor(lowerCamelCase,      return_tensors='np').input_values
           _lowercase       :							List[str]      		=		feature_extractor(lowerCamelCase,      return_tensors='np').input_values
           for enc_seq_a, enc_seq_a in zip(lowerCamelCase,      lowerCamelCase):
               self.assertTrue(np.allclose(lowerCamelCase,      lowerCamelCase,      atol=1E-3))
       def 			UpperCamelCase     (					self)       ->   List[Any]:




           """simple docstring"""

           _lowercase       :							Tuple      		=		self.feat_extract_tester.prepare_inputs_for_target()
           _lowercase       :							str      		=		self.feature_extraction_class(**self.feat_extract_dict)
           _lowercase       :							str      		=		feat_extract.model_input_names[0]

           _lowercase       :							int      		=		BatchFeature({input_name: speech_inputs})

           self.assertTrue(all(len(lowerCamelCase) == len(lowerCamelCase) for x, y in zip(lowerCamelCase,      processed_features[input_name])))

           _lowercase       :							List[str]      		=		self.feat_extract_tester.prepare_inputs_for_target(equal_length=lowerCamelCase)
           _lowercase       :							Dict      		=		BatchFeature({input_name: speech_inputs},      tensor_type='np')

           _lowercase       :							List[str]      		=		processed_features[input_name]

           if len(batch_features_input.shape) < 3:
               _lowercase       :							Optional[int]      		=		batch_features_input[:, :, None]

           self.assertTrue(
               batch_features_input.shape
               == (self.feat_extract_tester.batch_size, len(speech_inputs[0]), self.feat_extract_tester.num_mel_bins))
       @require_torch
       def 			UpperCamelCase     (					self)       ->   List[Any]:




           """simple docstring"""

           _lowercase       :							Optional[int]      		=		self.feat_extract_tester.prepare_inputs_for_target(equal_length=lowerCamelCase)
           _lowercase       :							str      		=		self.feature_extraction_class(**self.feat_extract_dict)
           _lowercase       :							Optional[int]      		=		feat_extract.model_input_names[0]

           _lowercase       :							str      		=		BatchFeature({input_name: speech_inputs},      tensor_type='pt')

           _lowercase       :							str      		=		processed_features[input_name]

           if len(batch_features_input.shape) < 3:
               _lowercase       :							Tuple      		=		batch_features_input[:, :, None]

           self.assertTrue(
               batch_features_input.shape
               == (self.feat_extract_tester.batch_size, len(speech_inputs[0]), self.feat_extract_tester.num_mel_bins))
       @require_torch
       def 			UpperCamelCase     (					self)       ->   int:




           """simple docstring"""

           _lowercase       :							Dict      		=		self.feature_extraction_class(**self.feat_extract_dict)
           _lowercase       :							str      		=		self.feat_extract_tester.prepare_inputs_for_target()
           _lowercase       :							Any      		=		feat_extract.model_input_names[0]

           _lowercase       :							Union[str, Any]      		=		BatchFeature({input_name: speech_inputs})

           _lowercase       :							List[str]      		=		feat_extract.num_mel_bins  # hack!

           _lowercase       :							int      		=		feat_extract.pad(lowerCamelCase,      padding='longest',      return_tensors='np')[input_name]
           _lowercase       :							List[str]      		=		feat_extract.pad(lowerCamelCase,      padding='longest',      return_tensors='pt')[input_name]

           self.assertTrue(abs(input_np.astype(np.floataa).sum() - input_pt.numpy().astype(np.floataa).sum()) < 1E-2)
       def 			UpperCamelCase     (					self)       ->   int:




           """simple docstring"""

           _lowercase       :							int      		=		self.feat_extract_dict
           _lowercase       :							int      		=		True
           _lowercase       :							Optional[int]      		=		self.feature_extraction_class(**lowerCamelCase)
           _lowercase       :							int      		=		self.feat_extract_tester.prepare_inputs_for_target()
           _lowercase       :							List[str]      		=		[len(lowerCamelCase) for x in speech_inputs]
           _lowercase       :							Dict      		=		feat_extract.model_input_names[0]

           _lowercase       :							Tuple      		=		BatchFeature({input_name: speech_inputs})

           _lowercase       :							Tuple      		=		feat_extract.num_mel_bins  # hack!

           _lowercase       :							Union[str, Any]      		=		feat_extract.pad(lowerCamelCase,      padding='longest',      return_tensors='np')
           self.assertIn('attention_mask',      lowerCamelCase)
           self.assertListEqual(list(processed.attention_mask.shape),      list(processed[input_name].shape[:2]))
           self.assertListEqual(processed.attention_mask.sum(-1).tolist(),      lowerCamelCase)
       def 			UpperCamelCase     (					self)       ->   Tuple:




           """simple docstring"""

           _lowercase       :							int      		=		self.feat_extract_dict
           _lowercase       :							int      		=		True
           _lowercase       :							Dict      		=		self.feature_extraction_class(**lowerCamelCase)
           _lowercase       :							Union[str, Any]      		=		self.feat_extract_tester.prepare_inputs_for_target()
           _lowercase       :							List[Any]      		=		[len(lowerCamelCase) for x in speech_inputs]
           _lowercase       :							List[str]      		=		feat_extract.model_input_names[0]

           _lowercase       :							Optional[Any]      		=		BatchFeature({input_name: speech_inputs})
           _lowercase       :							Dict      		=		min(lowerCamelCase)

           _lowercase       :							Optional[int]      		=		feat_extract.num_mel_bins  # hack!

           _lowercase       :							Optional[int]      		=		feat_extract.pad(
               lowerCamelCase,      padding='max_length',      max_length=lowerCamelCase,      truncation=lowerCamelCase,      return_tensors='np')
           self.assertIn('attention_mask',      lowerCamelCase)
           self.assertListEqual(
               list(processed_pad.attention_mask.shape),      [processed_pad[input_name].shape[0], max_length])
           self.assertListEqual(
               processed_pad.attention_mask[:, :max_length].sum(-1).tolist(),      [max_length for x in speech_inputs])
       def 			UpperCamelCase     (					self,      lowerCamelCase)       ->   Dict:




           """simple docstring"""

           from datasets import load_dataset

           _lowercase       :							Union[str, Any]      		=		load_dataset('hf-internal-testing/librispeech_asr_dummy',      'clean',      split='validation')
           # automatic decoding with librispeech
           _lowercase       :							List[Any]      		=		ds.sort('id').select(range(lowerCamelCase))[:num_samples]['audio']

           return [x["array"] for x in speech_samples]
       def 			UpperCamelCase     (					self)       ->   str:




           """simple docstring"""

           _lowercase       :							Dict      		=		torch.tensor(
               [2.38_04E-03, 2.07_52E-03, 1.98_36E-03, 2.10_57E-03, 1.61_74E-03,
                3.05_18E-04, 9.15_53E-05, 3.35_69E-04, 9.76_56E-04, 1.83_11E-03,
                2.01_42E-03, 2.10_57E-03, 1.73_95E-03, 4.57_76E-04, -3.96_73E-04,
                4.57_76E-04, 1.00_71E-03, 9.15_53E-05, 4.88_28E-04, 1.15_97E-03,
                7.32_42E-04, 9.46_04E-04, 1.80_05E-03, 1.83_11E-03, 8.85_01E-04,
                4.27_25E-04, 4.88_28E-04, 7.32_42E-04, 1.09_86E-03, 2.10_57E-03])
           # fmt: on

           _lowercase       :							List[str]      		=		self._load_datasamples(1)
           _lowercase       :							Any      		=		SpeechTaFeatureExtractor()
           _lowercase       :							Union[str, Any]      		=		feature_extractor(lowerCamelCase,      return_tensors='pt').input_values
           self.assertEquals(input_values.shape,      (1, 9_36_80))
           self.assertTrue(torch.allclose(input_values[0, :30],      lowerCamelCase,      atol=1E-6))




       def 			UpperCamelCase     (					self)       ->   Dict:




           """simple docstring"""

           _lowercase       :							Optional[Any]      		=		torch.tensor(
               [-2.6_8_7_0, -3.0_1_0_4, -3.1_3_5_6, -3.5_3_5_2, -3.0_0_4_4, -3.0_3_5_3, -3.4_7_1_9, -3.6_7_7_7,
                -3.1_5_2_0, -2.9_4_3_5, -2.6_5_5_3, -2.8_7_9_5, -2.9_9_4_4, -2.5_9_2_1, -3.0_2_7_9, -3.0_3_8_6,
                -3.0_8_6_4, -3.1_2_9_1, -3.2_3_5_3, -2.7_4_4_4, -2.6_8_3_1, -2.7_2_8_7, -3.1_7_6_1, -3.1_5_7_1,
                -3.2_7_2_6, -3.0_5_8_2, -3.1_0_0_7, -3.4_5_3_3, -3.4_6_9_5, -3.0_9_9_8])
           # fmt: on

           _lowercase       :							Optional[int]      		=		self._load_datasamples(1)
           _lowercase       :							str      		=		SpeechTaFeatureExtractor()
           _lowercase       :							Any      		=		feature_extractor(audio_target=lowerCamelCase,      return_tensors='pt').input_values
           self.assertEquals(input_values.shape,      (1, 3_66, 80))
           self.assertTrue(torch.allclose(input_values[0, 0, :30],      lowerCamelCase,      atol=1E-4))






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_tf_available,
    is_torch_available,
)


SCREAMING_SNAKE_CASE       :      List[str]												= {
    "configuration_speech_to_text": ["SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Speech2TextConfig"],
    "processing_speech_to_text": ["Speech2TextProcessor"],
}

try:
 if not is_sentencepiece_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE       :      Union[str, Any]												= ["Speech2TextTokenizer"]

try:
 if not is_speech_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE       :      int												= ["Speech2TextFeatureExtractor"]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE       :      Optional[Any]												= [
     "TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "TFSpeech2TextForConditionalGeneration",
     "TFSpeech2TextModel",
     "TFSpeech2TextPreTrainedModel",
 ]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE       :      str												= [
     "SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "Speech2TextForConditionalGeneration",
     "Speech2TextModel",
     "Speech2TextPreTrainedModel",
 ]


if TYPE_CHECKING:
 from .configuration_speech_to_text import SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextConfig
 from .processing_speech_to_text import SpeechaTextProcessor

 try:
  if not is_sentencepiece_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_speech_to_text import SpeechaTextTokenizer

 try:
  if not is_speech_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .feature_extraction_speech_to_text import SpeechaTextFeatureExtractor

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_speech_to_text import (
      TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFSpeechaTextForConditionalGeneration,
      TFSpeechaTextModel,
      TFSpeechaTextPreTrainedModel,
  )

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_speech_to_text import (
      SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
      SpeechaTextForConditionalGeneration,
      SpeechaTextModel,
      SpeechaTextPreTrainedModel,
  )

else:
 import sys

 SCREAMING_SNAKE_CASE       :      Optional[Any]												= _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


