import datetime
+import json
import os
+import statistics
import urllib.parse
from ckeditor.fields import RichTextField
return False
return bool(self.duration < min(self.get_durations()) * 0.5)
+ def has_low_volume(self):
+ waveform_json = self.get_format_path('waveform.json')
+ if os.path.exists(waveform_json):
+ with open(waveform_json) as wavefile_fd:
+ median_volume = statistics.median(json.load(wavefile_fd))
+ return bool(median_volume < 10)
+ return False
+
def __str__(self):
return '%s - %s' % (self.title or self.id, self.episode.title)
<div class="errornotice">
{% trans "An episode should have only one main sound." %}
</div>
+ {% elif episode.main_sound.has_low_volume %}
+ <div class="errornotice">
+ {% trans "The audio volume of the main soundfile is too low." %}
+ {% if has_future_diffusion %}
+ {% trans "You should replace that file before it is broadcasted." %}
+ {% endif %}
+ </div>
{% endif %}
<table id="soundfiles"