laura_codec.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import os
  3. from typing import Any, Dict
  4. from modelscope.metainfo import Models
  5. from modelscope.models.base import Model
  6. from modelscope.models.builder import MODELS
  7. from modelscope.utils.constant import Frameworks, Tasks
  8. __all__ = ['LauraCodecGenModel']
  9. @MODELS.register_module(Tasks.text_to_speech, module_name=Models.laura_codec)
  10. class LauraCodecGenModel(Model):
  11. def __init__(self, model_dir: str, model_name: str,
  12. model_config: Dict[str, Any], *args, **kwargs):
  13. """initialize the info of model.
  14. Args:
  15. model_dir (str): the model path.
  16. model_name (str): the itn model name from configuration.json
  17. model_config (Dict[str, Any]): the detail config about model from configuration.json
  18. """
  19. super().__init__(model_dir, model_name, model_config, *args, **kwargs)
  20. self.model_cfg = {
  21. # the recognition model dir path
  22. 'model_workspace': model_dir,
  23. # the itn model name
  24. 'model_name': model_name,
  25. # the am model file path
  26. 'model_path': os.path.join(model_dir, model_name),
  27. # the recognition model config dict
  28. 'model_config': model_config
  29. }
  30. def forward(self) -> Dict[str, Any]:
  31. """
  32. just return the model config
  33. """
  34. return self.model_cfg