Commit b1439e6c authored by David Trattnig's avatar David Trattnig
Browse files

Calculate track duration.

parent 97ed7425
......@@ -33,12 +33,14 @@ __author__ = 'David Trattnig <david.trattnig@subsquare.at>'
import os, os.path
import logging
import random
import librosa
from accessify import private, protected
from modules.base.simpleutil import SimpleUtil
from accessify import private, protected
from modules.base.simpleutil import SimpleUtil
from modules.communication.mail import AuraMailer
class FallbackManager:
"""
Handles all types of fallbacks in case there is an outage
......@@ -150,6 +152,15 @@ class FallbackManager:
self.logger.info("Now playing: fallback track '%s - %s'." % (artist, title))
def get_track_duration(self, file):
"""
Returns the length of the given audio file.
"""
y, sr = librosa.load(file)
duration = librosa.get_duration(y=y, sr=sr)
return duration
#
# PRIVATE METHODS
#
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment