Spaces:
Runtime error
Runtime error
TheStinger
commited on
Commit
•
e98affd
1
Parent(s):
9262002
Update app.py
Browse files
app.py
CHANGED
@@ -50,17 +50,17 @@ def create_spectrogram_and_get_info(audio_file):
|
|
50 |
|
51 |
# Get the audio file info
|
52 |
audio_info = sf.info(audio_file)
|
53 |
-
|
54 |
bit_depth = {'PCM_16': 16, 'FLOAT': 32}.get(audio_info.subtype, 0)
|
55 |
|
56 |
# Convert duration to minutes, seconds, and milliseconds
|
57 |
minutes, seconds = divmod(audio_info.duration, 60)
|
58 |
seconds, milliseconds = divmod(seconds, 1)
|
59 |
milliseconds *= 1000 # convert from seconds to milliseconds
|
60 |
-
|
61 |
# Convert bitrate to Mb/s
|
62 |
bitrate = audio_info.samplerate * audio_info.channels * bit_depth / 8 / 1024 / 1024
|
63 |
-
|
64 |
# Create a table with the audio file info
|
65 |
info_table = f"""
|
66 |
|
@@ -70,9 +70,9 @@ def create_spectrogram_and_get_info(audio_file):
|
|
70 |
| Samples per second | {audio_info.samplerate} Hz |
|
71 |
| Audio Channels | {audio_info.channels} |
|
72 |
| Bitrate | {bitrate:.2f} Mb/s |
|
73 |
-
|
|
74 |
"""
|
75 |
-
|
76 |
# Return the PNG file of the spectrogram and the info table
|
77 |
return info_table, 'spectrogram.png'
|
78 |
|
|
|
50 |
|
51 |
# Get the audio file info
|
52 |
audio_info = sf.info(audio_file)
|
53 |
+
|
54 |
bit_depth = {'PCM_16': 16, 'FLOAT': 32}.get(audio_info.subtype, 0)
|
55 |
|
56 |
# Convert duration to minutes, seconds, and milliseconds
|
57 |
minutes, seconds = divmod(audio_info.duration, 60)
|
58 |
seconds, milliseconds = divmod(seconds, 1)
|
59 |
milliseconds *= 1000 # convert from seconds to milliseconds
|
60 |
+
|
61 |
# Convert bitrate to Mb/s
|
62 |
bitrate = audio_info.samplerate * audio_info.channels * bit_depth / 8 / 1024 / 1024
|
63 |
+
|
64 |
# Create a table with the audio file info
|
65 |
info_table = f"""
|
66 |
|
|
|
70 |
| Samples per second | {audio_info.samplerate} Hz |
|
71 |
| Audio Channels | {audio_info.channels} |
|
72 |
| Bitrate | {bitrate:.2f} Mb/s |
|
73 |
+
| Format | {audio_info.format} |
|
74 |
"""
|
75 |
+
|
76 |
# Return the PNG file of the spectrogram and the info table
|
77 |
return info_table, 'spectrogram.png'
|
78 |
|