File size: 7,491 Bytes
ee02bc0 ed3e9f5 ee02bc0 ed3e9f5 ee02bc0 ed3e9f5 ee02bc0 ed3e9f5 ee02bc0 ed3e9f5 ee02bc0 1cedd4e ee02bc0 ed3e9f5 ee02bc0 d428bf5 ed3e9f5 ee02bc0 1cedd4e d428bf5 ed3e9f5 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "bbd1b7a1-dbb7-4243-99e0-70a6cd47d573",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "bcc2f5482d8342a7915cecf9e7855531",
"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": 13,
"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": 14,
"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": 15,
"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, split=[\"test\", \"training\"])"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "f37d68ea-cbe7-4dd1-8215-f9449fe047f4",
"metadata": {},
"outputs": [],
"source": [
"ds.save_to_disk(\"data/test/\")\n",
"ds.save_to_disk(\"data/training/\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "bac1a601-a7a1-434e-917d-0e372684f56b",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Resuming upload of the dataset shards.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "61cfa14ccb514ff4961072752bc3d4da",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Pushing dataset shards to the dataset hub: 0%| | 0/1 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5803c7d37ce1426794af8ad65f618275",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading metadata: 0%| | 0.00/1.20k [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Updating downloaded metadata with the new split.\n"
]
},
{
"ename": "ValueError",
"evalue": "Split ['test', 'training'] already present",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [12]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mds\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpush_to_hub\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msharpcoder/bjorn_training\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/datasets/arrow_dataset.py:4342\u001b[0m, in \u001b[0;36mDataset.push_to_hub\u001b[0;34m(self, repo_id, split, private, token, branch, max_shard_size, shard_size, embed_external_files)\u001b[0m\n\u001b[1;32m 4340\u001b[0m repo_info\u001b[38;5;241m.\u001b[39mdataset_size \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m dataset_nbytes\n\u001b[1;32m 4341\u001b[0m repo_info\u001b[38;5;241m.\u001b[39msize_in_bytes \u001b[38;5;241m=\u001b[39m repo_info\u001b[38;5;241m.\u001b[39mdownload_size \u001b[38;5;241m+\u001b[39m repo_info\u001b[38;5;241m.\u001b[39mdataset_size\n\u001b[0;32m-> 4342\u001b[0m repo_info\u001b[38;5;241m.\u001b[39msplits[split] \u001b[38;5;241m=\u001b[39m SplitInfo(\n\u001b[1;32m 4343\u001b[0m split, num_bytes\u001b[38;5;241m=\u001b[39mdataset_nbytes, num_examples\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mlen\u001b[39m(\u001b[38;5;28mself\u001b[39m), dataset_name\u001b[38;5;241m=\u001b[39mdataset_name\n\u001b[1;32m 4344\u001b[0m )\n\u001b[1;32m 4345\u001b[0m info_to_dump \u001b[38;5;241m=\u001b[39m repo_info\n\u001b[1;32m 4346\u001b[0m buffer \u001b[38;5;241m=\u001b[39m BytesIO()\n",
"File \u001b[0;32m~/.local/lib/python3.10/site-packages/datasets/splits.py:523\u001b[0m, in \u001b[0;36mSplitDict.__setitem__\u001b[0;34m(self, key, value)\u001b[0m\n\u001b[1;32m 521\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCannot add elem. (key mismatch: \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mkey\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m != \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvalue\u001b[38;5;241m.\u001b[39mname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 522\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m:\n\u001b[0;32m--> 523\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSplit \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mkey\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m already present\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 524\u001b[0m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__setitem__\u001b[39m(key, value)\n",
"\u001b[0;31mValueError\u001b[0m: Split ['test', 'training'] already present"
]
}
],
"source": [
"# ds.push_to_hub(\"sharpcoder/bjorn_training\")"
]
},
{
"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
}
|