From 2ec99681f053b2e11b29c80c823e48d38de5f54d Mon Sep 17 00:00:00 2001 From: "jordi.hasianta" Date: Thu, 15 Sep 2022 19:47:27 +0700 Subject: [PATCH] add private module to create model object for speech api --- opendbm/api_lib/speech/__init__.py | 1 + opendbm/api_lib/speech/_speech_features.py | 34 ++++++++++++++++++++++ opendbm/api_lib/speech/_transcribe.py | 16 ++++++++++ 3 files changed, 51 insertions(+) create mode 100644 opendbm/api_lib/speech/__init__.py create mode 100644 opendbm/api_lib/speech/_speech_features.py create mode 100644 opendbm/api_lib/speech/_transcribe.py diff --git a/opendbm/api_lib/speech/__init__.py b/opendbm/api_lib/speech/__init__.py new file mode 100644 index 00000000..d3803da2 --- /dev/null +++ b/opendbm/api_lib/speech/__init__.py @@ -0,0 +1 @@ +from opendbm.api_lib.speech.api import Speech diff --git a/opendbm/api_lib/speech/_speech_features.py b/opendbm/api_lib/speech/_speech_features.py new file mode 100644 index 00000000..6e21357b --- /dev/null +++ b/opendbm/api_lib/speech/_speech_features.py @@ -0,0 +1,34 @@ +import tempfile + +from opendbm.api_lib.model import OPENDBM_DATA, AudioModel +from opendbm.dbm_lib import run_speech_feature + + +class SpeechFeature(AudioModel): + def __init__(self): + super().__init__() + self._params = [ + "nlp_numSentences", + "nlp_singPronPerAns", + "nlp_singPronPerSen", + "nlp_pastTensePerAns", + "nlp_pastTensePerSen", + "nlp_pronounsPerAns", + "nlp_pronounsPerSen", + "nlp_verbsPerAns", + "nlp_verbsPerSen", + "nlp_adjectivesPerAns", + "nlp_adjectivesPerSen", + "nlp_nounsPerAns", + "nlp_nounsPerSen", + "nlp_sentiment_mean", + "nlp_mattr", + "nlp_wordsPerMin", + "nlp_totalTime", + ] + + @AudioModel.prep_func + def _fit_transform(self, path): + return run_speech_feature( + path, f"{tempfile.gettempdir()}/", self.r_config, OPENDBM_DATA, save=False + ) diff --git a/opendbm/api_lib/speech/_transcribe.py b/opendbm/api_lib/speech/_transcribe.py new file mode 100644 index 00000000..ba201d58 --- /dev/null +++ b/opendbm/api_lib/speech/_transcribe.py @@ -0,0 +1,16 @@ +import tempfile + +from opendbm.api_lib.model import OPENDBM_DATA, AudioModel +from opendbm.dbm_lib.dbm_features.raw_features.nlp.transcribe import run_transcribe + + +class Transcribe(AudioModel): + def __init__(self): + super().__init__() + self._params = ["nlp_transcribe", "nlp_totalTime"] + + @AudioModel.prep_func + def _fit_transform(self, path): + return run_transcribe( + path, f"{tempfile.gettempdir()}/", self.r_config, OPENDBM_DATA, save=False + )