{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "9f6dfbea",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "\n",
    "with open(\"/home/georg/notebooks/datasets/phillippines/fili_100/pipeline/artifacts/fili_sample_manifest.json\") as f:\n",
    "    d = json.load(f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c754d236",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['id', 'uri', 'duration_s', 'transcript', 'transcript_normalized'])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# rename speakers\n",
    "d[0].keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3129b6f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'segments/c137e3c8-2537-4a61-bd86-9fd727304da3.wav'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d[0][\"uri\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "7d5bee3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "!mkdir available_samples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "88948d08",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alignment-gentle  artifacts  segments\r\n"
     ]
    }
   ],
   "source": [
    "!ls /home/georg/notebooks/datasets/phillippines/fili_100/pipeline/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "162a4c99",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import shutil\n",
    "from suno_utils.audio import Audio\n",
    "base_dir = \"/home/georg/notebooks/datasets/phillippines/fili_100/pipeline/\"\n",
    "for e in d:\n",
    "    fp = os.path.join(base_dir, e[\"uri\"])\n",
    "    Audio.from_file(fp).to_mp3(\"available_samples/\" + e[\"uri\"].split(\"/\")[-1].split(\".\")[0] + \".mp3\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "32622997",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "available_samples/c137e3c8-2537-4a61-bd86-9fd727304da3.mp3\n"
     ]
    }
   ],
   "source": [
    "for e in d:\n",
    "    fp = os.path.join(base_dir, e[\"uri\"])\n",
    "    print(\"available_samples/\" + e[\"uri\"].split(\"/\")[-1].split(\".\")[0] + \".mp3\")\n",
    "    break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "11b89b3d",
   "metadata": {},
   "outputs": [],
   "source": [
    "!tar -czf available_samples.tar.gz fili_sample_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f897bb5a",
   "metadata": {},
   "outputs": [],
   "source": [
    "!ls fili_sample_data/*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "cb41d6e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fili_sample_data/segment_meta.jsonl\r\n",
      "\r\n",
      "fili_sample_data/segments:\r\n",
      "0db196a5-8fd7-46ba-8a5e-901cf1cb3e59.wav\r\n",
      "128db05c-b99d-4cc7-9673-cc3c1c898f53.wav\r\n",
      "6850cb1c-2ea0-442e-8ed7-9391085f778d.wav\r\n",
      "787f2dbf-ca6a-4620-b69a-280cb5497cec.wav\r\n",
      "880e51a8-a842-4776-ad45-9804269caf71.wav\r\n",
      "9fa61c6e-031f-450d-bde1-33270e188bc7.wav\r\n",
      "d81c2c32-fe35-4b52-ad09-1b9fa35f8842.wav\r\n",
      "e50dc620-829e-4a8d-9e10-1372d7c23cdc.wav\r\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6b0dbcc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11283a27",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c81fdb3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a089a2f9",
   "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.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
