Spaces:
Running
on
Zero
Running
on
Zero
multi channel input, warn user and convert
Browse files
app.py
CHANGED
@@ -182,6 +182,9 @@ def prepare_prompt(text: str, speaker: int, audio_path: str) -> Segment:
|
|
182 |
|
183 |
def load_prompt_audio(audio_path: str) -> torch.Tensor:
|
184 |
audio_tensor, sample_rate = torchaudio.load(audio_path)
|
|
|
|
|
|
|
185 |
audio_tensor = audio_tensor.squeeze(0)
|
186 |
if sample_rate != generator.sample_rate:
|
187 |
audio_tensor = torchaudio.functional.resample(
|
|
|
182 |
|
183 |
def load_prompt_audio(audio_path: str) -> torch.Tensor:
|
184 |
audio_tensor, sample_rate = torchaudio.load(audio_path)
|
185 |
+
if audio_tensor.shape[0] != 1:
|
186 |
+
gr.Warning("Warning: Audio prompt is multi-channel, converting to mono.", duration=15)
|
187 |
+
audio_tensor = audio_tensor.mean(dim=0)
|
188 |
audio_tensor = audio_tensor.squeeze(0)
|
189 |
if sample_rate != generator.sample_rate:
|
190 |
audio_tensor = torchaudio.functional.resample(
|