File size: 2,685 Bytes
ee02bc0 1cedd4e ee02bc0 1cedd4e ee02bc0 1cedd4e ee02bc0 1cedd4e ee02bc0 1cedd4e ee02bc0 1cedd4e ee02bc0 1cedd4e ee02bc0 1cedd4e ee02bc0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "bbd1b7a1-dbb7-4243-99e0-70a6cd47d573",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fbfb4b038e344f68b344e0998d42112f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HTML(value='<center> <img\\nsrc=https://huggingface.co/front/assets/huggingface_logo-noborder.sv…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from huggingface_hub import notebook_login\n",
"notebook_login()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "306958c8-4603-4b9b-b941-6a824777164d",
"metadata": {},
"outputs": [],
"source": [
"import librosa\n",
"import math\n",
"import pyarrow as pa\n",
"import pandas as pd\n",
"from datasets import load_dataset_builder, SplitGenerator, Split, Dataset, table"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4ac69d3b-38c6-49af-aefe-63755bf3f0e9",
"metadata": {},
"outputs": [],
"source": [
"SAMPLE_RATE = 16_000\n",
"MAX_LENGTH_IN_SECONDS = 20.0\n",
"\n",
"def add_audio(file, words):\n",
" audio, _ = librosa.load(file, sr=SAMPLE_RATE)\n",
" return {\n",
" \"audio\": audio,\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "9192b631-388f-4306-b975-9ba770b9dc4d",
"metadata": {},
"outputs": [],
"source": [
"audio, _ = librosa.load('clips/1.wav', sr=SAMPLE_RATE)\n",
" \n",
"df = pd.DataFrame({\n",
" 'audio': [audio],\n",
" 'text': ['bjorn.'],\n",
"})\n",
"tbl = table.InMemoryTable(\n",
" pa.Table.from_pandas(df)\n",
")\n",
"ds = Dataset(tbl)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "bac1a601-a7a1-434e-917d-0e372684f56b",
"metadata": {},
"outputs": [],
"source": [
"ds.save_to_disk('.')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b070517c-2dfc-4f1b-baed-1748a9d5f088",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|