Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,9 +15,11 @@ import torch
|
|
| 15 |
# with gr.Blocks() as demo:
|
| 16 |
# gr.Audio(type="file", label="Upload Audio", elem_id="audio_input").submit(audio_function)
|
| 17 |
|
|
|
|
|
|
|
| 18 |
def audio_to_pt(audio_file):
|
| 19 |
# Step 1: Load audio
|
| 20 |
-
waveform, sample_rate = torchaudio.load(audio_file.name)
|
| 21 |
|
| 22 |
# Step 2: Preprocess (e.g., normalize, resample if necessary)
|
| 23 |
# Normalize waveform to [-1, 1]
|
|
@@ -32,10 +34,10 @@ def audio_to_pt(audio_file):
|
|
| 32 |
# Step 4: Gradio Interface
|
| 33 |
interface = gr.Interface(
|
| 34 |
fn=audio_to_pt,
|
| 35 |
-
inputs=gr.Audio(label="Upload Audio", type="
|
| 36 |
outputs="file",
|
| 37 |
title="Audio to PyTorch File Converter",
|
| 38 |
-
description="Upload an MP3 or
|
| 39 |
)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
|
|
|
| 15 |
# with gr.Blocks() as demo:
|
| 16 |
# gr.Audio(type="file", label="Upload Audio", elem_id="audio_input").submit(audio_function)
|
| 17 |
|
| 18 |
+
|
| 19 |
+
|
| 20 |
def audio_to_pt(audio_file):
|
| 21 |
# Step 1: Load audio
|
| 22 |
+
waveform, sample_rate = torchaudio.load(audio_file.name) # Changed to handle filepath input
|
| 23 |
|
| 24 |
# Step 2: Preprocess (e.g., normalize, resample if necessary)
|
| 25 |
# Normalize waveform to [-1, 1]
|
|
|
|
| 34 |
# Step 4: Gradio Interface
|
| 35 |
interface = gr.Interface(
|
| 36 |
fn=audio_to_pt,
|
| 37 |
+
inputs=gr.Audio(label="Upload Audio", type="filepath"), # Use "filepath" instead of "file"
|
| 38 |
outputs="file",
|
| 39 |
title="Audio to PyTorch File Converter",
|
| 40 |
+
description="Upload an MP3 or WAV file to convert it into a .pt file for training."
|
| 41 |
)
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|