akshansh36 commited on
Commit
ce2ef70
·
verified ·
1 Parent(s): 9c4f35f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
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
- # Assuming 'audio' is received as numpy array, convert to torch tensor
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 ensure it's returned as a tuple with the sample rate
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)