Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,11 +9,11 @@ import numpy as np
|
|
9 |
import soundfile as sf
|
10 |
import os
|
11 |
import random
|
|
|
12 |
|
13 |
# Load your Pix2Pix model (make sure the path is correct)
|
14 |
model = load_model('./model_022600.h5', compile=False)
|
15 |
|
16 |
-
|
17 |
# Function to shift frequencies
|
18 |
def shift_frequencies(spectrogram, shift):
|
19 |
return np.roll(spectrogram, shift, axis=0)
|
@@ -97,10 +97,11 @@ def process_image(input_image):
|
|
97 |
wav = librosa.feature.inverse.mel_to_audio(img, sr=44100, n_fft=2048, hop_length=512)
|
98 |
|
99 |
# Save the audio file to a temporary location
|
100 |
-
|
101 |
-
|
|
|
102 |
|
103 |
-
return
|
104 |
|
105 |
# Create a Gradio interface
|
106 |
interface = gr.Interface(
|
|
|
9 |
import soundfile as sf
|
10 |
import os
|
11 |
import random
|
12 |
+
import tempfile # For temporary file handling
|
13 |
|
14 |
# Load your Pix2Pix model (make sure the path is correct)
|
15 |
model = load_model('./model_022600.h5', compile=False)
|
16 |
|
|
|
17 |
# Function to shift frequencies
|
18 |
def shift_frequencies(spectrogram, shift):
|
19 |
return np.roll(spectrogram, shift, axis=0)
|
|
|
97 |
wav = librosa.feature.inverse.mel_to_audio(img, sr=44100, n_fft=2048, hop_length=512)
|
98 |
|
99 |
# Save the audio file to a temporary location
|
100 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_audio_file:
|
101 |
+
sf.write(temp_audio_file.name, wav, samplerate=44100)
|
102 |
+
audio_file_path = temp_audio_file.name
|
103 |
|
104 |
+
return audio_file_path # Return the file path
|
105 |
|
106 |
# Create a Gradio interface
|
107 |
interface = gr.Interface(
|