from django.conf import settings
from .BaseAudioService import BaseAudioService
from .AliyunAudioService import AliyunAudioService
from .TencentAudioService import TencentAudioService
from .HuoshanAudioService import HuoshanAudioService


def get_audio_service() -> BaseAudioService:
    provider = settings.AUDIO_SERVICE_PROVIDER
    config = settings.AUDIO_SERVICE_CONFIG[provider]

    if provider == 'aliyun':
        return AliyunAudioService(config)
    elif provider == 'tencent':
        return TencentAudioService(config['api_key'], config['api_secret'])
    elif provider == 'huoshan':
        return HuoshanAudioService(config)
    else:
        raise ValueError(f"Unknown audio service provider: {provider}")

if __name__ == '__main__':
    # Example usage
    audio_service = get_audio_service()
    synthesized_speech = audio_service.synthesize_speech("Hello, world!")
    # recognized_text = audio_service.recognize_speech(audio_data)


