humair025 commited on
Commit
e54e4dc
·
verified ·
1 Parent(s): 4b1cd22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -13,7 +13,7 @@ import matplotlib.pyplot as plt
13
  import numpy as np
14
  import torch
15
  from loguru import logger
16
- from PIL import Image
17
  from torch import Tensor
18
  from torchaudio.backend.common import AudioMetaData
19
 
@@ -247,7 +247,7 @@ class SpectrogramVisualizer:
247
  n_fft: int = 1024,
248
  hop: int = 512,
249
  title: Optional[str] = None,
250
- ) -> Image:
251
  """Create spectrogram image from audio tensor"""
252
  audio = torch.as_tensor(audio)
253
 
@@ -276,7 +276,7 @@ class SpectrogramVisualizer:
276
  )
277
 
278
  figure.canvas.draw()
279
- return Image.frombytes(
280
  "RGB",
281
  figure.canvas.get_width_height(),
282
  figure.canvas.tostring_rgb()
@@ -360,7 +360,7 @@ def process_audio(
360
  noise_type: str,
361
  snr: int,
362
  mic_input: Optional[str] = None,
363
- ) -> Tuple[str, Image, str, Image]:
364
  """Main audio processing pipeline.
365
 
366
  Args:
@@ -604,5 +604,5 @@ if __name__ == "__main__":
604
  demo.queue().launch(
605
  server_name="0.0.0.0",
606
  server_port=7860,
607
- share=True,
608
  )
 
13
  import numpy as np
14
  import torch
15
  from loguru import logger
16
+ from PIL import Image as PILImage
17
  from torch import Tensor
18
  from torchaudio.backend.common import AudioMetaData
19
 
 
247
  n_fft: int = 1024,
248
  hop: int = 512,
249
  title: Optional[str] = None,
250
+ ) -> PILImage.Image:
251
  """Create spectrogram image from audio tensor"""
252
  audio = torch.as_tensor(audio)
253
 
 
276
  )
277
 
278
  figure.canvas.draw()
279
+ return PILImage.frombytes(
280
  "RGB",
281
  figure.canvas.get_width_height(),
282
  figure.canvas.tostring_rgb()
 
360
  noise_type: str,
361
  snr: int,
362
  mic_input: Optional[str] = None,
363
+ ) -> Tuple[str, PILImage.Image, str, PILImage.Image]:
364
  """Main audio processing pipeline.
365
 
366
  Args:
 
604
  demo.queue().launch(
605
  server_name="0.0.0.0",
606
  server_port=7860,
607
+ share=False,
608
  )