CoolFace
Datasetpublic

model-metadata/code_python_files

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes13kdownloads
pyannote_segmentation-3.0_1.py75 linesDownload Raw Back to root
1# /// script2# requires-python = ">=3.12"3# dependencies = [4#     "numpy",5#     "einops",6#     "pandas",7#     "matplotlib",8#     "protobuf",9#     "torch",10#     "sentencepiece",11#     "torchvision",12#     "transformers",13#     "timm",14#     "diffusers",15#     "sentence-transformers",16#     "accelerate",17#     "peft",18#     "slack-sdk",19# ]20# ///21 22try:23    from pyannote.audio import Model, Inference24    25    model = Model.from_pretrained("pyannote/segmentation-3.0")26    inference = Inference(model)27    28    # inference on the whole file29    inference("file.wav")30    31    # inference on an excerpt32    from pyannote.core import Segment33    excerpt = Segment(start=2.0, end=5.0)34    inference.crop("file.wav", excerpt)35    with open('pyannote_segmentation-3.0_1.txt', 'w', encoding='utf-8') as f:36        f.write('Everything was good in pyannote_segmentation-3.0_1.txt')37except Exception as e:38    import os39    from slack_sdk import WebClient40    client = WebClient(token=os.environ['SLACK_TOKEN'])41    client.chat_postMessage(42        channel='#hub-model-metadata-snippets-sprint',43        text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/pyannote_segmentation-3.0_1.txt|pyannote_segmentation-3.0_1.txt>',44    )45 46    with open('pyannote_segmentation-3.0_1.txt', 'a', encoding='utf-8') as f:47        import traceback48        f.write('''```CODE: 49from pyannote.audio import Model, Inference50 51model = Model.from_pretrained("pyannote/segmentation-3.0")52inference = Inference(model)53 54# inference on the whole file55inference("file.wav")56 57# inference on an excerpt58from pyannote.core import Segment59excerpt = Segment(start=2.0, end=5.0)60inference.crop("file.wav", excerpt)61```62 63ERROR: 64''')65        traceback.print_exc(file=f)66    67finally:68    from huggingface_hub import upload_file69    upload_file(70        path_or_fileobj='pyannote_segmentation-3.0_1.txt',71        repo_id='model-metadata/code_execution_files',72        path_in_repo='pyannote_segmentation-3.0_1.txt',73        repo_type='dataset',74    )75