Spaces:
Runtime error
Runtime error
Download make_examples.py from stevafernandes/bee-ai: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/stevafernandes/bee-ai/resolve/main/make_examples.py
- Command line
-
hf download hf://spaces/stevafernandes/bee-ai/make_examples.py
-
curl -L -o make_examples.py https://huggingface.co/spaces/stevafernandes/bee-ai/resolve/main/make_examples.py
1.21 kB
| """make_examples.py - write a few 16 kHz mono example recordings for the Space's Examples panel. | |
| python make_examples.py --audio-dir /path/to/wav [--files 25.IA.July.2023.wav ...] | |
| The examples are re-encoded at 16 kHz (the pipeline's working rate), which keeps each file under | |
| 4 MB; the app's ground-truth lookup works because the file names are unchanged. | |
| """ | |
| import argparse | |
| import os | |
| import sys | |
| import soundfile as sf | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| sys.path.insert(0, HERE) | |
| import acoustic as ac # noqa: E402 | |
| DEFAULT = ["25.IA.July.2023.wav", "49.IA.Mar.2023.wav", "51.NZ.Jan.2023.wav", "F1.IA.Oct.2023.wav"] | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--audio-dir", required=True) | |
| ap.add_argument("--files", nargs="*", default=DEFAULT) | |
| ap.add_argument("--out", default=os.path.join(HERE, "examples")) | |
| a = ap.parse_args() | |
| os.makedirs(a.out, exist_ok=True) | |
| for f in a.files: | |
| y, sr = ac.load_audio(os.path.join(a.audio_dir, f), ac.SR) | |
| sf.write(os.path.join(a.out, f), y, sr, subtype="PCM_16") | |
| print("wrote", f, f"{os.path.getsize(os.path.join(a.out, f))/1e6:.2f} MB") | |
| if __name__ == "__main__": | |
| main() | |