{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "True\n" ] } ], "source": [ "import os\n", "\n", "print(os.path.exists('/home/tiger/nfs/data/old_data/Audiostock/audios/1210764.wav'))" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import audioread\n", "with audioread.audio_open('/home/tiger/nfs/data/old_data/Audiostock/audios/1210764.wav') as f:\n", " totalsec = f.duration" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.5\n" ] } ], "source": [ "print(totalsec)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namedatasetcaptionaudio_pathduration
01210764.wavaudiostockPing pong! Quiz Correct Answer Successful Button/home/tiger/nfs/data/old_data/Audiostock/audio...1.500000
11108217.wavaudiostockSharp shamisen chichin part 2/home/tiger/nfs/data/old_data/Audiostock/audio...2.750000
21238575.wavaudiostockThe sound of locking the inside of the door of.../home/tiger/nfs/data/old_data/Audiostock/audio...1.495000
31153833.wavaudiostockElectric sound like laser./home/tiger/nfs/data/old_data/Audiostock/audio...1.851000
4811188.wavaudiostockFlashy and glittering blues jingle/home/tiger/nfs/data/old_data/Audiostock/audio...4.714313
\n", "
" ], "text/plain": [ " name dataset caption \\\n", "0 1210764.wav audiostock Ping pong! Quiz Correct Answer Successful Button \n", "1 1108217.wav audiostock Sharp shamisen chichin part 2 \n", "2 1238575.wav audiostock The sound of locking the inside of the door of... \n", "3 1153833.wav audiostock Electric sound like laser. \n", "4 811188.wav audiostock Flashy and glittering blues jingle \n", "\n", " audio_path duration \n", "0 /home/tiger/nfs/data/old_data/Audiostock/audio... 1.500000 \n", "1 /home/tiger/nfs/data/old_data/Audiostock/audio... 2.750000 \n", "2 /home/tiger/nfs/data/old_data/Audiostock/audio... 1.495000 \n", "3 /home/tiger/nfs/data/old_data/Audiostock/audio... 1.851000 \n", "4 /home/tiger/nfs/data/old_data/Audiostock/audio... 4.714313 " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namedatasetcaptionaudio_pathduration
01210764audiostockPing pong! Quiz Correct Answer Successful Button/home/tiger/nfs/data/old_data/Audiostock/audio...1.500000
11108217audiostockSharp shamisen chichin part 2/home/tiger/nfs/data/old_data/Audiostock/audio...2.750000
21238575audiostockThe sound of locking the inside of the door of.../home/tiger/nfs/data/old_data/Audiostock/audio...1.495000
31153833audiostockElectric sound like laser./home/tiger/nfs/data/old_data/Audiostock/audio...1.851000
4811188audiostockFlashy and glittering blues jingle/home/tiger/nfs/data/old_data/Audiostock/audio...4.714313
\n", "
" ], "text/plain": [ " name dataset caption \\\n", "0 1210764 audiostock Ping pong! Quiz Correct Answer Successful Button \n", "1 1108217 audiostock Sharp shamisen chichin part 2 \n", "2 1238575 audiostock The sound of locking the inside of the door of... \n", "3 1153833 audiostock Electric sound like laser. \n", "4 811188 audiostock Flashy and glittering blues jingle \n", "\n", " audio_path duration \n", "0 /home/tiger/nfs/data/old_data/Audiostock/audio... 1.500000 \n", "1 /home/tiger/nfs/data/old_data/Audiostock/audio... 2.750000 \n", "2 /home/tiger/nfs/data/old_data/Audiostock/audio... 1.495000 \n", "3 /home/tiger/nfs/data/old_data/Audiostock/audio... 1.851000 \n", "4 /home/tiger/nfs/data/old_data/Audiostock/audio... 4.714313 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv('tmp.tsv',sep='\\t')\n", "display(df)\n", "n2n = {}\n", "for t in df.itertuples():\n", " name = getattr(t,'name')\n", " n2n[name] = name[:-4]\n", "\n", "df['name'] = df['name'].map(n2n)\n", "display(df)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.3" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }