Spaces:
Runtime error
Runtime error
alexander-lazarin
commited on
fix bugs
Browse files
app.py
CHANGED
@@ -8,13 +8,13 @@ def cut_audio(audio, start_time, end_time):
|
|
8 |
end_time_ms = end_time * 1000
|
9 |
|
10 |
# Load the audio file using pydub
|
11 |
-
audio_segment = AudioSegment.from_file(audio
|
12 |
|
13 |
# Cut the audio segment
|
14 |
cut_segment = audio_segment[start_time_ms:end_time_ms]
|
15 |
|
16 |
# Determine the output format based on the original file extension
|
17 |
-
file_ext = os.path.splitext(audio
|
18 |
|
19 |
# Create a temporary file to save the cut audio
|
20 |
output_file = f"cut_audio{file_ext}"
|
@@ -26,11 +26,11 @@ def cut_audio(audio, start_time, end_time):
|
|
26 |
interface = gr.Interface(
|
27 |
fn=cut_audio,
|
28 |
inputs=[
|
29 |
-
gr.Audio(
|
30 |
gr.Number(label="Start Time (seconds)"), # Numeric input for start time
|
31 |
gr.Number(label="End Time (seconds)") # Numeric input for end time
|
32 |
],
|
33 |
-
outputs=gr.
|
34 |
title="Audio Cutter",
|
35 |
description="Upload an audio file and specify the start and end times to cut the audio. The output will be the cut audio in the same format as the original."
|
36 |
)
|
|
|
8 |
end_time_ms = end_time * 1000
|
9 |
|
10 |
# Load the audio file using pydub
|
11 |
+
audio_segment = AudioSegment.from_file(audio)
|
12 |
|
13 |
# Cut the audio segment
|
14 |
cut_segment = audio_segment[start_time_ms:end_time_ms]
|
15 |
|
16 |
# Determine the output format based on the original file extension
|
17 |
+
file_ext = os.path.splitext(audio)[-1].lower()
|
18 |
|
19 |
# Create a temporary file to save the cut audio
|
20 |
output_file = f"cut_audio{file_ext}"
|
|
|
26 |
interface = gr.Interface(
|
27 |
fn=cut_audio,
|
28 |
inputs=[
|
29 |
+
gr.Audio(sources="upload", type="filepath"), # Audio input
|
30 |
gr.Number(label="Start Time (seconds)"), # Numeric input for start time
|
31 |
gr.Number(label="End Time (seconds)") # Numeric input for end time
|
32 |
],
|
33 |
+
outputs=gr.Audio(label="Cut Audio"), # Output the cut audio file
|
34 |
title="Audio Cutter",
|
35 |
description="Upload an audio file and specify the start and end times to cut the audio. The output will be the cut audio in the same format as the original."
|
36 |
)
|