Source code for deeptone.deeptone

import logging

from deeptone.file_processing import FileProcessing
from deeptone.models.arousal_model import LOW, HIGH, NEUTRAL, NO_SPEECH
from deeptone.models.audio_event_model import (
    NOISE,
    NAT_HUMAN_SOUNDS,
    NEG_HUMAN_SOUNDS,
    POS_HUMAN_SOUNDS,
    SILENCE as AUDIO_EVENT_SILENCE,
)
from deeptone.models.base_three_class_speech_model import SPEECH, MUSIC, OTHER, SILENCE
from deeptone.models.emotions_model import HAPPY, TIRED, IRRITATED, NEUTRAL as EMO_NEUTRAL
from deeptone.models.gender_model import FEMALE, MALE, UNKNOWN
from deeptone.models.language_model import DE, EN, ES, FR, IT
from deeptone.models.language_model import UNKNOWN as LANG_UNKNOWN
from deeptone.models.sound_power_model import (
    VERY_FAINT,
    FAINT,
    MODERATE,
    LOUD,
    PAINFUL,
)
from deeptone.models.underage_speaker_model import ADULT, CHILD
from deeptone.models.underage_speaker_model import NO_SPEECH as UNDERAGE_SPEAKER_NO_SPEECH
from deeptone.models.underage_speaker_model import SILENCE as UNDERAGE_SPEAKER_SILENCE
from deeptone.models.underage_speaker_model import UNKNOWN as UNDERAGE_SPEAKER_UNKNOWN
from deeptone.speaker_recognition import SpeakerRecognition
from deeptone.stream_processing import StreamProcessing

# model outputs
AROUSAL_LOW = LOW
AROUSAL_HIGH = HIGH
AROUSAL_NEUTRAL = NEUTRAL
AROUSAL_NO_SPEECH = NO_SPEECH
AROUSAL_SILENCE = SILENCE

GENDER_FEMALE = FEMALE
GENDER_MALE = MALE
GENDER_UNKNOWN = UNKNOWN
GENDER_NO_SPEECH = NO_SPEECH
GENDER_SILENCE = SILENCE

SPEECH_SPEECH = SPEECH
SPEECH_MUSIC = MUSIC
SPEECH_OTHER = OTHER
SPEECH_SILENCE = SILENCE

SPEECH_RT_SPEECH = SPEECH
SPEECH_RT_MUSIC = MUSIC
SPEECH_RT_OTHER = OTHER
SPEECH_RT_SILENCE = SILENCE

EMOTIONS_HAPPY = HAPPY
EMOTIONS_TIRED = TIRED
EMOTIONS_IRRITATED = IRRITATED
EMOTIONS_NEUTRAL = EMO_NEUTRAL
EMOTIONS_NO_SPEECH = NO_SPEECH
EMOTIONS_SILENCE = SILENCE

LANGUAGE_DE = DE
LANGUAGE_EN = EN
LANGUAGE_ES = ES
LANGUAGE_FR = FR
LANGUAGE_IT = IT
LANGUAGE_UNKNOWN = LANG_UNKNOWN
LANGUAGE_NO_SPEECH = NO_SPEECH
LANGUAGE_SILENCE = SILENCE

UNDERAGE_ADULT = ADULT
UNDERAGE_CHILD = CHILD
UNDERAGE_UNKNOWN = UNDERAGE_SPEAKER_UNKNOWN
UNDERAGE_NO_SPEECH = UNDERAGE_SPEAKER_NO_SPEECH
UNDERAGE_SILENCE = UNDERAGE_SPEAKER_SILENCE

AUDIO_EVENT_MUSIC = MUSIC
AUDIO_EVENT_NOISE = NOISE
AUDIO_EVENT_SPEECH = SPEECH
AUDIO_EVENT_NAT_HUMAN_SOUNDS = NAT_HUMAN_SOUNDS
AUDIO_EVENT_NEG_HUMAN_SOUNDS = NEG_HUMAN_SOUNDS
AUDIO_EVENT_POS_HUMAN_SOUNDS = POS_HUMAN_SOUNDS
AUDIO_EVENT_SILENCE = AUDIO_EVENT_SILENCE

SOUND_POWER_VERY_FAINT = VERY_FAINT
SOUND_POWER_FAINT = FAINT
SOUND_POWER_MODERATE = MODERATE
SOUND_POWER_LOUD = LOUD
SOUND_POWER_PAINFUL = PAINFUL

logger = logging.getLogger(__name__)


[docs]class Deeptone(FileProcessing, StreamProcessing, SpeakerRecognition): """ Entry point for the Deeptone SDK. Once this class is initialized, it provides access to the Deeptone Deep Learning models, which allow you to extract insights from your audio files. Three processing modes are supported: * File Processing: This mode allows you to provide a file to Deeptone, which will provide a time series analysis, \ alongside a summary and list of transitions for the entire file. * Audio Bytes Processing: This mode allows you to provide audio bytes to Deeptone. The output will be the same \ as in the File Processing case. * Stream Processing: This mode allows you to provide a real-time audio stream, which results in a continuous \ analysis, which will periodically generate insights as the stream progresses. Performance Considerations: Initialization of the Deep Learning models that power Deeptone is a time-consuming operation. As such, the initialization process of this class can be costly, and thus, we recommend that instances be long-lived. Thread Safety Considerations: Instances of `Deeptone` are thread-safe. However, the actual inference process is done within a critical section, meaning that performance might be limited when using a single instance across multiple threads. If performance is a critical requirement, youshould either ensure each thread has its own `Deeptone` instance (usage of a pool is recommended). Raises: LicenseManagerError: When the License Key is invalid or cannot be validated """