{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from transformers import pipeline\n", "\n", "pipe = pipeline(\n", " \"audio-classification\", model=\"Davidmide02/distilhubert-finetuned-gtzan\"\n", ")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def classify_audio(filepath):\n", " preds = pipe(filepath)\n", " outputs = {}\n", " for p in preds:\n", " outputs[p[\"label\"]] = p[\"score\"]\n", " return outputs" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "