We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
E   TypeError: save() missing 1 required positional argument: 'sample_rate'
Hello,

Getting error in using 

`enhancer = SpectralMaskEnhancement.from_hparams(
    source="speechbrain/mtl-mimic-voicebank",
    savedir='stream_folder/',
    run_opts={"device":"cuda"})

enhanced = enhancer.enhance_file("stream_folder/fr_yourname.wav", output="stream_folder/test.wav)`

test_speechbrain.py:None (test_speechbrain.py)
test_speechbrain.py:13: in <module>
    enhanced = enhancer.enhance_file("stream_folder/fr_yourname.wav",
/home/tim/env/python3.8/lib/python3.8/site-packages/speechbrain/pretrained/interfaces.py:1929: in enhance_file
    torchaudio.save(output_filename, enhanced, channels_first=False)
E   TypeError: save() missing 1 required positional argument: 'sample_rate'

probably an update on torchaudio.save you need to handle.

Regards

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `speechbrain/inference/enhancement.py`
Content:
```
1 """ Specifies the inference interfaces for speech enhancement modules.
2 
3 Authors:
4  * Aku Rouhe 2021
5  * Peter Plantinga 2021
6  * Loren Lugosch 2020
7  * Mirco Ravanelli 2020
8  * Titouan Parcollet 2021
9  * Abdel Heba 2021
10  * Andreas Nautsch 2022, 2023
11  * Pooneh Mousavi 2023
12  * Sylvain de Langen 2023
13  * Adel Moumen 2023
14  * Pradnya Kandarkar 2023
15 """
16 import torch
17 import torchaudio
18 from speechbrain.inference.interfaces import Pretrained
19 from speechbrain.utils.callchains import lengths_arg_exists
20 
21 
22 class SpectralMaskEnhancement(Pretrained):
23     """A ready-to-use model for speech enhancement.
24 
25     Arguments
26     ---------
27     See ``Pretrained``.
28 
29     Example
30     -------
31     >>> import torch
32     >>> from speechbrain.inference.enhancement import SpectralMaskEnhancement
33     >>> # Model is downloaded from the speechbrain HuggingFace repo
34     >>> tmpdir = getfixture("tmpdir")
35     >>> enhancer = SpectralMaskEnhancement.from_hparams(
36     ...     source="speechbrain/metricgan-plus-voicebank",
37     ...     savedir=tmpdir,
38     ... )
39     >>> enhanced = enhancer.enhance_file(
40     ...     "speechbrain/metricgan-plus-voicebank/example.wav"
41     ... )
42     """
43 
44     HPARAMS_NEEDED = ["compute_stft", "spectral_magnitude", "resynth"]
45     MODULES_NEEDED = ["enhance_model"]
46 
47     def compute_features(self, wavs):
48         """Compute the log spectral magnitude features for masking.
49 
50         Arguments
51         ---------
52         wavs : torch.Tensor
53             A batch of waveforms to convert to log spectral mags.
54         """
55         feats = self.hparams.compute_stft(wavs)
56         feats = self.hparams.spectral_magnitude(feats)
57         return torch.log1p(feats)
58 
59     def enhance_batch(self, noisy, lengths=None):
60         """Enhance a batch of noisy waveforms.
61 
62         Arguments
63         ---------
64         noisy : torch.Tensor
65             A batch of waveforms to perform enhancement on.
66         lengths : torch.Tensor
67             The lengths of the waveforms if the enhancement model handles them.
68 
69         Returns
70         -------
71         torch.Tensor
72             A batch of enhanced waveforms of the same shape as input.
73         """
74         noisy = noisy.to(self.device)
75         noisy_features = self.compute_features(noisy)
76 
77         # Perform masking-based enhancement, multiplying output with input.
78         if lengths is not None:
79             mask = self.mods.enhance_model(noisy_features, lengths=lengths)
80         else:
81             mask = self.mods.enhance_model(noisy_features)
82         enhanced = torch.mul(mask, noisy_features)
83 
84         # Return resynthesized waveforms
85         return self.hparams.resynth(torch.expm1(enhanced), noisy)
86 
87     def enhance_file(self, filename, output_filename=None, **kwargs):
88         """Enhance a wav file.
89 
90         Arguments
91         ---------
92         filename : str
93             Location on disk to load file for enhancement.
94         output_filename : str
95             If provided, writes enhanced data to this file.
96         """
97         noisy = self.load_audio(filename, **kwargs)
98         noisy = noisy.to(self.device)
99 
100         # Fake a batch:
101         batch = noisy.unsqueeze(0)
102         if lengths_arg_exists(self.enhance_batch):
103             enhanced = self.enhance_batch(batch, lengths=torch.tensor([1.0]))
104         else:
105             enhanced = self.enhance_batch(batch)
106 
107         if output_filename is not None:
108             torchaudio.save(output_filename, enhanced, channels_first=False)
109 
110         return enhanced.squeeze(0)
111 
112 
113 class WaveformEnhancement(Pretrained):
114     """A ready-to-use model for speech enhancement.
115 
116     Arguments
117     ---------
118     See ``Pretrained``.
119 
120     Example
121     -------
122     >>> from speechbrain.inference.enhancement import WaveformEnhancement
123     >>> # Model is downloaded from the speechbrain HuggingFace repo
124     >>> tmpdir = getfixture("tmpdir")
125     >>> enhancer = WaveformEnhancement.from_hparams(
126     ...     source="speechbrain/mtl-mimic-voicebank",
127     ...     savedir=tmpdir,
128     ... )
129     >>> enhanced = enhancer.enhance_file(
130     ...     "speechbrain/mtl-mimic-voicebank/example.wav"
131     ... )
132     """
133 
134     MODULES_NEEDED = ["enhance_model"]
135 
136     def enhance_batch(self, noisy, lengths=None):
137         """Enhance a batch of noisy waveforms.
138 
139         Arguments
140         ---------
141         noisy : torch.Tensor
142             A batch of waveforms to perform enhancement on.
143         lengths : torch.Tensor
144             The lengths of the waveforms if the enhancement model handles them.
145 
146         Returns
147         -------
148         torch.Tensor
149             A batch of enhanced waveforms of the same shape as input.
150         """
151         noisy = noisy.to(self.device)
152         enhanced_wav, _ = self.mods.enhance_model(noisy)
153         return enhanced_wav
154 
155     def enhance_file(self, filename, output_filename=None, **kwargs):
156         """Enhance a wav file.
157 
158         Arguments
159         ---------
160         filename : str
161             Location on disk to load file for enhancement.
162         output_filename : str
163             If provided, writes enhanced data to this file.
164         """
165         noisy = self.load_audio(filename, **kwargs)
166 
167         # Fake a batch:
168         batch = noisy.unsqueeze(0)
169         enhanced = self.enhance_batch(batch)
170 
171         if output_filename is not None:
172             torchaudio.save(output_filename, enhanced, channels_first=False)
173 
174         return enhanced.squeeze(0)
175 
176     def forward(self, noisy, lengths=None):
177         """Runs enhancement on the noisy input"""
178         return self.enhance_batch(noisy, lengths)
179
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/speechbrain/inference/enhancement.py b/speechbrain/inference/enhancement.py
--- a/speechbrain/inference/enhancement.py
+++ b/speechbrain/inference/enhancement.py
@@ -105,7 +105,11 @@
             enhanced = self.enhance_batch(batch)
 
         if output_filename is not None:
-            torchaudio.save(output_filename, enhanced, channels_first=False)
+            torchaudio.save(
+                uri=output_filename,
+                src=enhanced,
+                sample_rate=self.hparams.compute_stft.sample_rate,
+            )
 
         return enhanced.squeeze(0)
 
@@ -169,7 +173,11 @@
         enhanced = self.enhance_batch(batch)
 
         if output_filename is not None:
-            torchaudio.save(output_filename, enhanced, channels_first=False)
+            torchaudio.save(
+                uri=output_filename,
+                src=enhanced,
+                sample_rate=self.audio_normalizer.sample_rate,
+            )
 
         return enhanced.squeeze(0)

{"golden_diff": "diff --git a/speechbrain/inference/enhancement.py b/speechbrain/inference/enhancement.py\n--- a/speechbrain/inference/enhancement.py\n+++ b/speechbrain/inference/enhancement.py\n@@ -105,7 +105,11 @@\n             enhanced = self.enhance_batch(batch)\n \n         if output_filename is not None:\n-            torchaudio.save(output_filename, enhanced, channels_first=False)\n+            torchaudio.save(\n+                uri=output_filename,\n+                src=enhanced,\n+                sample_rate=self.hparams.compute_stft.sample_rate,\n+            )\n \n         return enhanced.squeeze(0)\n \n@@ -169,7 +173,11 @@\n         enhanced = self.enhance_batch(batch)\n \n         if output_filename is not None:\n-            torchaudio.save(output_filename, enhanced, channels_first=False)\n+            torchaudio.save(\n+                uri=output_filename,\n+                src=enhanced,\n+                sample_rate=self.audio_normalizer.sample_rate,\n+            )\n \n         return enhanced.squeeze(0)\n", "issue": "E   TypeError: save() missing 1 required positional argument: 'sample_rate'\nHello,\r\n\r\nGetting error in using \r\n\r\n`enhancer = SpectralMaskEnhancement.from_hparams(\r\n    source=\"speechbrain/mtl-mimic-voicebank\",\r\n    savedir='stream_folder/',\r\n    run_opts={\"device\":\"cuda\"})\r\n\r\nenhanced = enhancer.enhance_file(\"stream_folder/fr_yourname.wav\", output=\"stream_folder/test.wav)`\r\n\r\ntest_speechbrain.py:None (test_speechbrain.py)\r\ntest_speechbrain.py:13: in <module>\r\n    enhanced = enhancer.enhance_file(\"stream_folder/fr_yourname.wav\",\r\n/home/tim/env/python3.8/lib/python3.8/site-packages/speechbrain/pretrained/interfaces.py:1929: in enhance_file\r\n    torchaudio.save(output_filename, enhanced, channels_first=False)\r\nE   TypeError: save() missing 1 required positional argument: 'sample_rate'\r\n\r\nprobably an update on torchaudio.save you need to handle.\r\n\r\nRegards\n", "before_files": [{"content": "\"\"\" Specifies the inference interfaces for speech enhancement modules.\n\nAuthors:\n * Aku Rouhe 2021\n * Peter Plantinga 2021\n * Loren Lugosch 2020\n * Mirco Ravanelli 2020\n * Titouan Parcollet 2021\n * Abdel Heba 2021\n * Andreas Nautsch 2022, 2023\n * Pooneh Mousavi 2023\n * Sylvain de Langen 2023\n * Adel Moumen 2023\n * Pradnya Kandarkar 2023\n\"\"\"\nimport torch\nimport torchaudio\nfrom speechbrain.inference.interfaces import Pretrained\nfrom speechbrain.utils.callchains import lengths_arg_exists\n\n\nclass SpectralMaskEnhancement(Pretrained):\n    \"\"\"A ready-to-use model for speech enhancement.\n\n    Arguments\n    ---------\n    See ``Pretrained``.\n\n    Example\n    -------\n    >>> import torch\n    >>> from speechbrain.inference.enhancement import SpectralMaskEnhancement\n    >>> # Model is downloaded from the speechbrain HuggingFace repo\n    >>> tmpdir = getfixture(\"tmpdir\")\n    >>> enhancer = SpectralMaskEnhancement.from_hparams(\n    ...     source=\"speechbrain/metricgan-plus-voicebank\",\n    ...     savedir=tmpdir,\n    ... )\n    >>> enhanced = enhancer.enhance_file(\n    ...     \"speechbrain/metricgan-plus-voicebank/example.wav\"\n    ... )\n    \"\"\"\n\n    HPARAMS_NEEDED = [\"compute_stft\", \"spectral_magnitude\", \"resynth\"]\n    MODULES_NEEDED = [\"enhance_model\"]\n\n    def compute_features(self, wavs):\n        \"\"\"Compute the log spectral magnitude features for masking.\n\n        Arguments\n        ---------\n        wavs : torch.Tensor\n            A batch of waveforms to convert to log spectral mags.\n        \"\"\"\n        feats = self.hparams.compute_stft(wavs)\n        feats = self.hparams.spectral_magnitude(feats)\n        return torch.log1p(feats)\n\n    def enhance_batch(self, noisy, lengths=None):\n        \"\"\"Enhance a batch of noisy waveforms.\n\n        Arguments\n        ---------\n        noisy : torch.Tensor\n            A batch of waveforms to perform enhancement on.\n        lengths : torch.Tensor\n            The lengths of the waveforms if the enhancement model handles them.\n\n        Returns\n        -------\n        torch.Tensor\n            A batch of enhanced waveforms of the same shape as input.\n        \"\"\"\n        noisy = noisy.to(self.device)\n        noisy_features = self.compute_features(noisy)\n\n        # Perform masking-based enhancement, multiplying output with input.\n        if lengths is not None:\n            mask = self.mods.enhance_model(noisy_features, lengths=lengths)\n        else:\n            mask = self.mods.enhance_model(noisy_features)\n        enhanced = torch.mul(mask, noisy_features)\n\n        # Return resynthesized waveforms\n        return self.hparams.resynth(torch.expm1(enhanced), noisy)\n\n    def enhance_file(self, filename, output_filename=None, **kwargs):\n        \"\"\"Enhance a wav file.\n\n        Arguments\n        ---------\n        filename : str\n            Location on disk to load file for enhancement.\n        output_filename : str\n            If provided, writes enhanced data to this file.\n        \"\"\"\n        noisy = self.load_audio(filename, **kwargs)\n        noisy = noisy.to(self.device)\n\n        # Fake a batch:\n        batch = noisy.unsqueeze(0)\n        if lengths_arg_exists(self.enhance_batch):\n            enhanced = self.enhance_batch(batch, lengths=torch.tensor([1.0]))\n        else:\n            enhanced = self.enhance_batch(batch)\n\n        if output_filename is not None:\n            torchaudio.save(output_filename, enhanced, channels_first=False)\n\n        return enhanced.squeeze(0)\n\n\nclass WaveformEnhancement(Pretrained):\n    \"\"\"A ready-to-use model for speech enhancement.\n\n    Arguments\n    ---------\n    See ``Pretrained``.\n\n    Example\n    -------\n    >>> from speechbrain.inference.enhancement import WaveformEnhancement\n    >>> # Model is downloaded from the speechbrain HuggingFace repo\n    >>> tmpdir = getfixture(\"tmpdir\")\n    >>> enhancer = WaveformEnhancement.from_hparams(\n    ...     source=\"speechbrain/mtl-mimic-voicebank\",\n    ...     savedir=tmpdir,\n    ... )\n    >>> enhanced = enhancer.enhance_file(\n    ...     \"speechbrain/mtl-mimic-voicebank/example.wav\"\n    ... )\n    \"\"\"\n\n    MODULES_NEEDED = [\"enhance_model\"]\n\n    def enhance_batch(self, noisy, lengths=None):\n        \"\"\"Enhance a batch of noisy waveforms.\n\n        Arguments\n        ---------\n        noisy : torch.Tensor\n            A batch of waveforms to perform enhancement on.\n        lengths : torch.Tensor\n            The lengths of the waveforms if the enhancement model handles them.\n\n        Returns\n        -------\n        torch.Tensor\n            A batch of enhanced waveforms of the same shape as input.\n        \"\"\"\n        noisy = noisy.to(self.device)\n        enhanced_wav, _ = self.mods.enhance_model(noisy)\n        return enhanced_wav\n\n    def enhance_file(self, filename, output_filename=None, **kwargs):\n        \"\"\"Enhance a wav file.\n\n        Arguments\n        ---------\n        filename : str\n            Location on disk to load file for enhancement.\n        output_filename : str\n            If provided, writes enhanced data to this file.\n        \"\"\"\n        noisy = self.load_audio(filename, **kwargs)\n\n        # Fake a batch:\n        batch = noisy.unsqueeze(0)\n        enhanced = self.enhance_batch(batch)\n\n        if output_filename is not None:\n            torchaudio.save(output_filename, enhanced, channels_first=False)\n\n        return enhanced.squeeze(0)\n\n    def forward(self, noisy, lengths=None):\n        \"\"\"Runs enhancement on the noisy input\"\"\"\n        return self.enhance_batch(noisy, lengths)\n", "path": "speechbrain/inference/enhancement.py"}], "after_files": [{"content": "\"\"\" Specifies the inference interfaces for speech enhancement modules.\n\nAuthors:\n * Aku Rouhe 2021\n * Peter Plantinga 2021\n * Loren Lugosch 2020\n * Mirco Ravanelli 2020\n * Titouan Parcollet 2021\n * Abdel Heba 2021\n * Andreas Nautsch 2022, 2023\n * Pooneh Mousavi 2023\n * Sylvain de Langen 2023\n * Adel Moumen 2023\n * Pradnya Kandarkar 2023\n\"\"\"\nimport torch\nimport torchaudio\nfrom speechbrain.inference.interfaces import Pretrained\nfrom speechbrain.utils.callchains import lengths_arg_exists\n\n\nclass SpectralMaskEnhancement(Pretrained):\n    \"\"\"A ready-to-use model for speech enhancement.\n\n    Arguments\n    ---------\n    See ``Pretrained``.\n\n    Example\n    -------\n    >>> import torch\n    >>> from speechbrain.inference.enhancement import SpectralMaskEnhancement\n    >>> # Model is downloaded from the speechbrain HuggingFace repo\n    >>> tmpdir = getfixture(\"tmpdir\")\n    >>> enhancer = SpectralMaskEnhancement.from_hparams(\n    ...     source=\"speechbrain/metricgan-plus-voicebank\",\n    ...     savedir=tmpdir,\n    ... )\n    >>> enhanced = enhancer.enhance_file(\n    ...     \"speechbrain/metricgan-plus-voicebank/example.wav\"\n    ... )\n    \"\"\"\n\n    HPARAMS_NEEDED = [\"compute_stft\", \"spectral_magnitude\", \"resynth\"]\n    MODULES_NEEDED = [\"enhance_model\"]\n\n    def compute_features(self, wavs):\n        \"\"\"Compute the log spectral magnitude features for masking.\n\n        Arguments\n        ---------\n        wavs : torch.Tensor\n            A batch of waveforms to convert to log spectral mags.\n        \"\"\"\n        feats = self.hparams.compute_stft(wavs)\n        feats = self.hparams.spectral_magnitude(feats)\n        return torch.log1p(feats)\n\n    def enhance_batch(self, noisy, lengths=None):\n        \"\"\"Enhance a batch of noisy waveforms.\n\n        Arguments\n        ---------\n        noisy : torch.Tensor\n            A batch of waveforms to perform enhancement on.\n        lengths : torch.Tensor\n            The lengths of the waveforms if the enhancement model handles them.\n\n        Returns\n        -------\n        torch.Tensor\n            A batch of enhanced waveforms of the same shape as input.\n        \"\"\"\n        noisy = noisy.to(self.device)\n        noisy_features = self.compute_features(noisy)\n\n        # Perform masking-based enhancement, multiplying output with input.\n        if lengths is not None:\n            mask = self.mods.enhance_model(noisy_features, lengths=lengths)\n        else:\n            mask = self.mods.enhance_model(noisy_features)\n        enhanced = torch.mul(mask, noisy_features)\n\n        # Return resynthesized waveforms\n        return self.hparams.resynth(torch.expm1(enhanced), noisy)\n\n    def enhance_file(self, filename, output_filename=None, **kwargs):\n        \"\"\"Enhance a wav file.\n\n        Arguments\n        ---------\n        filename : str\n            Location on disk to load file for enhancement.\n        output_filename : str\n            If provided, writes enhanced data to this file.\n        \"\"\"\n        noisy = self.load_audio(filename, **kwargs)\n        noisy = noisy.to(self.device)\n\n        # Fake a batch:\n        batch = noisy.unsqueeze(0)\n        if lengths_arg_exists(self.enhance_batch):\n            enhanced = self.enhance_batch(batch, lengths=torch.tensor([1.0]))\n        else:\n            enhanced = self.enhance_batch(batch)\n\n        if output_filename is not None:\n            torchaudio.save(\n                uri=output_filename,\n                src=enhanced,\n                sample_rate=self.hparams.compute_stft.sample_rate,\n            )\n\n        return enhanced.squeeze(0)\n\n\nclass WaveformEnhancement(Pretrained):\n    \"\"\"A ready-to-use model for speech enhancement.\n\n    Arguments\n    ---------\n    See ``Pretrained``.\n\n    Example\n    -------\n    >>> from speechbrain.inference.enhancement import WaveformEnhancement\n    >>> # Model is downloaded from the speechbrain HuggingFace repo\n    >>> tmpdir = getfixture(\"tmpdir\")\n    >>> enhancer = WaveformEnhancement.from_hparams(\n    ...     source=\"speechbrain/mtl-mimic-voicebank\",\n    ...     savedir=tmpdir,\n    ... )\n    >>> enhanced = enhancer.enhance_file(\n    ...     \"speechbrain/mtl-mimic-voicebank/example.wav\"\n    ... )\n    \"\"\"\n\n    MODULES_NEEDED = [\"enhance_model\"]\n\n    def enhance_batch(self, noisy, lengths=None):\n        \"\"\"Enhance a batch of noisy waveforms.\n\n        Arguments\n        ---------\n        noisy : torch.Tensor\n            A batch of waveforms to perform enhancement on.\n        lengths : torch.Tensor\n            The lengths of the waveforms if the enhancement model handles them.\n\n        Returns\n        -------\n        torch.Tensor\n            A batch of enhanced waveforms of the same shape as input.\n        \"\"\"\n        noisy = noisy.to(self.device)\n        enhanced_wav, _ = self.mods.enhance_model(noisy)\n        return enhanced_wav\n\n    def enhance_file(self, filename, output_filename=None, **kwargs):\n        \"\"\"Enhance a wav file.\n\n        Arguments\n        ---------\n        filename : str\n            Location on disk to load file for enhancement.\n        output_filename : str\n            If provided, writes enhanced data to this file.\n        \"\"\"\n        noisy = self.load_audio(filename, **kwargs)\n\n        # Fake a batch:\n        batch = noisy.unsqueeze(0)\n        enhanced = self.enhance_batch(batch)\n\n        if output_filename is not None:\n            torchaudio.save(\n                uri=output_filename,\n                src=enhanced,\n                sample_rate=self.audio_normalizer.sample_rate,\n            )\n\n        return enhanced.squeeze(0)\n\n    def forward(self, noisy, lengths=None):\n        \"\"\"Runs enhancement on the noisy input\"\"\"\n        return self.enhance_batch(noisy, lengths)\n", "path": "speechbrain/inference/enhancement.py"}]}