__init__.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Copyright 2023 The HuggingFace Team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. from ...utils import (
  16. OptionalDependencyNotAvailable,
  17. _LazyModule,
  18. is_sentencepiece_available,
  19. is_torch_available,
  20. )
  21. _import_structure = {
  22. "configuration_speecht5": [
  23. "SpeechT5Config",
  24. "SpeechT5HifiGanConfig",
  25. ],
  26. "feature_extraction_speecht5": ["SpeechT5FeatureExtractor"],
  27. "processing_speecht5": ["SpeechT5Processor"],
  28. }
  29. try:
  30. if not is_sentencepiece_available():
  31. raise OptionalDependencyNotAvailable()
  32. except OptionalDependencyNotAvailable:
  33. pass
  34. else:
  35. _import_structure["tokenization_speecht5"] = ["SpeechT5Tokenizer"]
  36. try:
  37. if not is_torch_available():
  38. raise OptionalDependencyNotAvailable()
  39. except OptionalDependencyNotAvailable:
  40. pass
  41. else:
  42. _import_structure["modeling_speecht5"] = [
  43. "SpeechT5ForSpeechToText",
  44. "SpeechT5ForSpeechToSpeech",
  45. "SpeechT5ForTextToSpeech",
  46. "SpeechT5Model",
  47. "SpeechT5PreTrainedModel",
  48. "SpeechT5HifiGan",
  49. ]
  50. if TYPE_CHECKING:
  51. from .configuration_speecht5 import (
  52. SpeechT5Config,
  53. SpeechT5HifiGanConfig,
  54. )
  55. from .feature_extraction_speecht5 import SpeechT5FeatureExtractor
  56. from .processing_speecht5 import SpeechT5Processor
  57. try:
  58. if not is_sentencepiece_available():
  59. raise OptionalDependencyNotAvailable()
  60. except OptionalDependencyNotAvailable:
  61. pass
  62. else:
  63. from .tokenization_speecht5 import SpeechT5Tokenizer
  64. try:
  65. if not is_torch_available():
  66. raise OptionalDependencyNotAvailable()
  67. except OptionalDependencyNotAvailable:
  68. pass
  69. else:
  70. from .modeling_speecht5 import (
  71. SpeechT5ForSpeechToSpeech,
  72. SpeechT5ForSpeechToText,
  73. SpeechT5ForTextToSpeech,
  74. SpeechT5HifiGan,
  75. SpeechT5Model,
  76. SpeechT5PreTrainedModel,
  77. )
  78. else:
  79. import sys
  80. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)