From f7700ac3794400b2710305e4833f3e7cb492d05b Mon Sep 17 00:00:00 2001 From: Gabrielparizet Date: Mon, 3 Apr 2023 17:51:39 +0200 Subject: [PATCH] (Build) Modify tempo and duration response formats --- api/length_detector.py | 2 +- api/tempo_detector.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/length_detector.py b/api/length_detector.py index 1b5c6bf..830e44a 100644 --- a/api/length_detector.py +++ b/api/length_detector.py @@ -7,7 +7,7 @@ def find_length(filename): # Get the duration of our audiofile in seconds with librosa get_duration method. duration = librosa.get_duration(y=y, sr=sr) file_duration = seconds_to_minutes(duration) - return f'Your audio file is {file_duration} long.' + return file_duration # The seconds_to_minutes function takes time in float as an argument and converts it to string giving its time in minutes and seconds. diff --git a/api/tempo_detector.py b/api/tempo_detector.py index 4e97ab9..8d4bf0a 100644 --- a/api/tempo_detector.py +++ b/api/tempo_detector.py @@ -8,7 +8,7 @@ def find_tempo(filename): # librosa.beat.beat_track is used to calculate the tempo of the audio file based on its beat frames, which are stored in beat_frames. tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr) file_tempo = format_tempo(tempo) - return f'Your audio file tempo is of {file_tempo} bpm.' + return file_tempo # format_tempo takes a floating-point number and returns a string representation of that number with two decimal places. def format_tempo(float):