Repository: speechbrain/speechbrain

Issue:
When running pytest, an new exp folder appears
Another small issue: when running pytest, a new exp folder appears. The exp folder contains speech samples from the data_augmentation part.


Discussion:
I think its a good idea to remove the outputs from these examples. Users can run the minimal examples to listen to samples.
I think we can keep it, but maybe putting it in the local experment
folder...in my case it was in the main speechbrain one

On May 16, 2020 19:39, "Peter Massey-Plantinga" <notifications@github.com>
wrote:

I think its a good idea to remove the outputs from these examples. Users
can run the minimal examples to listen to samples.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/speechbrain/speechbrain/issues/90#issuecomment-629720026>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEA2ZVVSO633AWSVM3YXDS3RR4PZ5ANCNFSM4NDCDJWA>
.


Resolving patch:
diff --git a/speechbrain/processing/signal_processing.py b/speechbrain/processing/signal_processing.py
--- a/speechbrain/processing/signal_processing.py
+++ b/speechbrain/processing/signal_processing.py
@@ -82,13 +82,10 @@ def convolve1d(
     Example
     -------
     >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> signal = torch.tensor(signal[None, :, None])
     >>> filter = torch.rand(1, 10, 1, dtype=signal.dtype)
     >>> signal = convolve1d(signal, filter, padding=(9, 0))
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(signal, ['example_conv'], torch.ones(1))
     """
     if len(waveform.shape) != 3:
         raise ValueError("Convolve1D expects a 3-dimensional tensor")
@@ -196,13 +193,10 @@ def notch_filter(notch_freq, filter_width=101, notch_width=0.05):
     Example
     -------
     >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> signal = torch.tensor(signal, dtype=torch.float32)[None, :, None]
     >>> kernel = notch_filter(0.25)
     >>> notched_signal = convolve1d(signal, kernel)
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(notched_signal, ['freq_drop'], torch.ones(1))
     """
 
     # Check inputs
diff --git a/speechbrain/processing/speech_augmentation.py b/speechbrain/processing/speech_augmentation.py
--- a/speechbrain/processing/speech_augmentation.py
+++ b/speechbrain/processing/speech_augmentation.py
@@ -14,6 +14,7 @@
 # Importing libraries
 import math
 import torch
+import soundfile as sf  # noqa
 from speechbrain.data_io.data_io import DataLoaderFactory
 from speechbrain.processing.signal_processing import (
     compute_amplitude,
@@ -59,14 +60,10 @@ class AddNoise(torch.nn.Module):
 
     Example
     -------
-    >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> noisifier = AddNoise('samples/noise_samples/noise.csv')
     >>> clean = torch.tensor([signal], dtype=torch.float32)
     >>> noisy = noisifier(clean, torch.ones(1))
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(noisy, ['example_add_noise'], torch.ones(1))
     """
 
     def __init__(
@@ -233,14 +230,10 @@ class AddReverb(torch.nn.Module):
 
     Example
     -------
-    >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> reverb = AddReverb('samples/rir_samples/rirs.csv')
     >>> clean = torch.tensor([signal], dtype=torch.float32)
     >>> reverbed = reverb(clean, torch.ones(1))
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(reverbed, ['example_add_reverb'], torch.ones(1))
     """
 
     def __init__(
@@ -356,14 +349,14 @@ class SpeedPerturb(torch.nn.Module):
 
     Example
     -------
-    >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> perturbator = SpeedPerturb(orig_freq=rate, speeds=[90])
     >>> clean = torch.tensor(signal, dtype=torch.float32).unsqueeze(0)
     >>> perturbed = perturbator(clean)
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(perturbed, ['example_perturb'], torch.ones(1))
+    >>> clean.shape
+    torch.Size([1, 52173])
+    >>> perturbed.shape
+    torch.Size([1, 46956])
     """
 
     def __init__(
@@ -429,18 +422,14 @@ class Resample(torch.nn.Module):
 
     Example
     -------
-    >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
-    >>> signal = torch.tensor(signal, dtype=torch.float32)[None, :, None]
+    >>> signal = torch.tensor(signal, dtype=torch.float32)[None, :]
     >>> resampler = Resample(orig_freq=rate, new_freq=rate // 2)
     >>> resampled = resampler(signal)
-    >>> save_signal = TensorSaver(
-    ...     save_folder='exp/example',
-    ...     save_format='wav',
-    ...     sampling_rate=rate // 2,
-    ... )
-    >>> save_signal(resampled, ["example_resamp"], torch.ones(1))
+    >>> signal.shape
+    torch.Size([1, 52173])
+    >>> resampled.shape
+    torch.Size([1, 26087])
     """
 
     def __init__(
@@ -739,8 +728,6 @@ class AddBabble(torch.nn.Module):
 
     Example
     -------
-    >>> from speechbrain.data_io.data_io import TensorSaver
-    >>> from speechbrain.data_io.data_io import DataLoaderFactory
     >>> babbler = AddBabble()
     >>> dataloader = DataLoaderFactory(
     ...     csv_file='samples/audio_samples/csv_example3.csv',
@@ -749,8 +736,6 @@ class AddBabble(torch.nn.Module):
     >>> loader = zip(*dataloader())
     >>> ids, batch, lengths = next(loader)[0]
     >>> noisy = babbler(batch, lengths)
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(noisy, ids, lengths)
     """
 
     def __init__(
@@ -836,14 +821,10 @@ class DropFreq(torch.nn.Module):
 
     Example
     -------
-    >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
     >>> dropper = DropFreq()
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> signal = torch.tensor(signal, dtype=torch.float32)
     >>> dropped_signal = dropper(signal.unsqueeze(0))
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(dropped_signal, ['freq_drop'], torch.ones(1))
     """
 
     def __init__(
@@ -948,15 +929,13 @@ class DropChunk(torch.nn.Module):
 
     Example
     -------
-    >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
-    >>> dropper = DropChunk()
+    >>> dropper = DropChunk(drop_start=100, drop_end=200)
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> signal = torch.tensor(signal).unsqueeze(0)
     >>> length = torch.ones(1)
     >>> dropped_signal = dropper(signal, length)
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(dropped_signal, ['drop_chunk'], length)
+    >>> float(dropped_signal[:, 150])
+    0.0
     """
 
     def __init__(
@@ -1073,13 +1052,11 @@ class DoClip(torch.nn.Module):
 
     Example
     -------
-    >>> import soundfile as sf
-    >>> from speechbrain.data_io.data_io import TensorSaver
-    >>> clipper = DoClip()
+    >>> clipper = DoClip(clip_low=0.01, clip_high=0.01)
     >>> signal, rate = sf.read('samples/audio_samples/example1.wav')
     >>> clipped_signal = clipper(torch.tensor(signal).unsqueeze(0))
-    >>> save_signal = TensorSaver(save_folder='exp/example', save_format='wav')
-    >>> save_signal(clipped_signal, ['clip'], torch.ones(1))
+    >>> "%.2f" % clipped_signal.max()
+    '0.01'
     """
 
     def __init__(


Test patch: