"""This module is responsible for audio meta data validation.""" from trafaret import DataError from common_config import logger # noqa import schemas_factory # noqa def validate_audio_metadata(audio_metadata): """Validate audio metadata. Args: audio_metadata (dict): Input audio metadata. Returns: bool: True or throw ValueError. Raises: ValueError: Invalid metadata of audio file. """ try: mime_type = audio_metadata.get('mime_type', '').lower() schema = schemas_factory.get_audio_validation_schema(mime_type) schema.check(audio_metadata) return True except DataError as e: logger.exception(str(e)) error_message = schemas_factory.extract_errors(e) raise ValueError(error_message)