stt.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # coding=utf-8
  2. import io
  3. from typing import Dict
  4. from models_provider.base_model_provider import MaxKBBaseModel
  5. from models_provider.impl.base_stt import BaseSpeechToText
  6. class TencentSpeechToText(MaxKBBaseModel, BaseSpeechToText):
  7. secret_id: str
  8. secret_key: str
  9. model: str
  10. @staticmethod
  11. def is_cache_model():
  12. return False
  13. def __init__(self, **kwargs):
  14. super().__init__(**kwargs)
  15. self.secret_id = kwargs.get('secret_id')
  16. self.secret_key = kwargs.get('secret_key')
  17. self.model = kwargs.get('model')
  18. @staticmethod
  19. def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
  20. return TencentSpeechToText(
  21. model=model_name,
  22. secret_id=model_credential.get('secret_id'),
  23. secret_key=model_credential.get('secret_key'),
  24. **model_kwargs,
  25. )
  26. def check_auth(self):
  27. pass
  28. def speech_to_text(self, audio_file):
  29. return "Tencent STT not implemented"