Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,7 @@ def process_audio_stream(audio, instream):
|
|
41 |
if instream is None:
|
42 |
instream = torch.zeros(0, dtype=torch.float32)
|
43 |
|
44 |
-
#
|
45 |
audio_data = torch.tensor(audio[1], dtype=torch.float32)
|
46 |
|
47 |
# Append new data to audio buffer
|
@@ -62,12 +62,13 @@ def process_audio_stream(audio, instream):
|
|
62 |
# Append the processed output to instream for continuous processing
|
63 |
instream = torch.cat((instream, output))
|
64 |
|
65 |
-
# Convert the output to a numpy array and
|
66 |
return (instream.numpy(), sr), (instream.numpy(), sr)
|
67 |
else:
|
68 |
return gr.update(), instream
|
69 |
|
70 |
|
|
|
71 |
# Function to save audio to file
|
72 |
def save_audio(audio, audio_path, sample_rate):
|
73 |
torchaudio.save(audio_path, torch.tensor(audio, dtype=torch.float32), sample_rate)
|
|
|
41 |
if instream is None:
|
42 |
instream = torch.zeros(0, dtype=torch.float32)
|
43 |
|
44 |
+
# Convert audio data to torch tensor
|
45 |
audio_data = torch.tensor(audio[1], dtype=torch.float32)
|
46 |
|
47 |
# Append new data to audio buffer
|
|
|
62 |
# Append the processed output to instream for continuous processing
|
63 |
instream = torch.cat((instream, output))
|
64 |
|
65 |
+
# Convert the output to a numpy array and return as a tuple with sample rate
|
66 |
return (instream.numpy(), sr), (instream.numpy(), sr)
|
67 |
else:
|
68 |
return gr.update(), instream
|
69 |
|
70 |
|
71 |
+
|
72 |
# Function to save audio to file
|
73 |
def save_audio(audio, audio_path, sample_rate):
|
74 |
torchaudio.save(audio_path, torch.tensor(audio, dtype=torch.float32), sample_rate)
|