|
@@ -5,6 +5,8 @@ import random |
|
|
import subprocess |
|
|
import subprocess |
|
|
from ast import literal_eval |
|
|
from ast import literal_eval |
|
|
from pipeline.utils import SourceMedia, Feature, Interval |
|
|
from pipeline.utils import SourceMedia, Feature, Interval |
|
|
|
|
|
from pipeline.utils import SourceMedia, Source, Feature, Interval |
|
|
|
|
|
|
|
|
# for loudness detection |
|
|
# for loudness detection |
|
|
import soundfile |
|
|
import soundfile |
|
|
import pyloudnorm |
|
|
import pyloudnorm |
|
@@ -114,7 +116,7 @@ class LaughterFeatureExtractor(FeatureExtractor): |
|
|
for laugh in laughs: |
|
|
for laugh in laughs: |
|
|
start, end = laugh |
|
|
start, end = laugh |
|
|
self.features.append(Feature(interval=Interval(start=start, end=end), |
|
|
self.features.append(Feature(interval=Interval(start=start, end=end), |
|
|
source="laughter", path=file.path)) |
|
|
|
|
|
|
|
|
source=file, feature_extractor="laughter")) |
|
|
# TODO: implement options eg minimum feature length |
|
|
# TODO: implement options eg minimum feature length |
|
|
|
|
|
|
|
|
# adjust features |
|
|
# adjust features |
|
@@ -165,7 +167,12 @@ class RandomFeatureExtractor(FeatureExtractor): |
|
|
duration = random.random() * self.MAX_DURATION |
|
|
duration = random.random() * self.MAX_DURATION |
|
|
start = random.random() * file.duration() - duration |
|
|
start = random.random() * file.duration() - duration |
|
|
self.features.append(Feature(interval=Interval(start=start, duration=duration), |
|
|
self.features.append(Feature(interval=Interval(start=start, duration=duration), |
|
|
source="random", path=file.path)) |
|
|
|
|
|
|
|
|
source=file, feature_extractor="random")) |
|
|
|
|
|
|
|
|
|
|
|
def teardown(self): |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LoudAudioFeatureExtractor(FeatureExtractor): |
|
|
class LoudAudioFeatureExtractor(FeatureExtractor): |
|
|
"""Feature extractor for loud audio detection. |
|
|
"""Feature extractor for loud audio detection. |
|
|
|
|
|
|
|
|