{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "bc1da29c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "\n",
    "DATE_DIR = \"2022_08_11\"\n",
    "\n",
    "BASE_DIR = \"/mnt/data-ssd-1/data/private/customer/sanas/2022-08-04-fili-callcenter/\"\n",
    "TO_REV_DIR = os.path.join(BASE_DIR, \"to_rev\", DATE_DIR)\n",
    "REV_MANIFEST_FILEPATH = os.path.join(TO_REV_DIR, \"rev_manifest.jsonl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "5961c111",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10372/10614 files\n"
     ]
    }
   ],
   "source": [
    "metadata = []\n",
    "with open(REV_MANIFEST_FILEPATH) as f:\n",
    "    for l in f.read().strip().split(\"\\n\"):\n",
    "        metadata.append(json.loads(l))\n",
    "print(\n",
    "    \"{}/{} files\".format(\n",
    "        len(metadata), len(os.listdir(os.path.join(BASE_DIR, \"Continuum_GSDExtracts\")))\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "7e3feb7f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "482.0h total\n",
      "433.3h segment total\n"
     ]
    }
   ],
   "source": [
    "tot_duration_s = 0\n",
    "tot_seg_duration_s = 0\n",
    "for m in metadata:\n",
    "    tot_duration_s += m[\"audio_duration_s\"]\n",
    "    for e in m[\"segments_meta\"]:\n",
    "        if e[\"type\"] == \"speech\":\n",
    "            tot_seg_duration_s += e[\"duration_s\"]\n",
    "\n",
    "print(\"{}h total\".format(round(tot_duration_s / 60 / 60, 1)))\n",
    "print(\"{}h segment total\".format(round(tot_seg_duration_s / 60 / 60, 1)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4ed2e288",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6a07ef3e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bb8560dc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "34de9ebd",
   "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
}
