{
"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",
" name | \n",
" dataset | \n",
" caption | \n",
" audio_path | \n",
" duration | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1210764.wav | \n",
" audiostock | \n",
" Ping pong! Quiz Correct Answer Successful Button | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 1.500000 | \n",
"
\n",
" \n",
" 1 | \n",
" 1108217.wav | \n",
" audiostock | \n",
" Sharp shamisen chichin part 2 | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 2.750000 | \n",
"
\n",
" \n",
" 2 | \n",
" 1238575.wav | \n",
" audiostock | \n",
" The sound of locking the inside of the door of... | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 1.495000 | \n",
"
\n",
" \n",
" 3 | \n",
" 1153833.wav | \n",
" audiostock | \n",
" Electric sound like laser. | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 1.851000 | \n",
"
\n",
" \n",
" 4 | \n",
" 811188.wav | \n",
" audiostock | \n",
" Flashy and glittering blues jingle | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 4.714313 | \n",
"
\n",
" \n",
"
\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",
" name | \n",
" dataset | \n",
" caption | \n",
" audio_path | \n",
" duration | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 1210764 | \n",
" audiostock | \n",
" Ping pong! Quiz Correct Answer Successful Button | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 1.500000 | \n",
"
\n",
" \n",
" 1 | \n",
" 1108217 | \n",
" audiostock | \n",
" Sharp shamisen chichin part 2 | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 2.750000 | \n",
"
\n",
" \n",
" 2 | \n",
" 1238575 | \n",
" audiostock | \n",
" The sound of locking the inside of the door of... | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 1.495000 | \n",
"
\n",
" \n",
" 3 | \n",
" 1153833 | \n",
" audiostock | \n",
" Electric sound like laser. | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 1.851000 | \n",
"
\n",
" \n",
" 4 | \n",
" 811188 | \n",
" audiostock | \n",
" Flashy and glittering blues jingle | \n",
" /home/tiger/nfs/data/old_data/Audiostock/audio... | \n",
" 4.714313 | \n",
"
\n",
" \n",
"
\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
}