Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
mariesig commited on
Commit ·
eb05480
1
Parent(s): 12206be
for debugging in hugginface
Browse files- offline_pipeline.py +8 -3
offline_pipeline.py
CHANGED
|
@@ -15,6 +15,7 @@ def retrieve_audio_information(
|
|
| 15 |
sample_id: str,
|
| 16 |
stt_model: str,
|
| 17 |
) -> tuple[Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]]:
|
|
|
|
| 18 |
noisy_spec_path = f"/tmp/{sample_id}_noisy_spectrogram.png"
|
| 19 |
enhanced_spec_path = f"/tmp/{sample_id}_enhanced_spectrogram.png"
|
| 20 |
spec_image(original_array).save(noisy_spec_path)
|
|
@@ -55,7 +56,7 @@ def load_local_file(
|
|
| 55 |
gr.Warning("Please upload a valid audio file.")
|
| 56 |
raise ValueError("Missing audio sample. Please upload an audio sample or use the microphone input.")
|
| 57 |
new_sample_stem = os.path.splitext(os.path.basename(sample_path))[0]
|
| 58 |
-
y_16k, _ = librosa.load(sample_path, sr=DEFAULT_SR, dtype="float32")
|
| 59 |
return y_16k, new_sample_stem
|
| 60 |
|
| 61 |
def load_file_from_dataset(sample_id: str) -> tuple[tuple, np.ndarray, str]:
|
|
@@ -63,6 +64,10 @@ def load_file_from_dataset(sample_id: str) -> tuple[tuple, np.ndarray, str]:
|
|
| 63 |
gr.Warning("Please select a sample from the dropdown.")
|
| 64 |
raise ValueError("No sample selected. Please select a sample from the dropdown.")
|
| 65 |
new_sample_stem = sample_id
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
return y_16k_for_gradio, y_16k, new_sample_stem
|
|
|
|
| 15 |
sample_id: str,
|
| 16 |
stt_model: str,
|
| 17 |
) -> tuple[Optional[str], Optional[str], Optional[str], Optional[str], Optional[str]]:
|
| 18 |
+
|
| 19 |
noisy_spec_path = f"/tmp/{sample_id}_noisy_spectrogram.png"
|
| 20 |
enhanced_spec_path = f"/tmp/{sample_id}_enhanced_spectrogram.png"
|
| 21 |
spec_image(original_array).save(noisy_spec_path)
|
|
|
|
| 56 |
gr.Warning("Please upload a valid audio file.")
|
| 57 |
raise ValueError("Missing audio sample. Please upload an audio sample or use the microphone input.")
|
| 58 |
new_sample_stem = os.path.splitext(os.path.basename(sample_path))[0]
|
| 59 |
+
y_16k, _ = librosa.load(sample_path, sr=DEFAULT_SR, dtype="float32", mono=True)
|
| 60 |
return y_16k, new_sample_stem
|
| 61 |
|
| 62 |
def load_file_from_dataset(sample_id: str) -> tuple[tuple, np.ndarray, str]:
|
|
|
|
| 64 |
gr.Warning("Please select a sample from the dropdown.")
|
| 65 |
raise ValueError("No sample selected. Please select a sample from the dropdown.")
|
| 66 |
new_sample_stem = sample_id
|
| 67 |
+
try:
|
| 68 |
+
y_16k, sr = get_audio(sample_id, prefix="mix")
|
| 69 |
+
y_16k_for_gradio = to_gradio_audio(y_16k, sr)
|
| 70 |
+
except Exception as e: # Convert to 16-bit PCM for gradio audio component
|
| 71 |
+
gr.Warning(f"{e}")
|
| 72 |
+
raise e
|
| 73 |
return y_16k_for_gradio, y_16k, new_sample_stem
|