Added tracing to classification
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-07-30 15:24:57 +02:00
parent 0245cd7b6a
commit 1acdd6d21c
3 changed files with 44 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import tempfile
import os
import os.path
import shutil
import opentracing
import librosa
import librosa.display
@@ -83,10 +84,13 @@ class Classifier(object):
return predicted_class_name, labeled_predictions
def predict(self, wav_filename: str) -> Tuple[str, dict]:
directory, _ = self.create_spectrogram(wav_filename)
def predict(self, wav_filename: str, span: opentracing.span.Span) -> Tuple[str, dict]:
with opentracing.tracer.start_span('createSpectrogram', child_of=span):
directory, _ = self.create_spectrogram(wav_filename)
with opentracing.tracer.start_span('runPredictor', child_of=span):
result = self._run_predictor(directory)
result = self._run_predictor(directory)
shutil.rmtree(directory) # The image is no longer needed
return result