Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -52,12 +52,8 @@ def process_audio_to_segments(audio_file):
|
|
52 |
end_pitch_shift = 12
|
53 |
pitch_increment = (end_pitch_shift - start_pitch_shift) / (len(midi_notes) - 1) # Accurate pitch increment
|
54 |
|
55 |
-
# Extract audio segments for each MIDI note
|
56 |
for i, note in enumerate(midi_notes):
|
57 |
-
# Ensure we don't exceed the audio length
|
58 |
-
if audio_length < segment_length:
|
59 |
-
raise ValueError("Audio length is less than segment length.")
|
60 |
-
|
61 |
# Random start point for segment, ensuring it fits the segment length
|
62 |
start_point = random.randint(0, max(0, audio_length - segment_length))
|
63 |
audio_segment = audio[start_point:start_point + segment_length]
|
@@ -90,5 +86,5 @@ gr.Interface(
|
|
90 |
inputs=inputs,
|
91 |
outputs=outputs,
|
92 |
title="Audio to Chromatic Scale Segments",
|
93 |
-
description="Upload an audio file, and the program will cut it into 73 segments, each between 0.6 and 0.7 seconds long, based on a MIDI chromatic scale, ordered from the lowest to highest pitch, and generate a combined audio file for download."
|
94 |
).launch()
|
|
|
52 |
end_pitch_shift = 12
|
53 |
pitch_increment = (end_pitch_shift - start_pitch_shift) / (len(midi_notes) - 1) # Accurate pitch increment
|
54 |
|
55 |
+
# Extract random audio segments for each MIDI note
|
56 |
for i, note in enumerate(midi_notes):
|
|
|
|
|
|
|
|
|
57 |
# Random start point for segment, ensuring it fits the segment length
|
58 |
start_point = random.randint(0, max(0, audio_length - segment_length))
|
59 |
audio_segment = audio[start_point:start_point + segment_length]
|
|
|
86 |
inputs=inputs,
|
87 |
outputs=outputs,
|
88 |
title="Audio to Chromatic Scale Segments",
|
89 |
+
description="Upload an audio file, and the program will cut it into 73 random segments, each between 0.6 and 0.7 seconds long, based on a MIDI chromatic scale, ordered from the lowest to highest pitch, and generate a combined audio file for download."
|
90 |
).launch()
|