You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1681 lines
1.3 MiB
1681 lines
1.3 MiB
4 years ago
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "choice-lender",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"eng=\"one minute a voice said and the time buzzer sounded\"\n",
|
||
|
"chn=\"可控是病毒武器最基本的要求\""
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "ruled-kuwait",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"o\n",
|
||
|
"n\n",
|
||
|
"e\n",
|
||
|
" \n",
|
||
|
"m\n",
|
||
|
"i\n",
|
||
|
"n\n",
|
||
|
"u\n",
|
||
|
"t\n",
|
||
|
"e\n",
|
||
|
" \n",
|
||
|
"a\n",
|
||
|
" \n",
|
||
|
"v\n",
|
||
|
"o\n",
|
||
|
"i\n",
|
||
|
"c\n",
|
||
|
"e\n",
|
||
|
" \n",
|
||
|
"s\n",
|
||
|
"a\n",
|
||
|
"i\n",
|
||
|
"d\n",
|
||
|
" \n",
|
||
|
"a\n",
|
||
|
"n\n",
|
||
|
"d\n",
|
||
|
" \n",
|
||
|
"t\n",
|
||
|
"h\n",
|
||
|
"e\n",
|
||
|
" \n",
|
||
|
"t\n",
|
||
|
"i\n",
|
||
|
"m\n",
|
||
|
"e\n",
|
||
|
" \n",
|
||
|
"b\n",
|
||
|
"u\n",
|
||
|
"z\n",
|
||
|
"z\n",
|
||
|
"e\n",
|
||
|
"r\n",
|
||
|
" \n",
|
||
|
"s\n",
|
||
|
"o\n",
|
||
|
"u\n",
|
||
|
"n\n",
|
||
|
"d\n",
|
||
|
"e\n",
|
||
|
"d\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for char in eng:\n",
|
||
|
" print(char)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "passive-petite",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"可\n",
|
||
|
"控\n",
|
||
|
"是\n",
|
||
|
"病\n",
|
||
|
"毒\n",
|
||
|
"武\n",
|
||
|
"器\n",
|
||
|
"最\n",
|
||
|
"基\n",
|
||
|
"本\n",
|
||
|
"的\n",
|
||
|
"要\n",
|
||
|
"求\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for char in chn:\n",
|
||
|
" print(char)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "olympic-realtor",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"one\n",
|
||
|
"minute\n",
|
||
|
"a\n",
|
||
|
"voice\n",
|
||
|
"said\n",
|
||
|
"and\n",
|
||
|
"the\n",
|
||
|
"time\n",
|
||
|
"buzzer\n",
|
||
|
"sounded\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for word in eng.split():\n",
|
||
|
" print(word)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"id": "induced-enhancement",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"可控是病毒武器最基本的要求\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"for word in chn.split():\n",
|
||
|
" print(word)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"id": "lovely-bottle",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"ename": "ModuleNotFoundError",
|
||
|
"evalue": "No module named 'StringIO'",
|
||
|
"output_type": "error",
|
||
|
"traceback": [
|
||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||
|
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
||
|
"\u001b[0;32m<ipython-input-9-3e4825b8299f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mStringIO\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||
|
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'StringIO'"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import StringIO"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"id": "interested-cardiff",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"from io import StringIO"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "portable-ivory",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"inputs = StringIO()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"id": "compatible-destination",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"inputs.write(\"nor is mister quilter's manner less interesting than his matter\" + '\\n')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"id": "federal-margin",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"nor is mister quilter's manner less interesting than his matternor is mister quilter's manner less interesting than his matter\n",
|
||
|
"\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(inputs.getvalue())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"id": "consecutive-entity",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"inputs.write(\"nor is mister quilter's manner less interesting than his matter\" + '\\n')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"id": "desirable-anxiety",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"nor is mister quilter's manner less interesting than his matternor is mister quilter's manner less interesting than his matter\n",
|
||
|
"nor is mister quilter's manner less interesting than his matter\n",
|
||
|
"\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(inputs.getvalue())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"id": "employed-schedule",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import tempfile"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"id": "unlikely-honduras",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"['__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_checkClosed', '_checkReadable', '_checkSeekable', '_checkWritable', '_dealloc_warn', '_finalizing', 'close', 'closed', 'detach', 'fileno', 'flush', 'isatty', 'mode', 'name', 'peek', 'raw', 'read', 'read1', 'readable', 'readinto', 'readinto1', 'readline', 'readlines', 'seek', 'seekable', 'tell', 'truncate', 'writable', 'write', 'writelines']\n",
|
||
|
"57\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with tempfile.TemporaryFile() as fp:\n",
|
||
|
" print(dir(fp))\n",
|
||
|
" print(fp.name)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 27,
|
||
|
"id": "needed-trail",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"a = tempfile.mkstemp(suffix=None, prefix='test', dir=None, text=False)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 28,
|
||
|
"id": "hazardous-choir",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(dir(a))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"id": "front-sauce",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"(57, '/tmp/test27smzbzc')\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(a)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"id": "shared-wages",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"<built-in method index of tuple object at 0x7f999b525648>\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(a.index)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 34,
|
||
|
"id": "charged-carnival",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_closer', 'close', 'delete', 'file', 'name']\n",
|
||
|
"/tmp/tmpfjn7mygy\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"fp= tempfile.NamedTemporaryFile(mode='w', delete=False)\n",
|
||
|
"print(dir(fp))\n",
|
||
|
"print(fp.name)\n",
|
||
|
"fp.close()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 36,
|
||
|
"id": "religious-terror",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/tmp/tmpfjn7mygy\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import os\n",
|
||
|
"os.path.exists(fp.name)\n",
|
||
|
"print(fp.name)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 37,
|
||
|
"id": "communist-gospel",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<function BufferedRandom.write(buffer, /)>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 37,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"fp.write"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 39,
|
||
|
"id": "simplified-clarity",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"'example'"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 39,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"s='/home/ubuntu/python/example.py'\n",
|
||
|
"os.path.splitext(os.path.basename(s))[0]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 40,
|
||
|
"id": "popular-genius",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"from collections import Counter"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 43,
|
||
|
"id": "studied-burner",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"dict_items([('hello', 1), ('world', 1)])\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"counter = Counter()\n",
|
||
|
"counter.update([\"hello\"])\n",
|
||
|
"counter.update([\"world\"])\n",
|
||
|
"print(counter.items())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 44,
|
||
|
"id": "mineral-ceremony",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"dict_items([('h', 1), ('e', 1), ('l', 3), ('o', 2), ('w', 1), ('r', 1), ('d', 1)])\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"counter = Counter()\n",
|
||
|
"counter.update(\"hello\")\n",
|
||
|
"counter.update(\"world\")\n",
|
||
|
"print(counter.items())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 45,
|
||
|
"id": "nonprofit-freedom",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"counter.update(list(\"hello\"))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 46,
|
||
|
"id": "extended-methodology",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"dict_items([('h', 2), ('e', 2), ('l', 5), ('o', 3), ('w', 1), ('r', 1), ('d', 1)])\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(counter.items())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 47,
|
||
|
"id": "grand-benjamin",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"['h', 'e', 'l', 'l', 'o']"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 47,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"list(\"hello\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 53,
|
||
|
"id": "marine-fundamentals",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"{}\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from io import StringIO\n",
|
||
|
"a = StringIO(initial_value='{}', newline='')\n",
|
||
|
"print(a.read())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 56,
|
||
|
"id": "suitable-charlotte",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"ename": "TypeError",
|
||
|
"evalue": "expected str, bytes or os.PathLike object, not _io.StringIO",
|
||
|
"output_type": "error",
|
||
|
"traceback": [
|
||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||
|
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
||
|
"\u001b[0;32m<ipython-input-56-4323a912120d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||
|
"\u001b[0;31mTypeError\u001b[0m: expected str, bytes or os.PathLike object, not _io.StringIO"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"with io.open(a) as f:\n",
|
||
|
" print(f.read())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 57,
|
||
|
"id": "institutional-configuration",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"io.open?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 58,
|
||
|
"id": "pregnant-modem",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def get_default_args(fn):\n",
|
||
|
" if fn is None:\n",
|
||
|
" return {}\n",
|
||
|
"\n",
|
||
|
" signature = inspect.signature(fn)\n",
|
||
|
" return {\n",
|
||
|
" k: v.default\n",
|
||
|
" for k, v in signature.parameters.items()\n",
|
||
|
" if v.default is not inspect.Parameter.empty\n",
|
||
|
" }"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 59,
|
||
|
"id": "first-release",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"ename": "NameError",
|
||
|
"evalue": "name 'inspect' is not defined",
|
||
|
"output_type": "error",
|
||
|
"traceback": [
|
||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||
|
"\u001b[0;32m<ipython-input-59-8f782d06097f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mget_default_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||
|
"\u001b[0;32m<ipython-input-58-cb5a8794f39f>\u001b[0m in \u001b[0;36mget_default_args\u001b[0;34m(fn)\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0msignature\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minspect\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msignature\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m return {\n\u001b[1;32m 7\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdefault\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||
|
"\u001b[0;31mNameError\u001b[0m: name 'inspect' is not defined"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"get_default_args(io.open)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 35,
|
||
|
"id": "convertible-roulette",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Requirement already satisfied: sox in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (1.4.1)\n",
|
||
|
"Requirement already satisfied: numpy>=1.9.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from sox) (1.20.1)\n",
|
||
|
"Requirement already satisfied: librosa in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (0.8.0)\n",
|
||
|
"Requirement already satisfied: scikit-learn!=0.19.0,>=0.14.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (0.24.1)\n",
|
||
|
"Requirement already satisfied: numba>=0.43.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (0.52.0)\n",
|
||
|
"Requirement already satisfied: pooch>=1.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (1.3.0)\n",
|
||
|
"Requirement already satisfied: scipy>=1.0.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (1.2.1)\n",
|
||
|
"Requirement already satisfied: numpy>=1.15.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (1.20.1)\n",
|
||
|
"Requirement already satisfied: decorator>=3.0.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (4.4.2)\n",
|
||
|
"Requirement already satisfied: resampy>=0.2.2 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (0.2.2)\n",
|
||
|
"Requirement already satisfied: audioread>=2.0.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (2.1.9)\n",
|
||
|
"Requirement already satisfied: soundfile>=0.9.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (0.9.0.post1)\n",
|
||
|
"Requirement already satisfied: joblib>=0.14 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from librosa) (1.0.1)\n",
|
||
|
"Requirement already satisfied: setuptools in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from numba>=0.43.0->librosa) (51.0.0)\n",
|
||
|
"Requirement already satisfied: llvmlite<0.36,>=0.35.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from numba>=0.43.0->librosa) (0.35.0)\n",
|
||
|
"Requirement already satisfied: appdirs in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from pooch>=1.0->librosa) (1.4.4)\n",
|
||
|
"Requirement already satisfied: packaging in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from pooch>=1.0->librosa) (20.9)\n",
|
||
|
"Requirement already satisfied: requests in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from pooch>=1.0->librosa) (2.25.1)\n",
|
||
|
"Requirement already satisfied: six>=1.3 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from resampy>=0.2.2->librosa) (1.15.0)\n",
|
||
|
"Requirement already satisfied: threadpoolctl>=2.0.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from scikit-learn!=0.19.0,>=0.14.0->librosa) (2.1.0)\n",
|
||
|
"Requirement already satisfied: cffi>=0.6 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from soundfile>=0.9.0->librosa) (1.14.4)\n",
|
||
|
"Requirement already satisfied: pycparser in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from cffi>=0.6->soundfile>=0.9.0->librosa) (2.20)\n",
|
||
|
"Requirement already satisfied: pyparsing>=2.0.2 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from packaging->pooch>=1.0->librosa) (2.4.7)\n",
|
||
|
"Requirement already satisfied: idna<3,>=2.5 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from requests->pooch>=1.0->librosa) (2.10)\n",
|
||
|
"Requirement already satisfied: certifi>=2017.4.17 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from requests->pooch>=1.0->librosa) (2020.12.5)\n",
|
||
|
"Requirement already satisfied: chardet<5,>=3.0.2 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from requests->pooch>=1.0->librosa) (4.0.0)\n",
|
||
|
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from requests->pooch>=1.0->librosa) (1.26.3)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"!pip install sox\n",
|
||
|
"!pip install librosa"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "cutting-fleece",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"<class 'numpy.float64'>\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import sox\n",
|
||
|
"tfm = sox.Transformer()\n",
|
||
|
"sample_rate = 44100\n",
|
||
|
"y = np.sin(2 * np.pi * 440.0 * np.arange(sample_rate * 1.0) / sample_rate)\n",
|
||
|
"print(y.dtype.type)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "historical-diving",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[ 0. 0.06264832 0.12505052 ... -0.18696144 -0.12505052\n",
|
||
|
" -0.06264832]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"output_array = tfm.build_array(input_array=y, sample_rate_in=sample_rate)\n",
|
||
|
"print(output_array)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"id": "similar-spice",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"tfm.build_array?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"id": "grand-influence",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"['8svx', 'aif', 'aifc', 'aiff', 'aiffc', 'al', 'amb', 'amr-nb', 'amr-wb', 'anb', 'au', 'avr', 'awb', 'caf', 'cdda', 'cdr', 'cvs', 'cvsd', 'cvu', 'dat', 'dvms', 'f32', 'f4', 'f64', 'f8', 'fap', 'flac', 'fssd', 'gsm', 'gsrt', 'hcom', 'htk', 'ima', 'ircam', 'la', 'lpc', 'lpc10', 'lu', 'mat', 'mat4', 'mat5', 'maud', 'nist', 'ogg', 'paf', 'prc', 'pvf', 'raw', 's1', 's16', 's2', 's24', 's3', 's32', 's4', 's8', 'sb', 'sd2', 'sds', 'sf', 'sl', 'sln', 'smp', 'snd', 'sndfile', 'sndr', 'sndt', 'sou', 'sox', 'sph', 'sw', 'txw', 'u1', 'u16', 'u2', 'u24', 'u3', 'u32', 'u4', 'u8', 'ub', 'ul', 'uw', 'vms', 'voc', 'vorbis', 'vox', 'w64', 'wav', 'wavpcm', 'wv', 'wve', 'xa', 'xi']\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(sox.core._get_valid_formats())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "wireless-hypothetical",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"float64\n",
|
||
|
"(59471,)\n",
|
||
|
"16000\n",
|
||
|
"(54065,)\n",
|
||
|
"1.0999907518727459\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import soundfile as sf\n",
|
||
|
"wav='/workspace/DeepSpeech-2.x/examples/aishell/s1/../../..//examples/dataset/aishell/data_aishell/wav/dev/S0724/BAC009S0724W0190.wav'\n",
|
||
|
"samples, sr = sf.read(wav)\n",
|
||
|
"print(samples.dtype)\n",
|
||
|
"print(samples.shape)\n",
|
||
|
"print(sr)\n",
|
||
|
"tfm = sox.Transformer()\n",
|
||
|
"tfm.speed(1.1)\n",
|
||
|
"output_array = tfm.build_array(input_array=samples, sample_rate_in=sr)\n",
|
||
|
"output_array.dtype\n",
|
||
|
"print(output_array.shape)\n",
|
||
|
"print(len(samples)/len(output_array))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"id": "designed-fluid",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/x-wav;base64,UklGRsLQAQBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YZ7QAQAFAAwADAAOAAwAEAARABEAEQARABUAFgAYABYAGQAbAB4AHQAdACAAJgAjACEAKgAmACkAKQAoACUAKQAsAC0ALgAsAC8ALgAsAC0AKwAqACsALQAqACwAKgAnACgAJQAjACQAJwAmACcAJQAhACIAJgAkACYAIwAjACQAJAAiACAAJAAkAB8AIQAhABsAIAAeAB8AHAAcAB4AGQAVABYAGAAVABcAFAAUAA8AEQAQAA0AEgARAA8ADgAQAA0AEAANAAwADgALAAoAAgAHAAcAAwACAAEABwAKAAUABQACAAEAAwADAP7//v8CAAAAAQD+///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/e/9//3//g/9n/3v/c/97/2f/b/9v/1v/Z/9j/2P/Y/9j/1P/U/9X/0//V/9v/1v/Z/9j/2f/c/9r/2//a/93/3P/d/97/1//a/9v/2//i/9z/4P/c/+D/3//e/+H/3//k/+P/5//j/+P/4v/j/+H/4P/i/+D/4P/d/+H/4v/k/+L/5f/m/+X/4P/m/+j/5f/q/+f/5//n/+j/5f/m/+f/6f/p/+v/6v/q/+z/7//v/+7/8f/v/+3/6v/u/+7/7v/w/+//8v/y//L/8f/z//T/7//t/+//8P/w//P/7v/v//H/8v/y//L/7f/t//L/7v/v//P/7v/w/
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 17,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import IPython.display as ipd\n",
|
||
|
"ipd.Audio(wav) # load a local WAV file"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"id": "cultural-friendship",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/wav;base64,UklGRsLQAQBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YZ7QAQAaAEAAQABLAEAAVQBbAFsAWwBbAHAAdgCAAHYAhgCQAKEAmwCbAKsAywC7ALEA4QDLANwA3ADWAMYA3ADsAPEA9gDsAPwA9gDsAPEA5gDhAOYA8QDhAOwA4QDRANYAxgC7AMEA0QDLANEAxgCxALYAywDBAMsAuwC7AMEAwQC2AKsAwQDBAKYAsQCxAJAAqwChAKYAlgCWAKEAhgBwAHYAgABwAHsAawBrAFAAWwBVAEUAYABbAF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VACAABQAlACoAFQAKACAAIAAlACUAGgAQACAAKgAFADUAMAAaABAACgD7/wAA+//r/wAA6//7/wAA8P/g/9D/1v/Q/8v/y//A/7X/y/+1/7v/q/+7/8v/sP+1/7v/wP/F/7X/u/+7/7v/xf/F/7D/u/+l/6v/sP+b/6D/hf+b/5X/oP+b/6D/iv+K/4r/df+K/2X/X/9P/1//Vf9K/0//T/9V/y//Sv8//0r/L/86/zr/H/8v/yr/Kv8q/yr/FP8U/xr/D/8a/zr/H/8v/yr/L/8//zX/Ov81/0X/P/9F/0r/JP81/zr/Ov9f/z//Vf8//1X/T/9K/1r/T/9q/2X/ev9l/2X/X/9l/1r/Vf9f/1X/Vf9F/1r/X/9q/1//cP91/3D/Vf91/4D/cP+K/3r/ev96/4D/cP91/3r/hf+F/5D/iv+K/5X/pf+l/6D/sP+l/5v/iv+g/6D/oP+r/6X/tf+1/7X/sP+7/8D/pf+b/6X/q/+r/7v/oP+l/7D/tf+1/7X/m/+b/7X/oP+l/7v/oP+r/7D
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tfm = sox.Transformer()\n",
|
||
|
"tfm.speed(1.0)\n",
|
||
|
"output_array = tfm.build_array(input_array=samples, sample_rate_in=sr)\n",
|
||
|
"ipd.Audio(output_array, rate=sr) # load a NumPy array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"id": "fossil-lotus",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/wav;base64,UklG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FAA8ACAAEgAMAPv/AQD2//L/+//t/wEA+P/k/9T/0v/U/8f/z/+1/8P/v/+5/6//tf/L/7L/tf+8/8L/wf+z/7//tv/G/8P/tP+3/6T/r/+n/53/kf+O/5z/mv+f/5z/if+O/37/gP94/1z/Vf9b/1b/Sv9N/1b/Q/85/0f/RP84/zT/O/8e/zD/KP8q/yv/Hv8Q/xv/D/8b/zj/Hv8z/yX/Pf82/zr/NP9E/z7/R/9D/yL/Pv8x/1b/Sv9N/0X/Uf9P/03/V/9Y/2r/b/9x/1//ZP9h/1r/Vv9e/1T/Tf9N/2L/Zf9k/2v/ef9n/1r/gf9z/3//hP91/37/e/9z/3P/gP+D/4z/jP+K/5H/pv+j/6T/rf+l/5D/lP+j/57/qf+n/7P/t/+z/7L/v/+2/5n/pP+o/6z/t/+h/6b/tP+0/7j/pv+V/7L/o/+l/7r/nf+x/6n/t/+5/7L/yP++/83/wv/N/9//0//a/+j/7//5/wkA7v/p/+z/6//0//r/EAAJABgAHgAdAB0AFgAJAAAA/P8EAAMA7//y/+n/3P/Y/8X/vf/P/6j/tv+r/5v/o/+G/5L/rf+3/7r/o//A/83/zv/a/8n/+v/d////9P8CABYAFQAUAAAAGgAJABsAKgAgABYAJgADAAwADAAOAAUAFAACAPL/CwALAB4AJAAhACsAJwAVACoAFQAuAC4AMQA/AEEAPgA5AEwANQA6AFYANwA9AFwAPwAyAEAATABPAD0APgBAAEgATQBIAEIAMgBVAFkAeABOADkASgBVAGIASABFADkAQgAwAC4AJgAdAB0
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tfm = sox.Transformer()\n",
|
||
|
"tfm.speed(1.1)\n",
|
||
|
"output_array = tfm.build_array(input_array=samples, sample_rate_in=sr)\n",
|
||
|
"ipd.Audio(output_array, rate=sr) # load a NumPy array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"id": "constitutional-poker",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/wav;base64,UklGRmIEAgBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YT4EAgAXAD4APgBIAEMARQBcAFYAXABYAFkAbgBxAH4AdwB5AIoAkgCgAJcAmgCmAMMAxQClAMwA2QDJANsA2ADSAMUA0QDoAOkA9ADtAOoA+wDwAOkA7QDlAN8A3gDsAOgA3gDqANsAzgDTAMcAuwC5AMgAzADJAM0AwgCtALEAxwDBAMQAxAC0ALwAvgC+ALQAqAC6AMIArgCiALcAoQCRAKoAngCiAJoAjQCgAJIAegBsAHkAfQBvAHkAbABpAFsATQBgAEkASQBgAFkAUQBIAFQASgBJAFUAOwBFAEcAOgA3ABAAGAAtABYADgAHAAcAKQA0ABwAGQARAAMACwASAAoA8f/5/woAAAAEAPz/9P8BAPD/8/8UAAEAAAAbAPj/9f8NAAUAEQATAA4A/v8AAB8ADwAHAAoAAAABAP//+v/2/wUA/v/y/wUA+P/x/+n/2//g/8n/xf/T/7j/nv+l/63/n/+J/33/h/+D/3X/hf+F/3r/df9w/33/eP9t/2v/Uf9I/1j/Uf9L/03/RP9L/1H/Tf9S/0X/RP9H/z3/Pf89/0v/Uf89/zz/PP8m/yn/Nv8j/x//Gf8N/xf/C//5/vX+8/4A/wD/AP8Q/wz/Av8I/wj/Bv/6/vr++f7g/uH+4f7U/tf+0/65/rT+yf61/rX+wP6i/qj+nf6I/ov+iP6V/or+cv5p/m/+ZP5T/mL+Xv5U/lP+V/5h/mX+bv5U/kj+Wv5G/kH+Tf45/jD+PP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+//8j/vP+3/73/u/+9/8j
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 31,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"tfm = sox.Transformer()\n",
|
||
|
"tfm.speed(0.9)\n",
|
||
|
"output_array = tfm.build_array(input_array=samples, sample_rate_in=sr)\n",
|
||
|
"ipd.Audio(output_array, rate=sr) # load a NumPy array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 32,
|
||
|
"id": "threaded-strap",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"66078\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Z1A+gAAAACXBIWXMAAAsTAAALEwEAmpwYAAA8K0lEQVR4nO2dd3hUZfbHvycdQoAEQpEWmlQVJICoKApqABdcF8u6KlbUXX+77rqrIFZs7Lr2si5WXHXtrigI0myoSFB67xDpoYQEUs/vj7kTJpM7M/fO7XPP53nmye33ZObe97zveU8hZoYgCILgX5KcFkAQBEFwFlEEgiAIPkcUgSAIgs8RRSAIguBzRBEIgiD4HFEEgiAIPscURUBEBUS0log2ENF4lf1/IaJVRLSMiOYSUYeQfWOJaL3yGWuGPIIgCIJ2yGgcARElA1gH4DwAOwAsAvBbZl4Vcsw5ABYycxkR3QJgCDNfRkQ5AAoB5ANgAIsB9GPmA4aEEgRBEDRjx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mnGGJKLx2/0f3gOAODCZwMBhXqem68Vc+ScVbstm1j9YlXkCGIr3ZwPllVICnYDeGayONFRy0QaC2ZgW3H9Hp0f4wqqaxj7E3zCOJQ9JeXIGz8dO+PIMXTDG4VY8Ysy32By23n3/1ZE3Ldwk3WD/QofPvNmIorAJcQTgs9g3Pnh8nrbS3xat7jfQ3NwJIEzTKqN/lbF0YEArIk9eXZu9BTqKckWmu9kMGAIUQQeJpJZyM+eREcSUAlGGy2GNq16TCMXv/CdAYnUeXz2uqj7Uy1UBFpqdYsZNTKiCDxMpBffz7bSRExSN/zpbwA
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"librosa.display.waveplot(samples_out, sr=sr)\n",
|
||
|
"print(len(samples_out))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"id": "infectious-welcome",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import librosa\n",
|
||
|
"x, sr = librosa.load(wav, sr=16000)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 46,
|
||
|
"id": "musical-anatomy",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"float32\n",
|
||
|
"float64\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(x.dtype)\n",
|
||
|
"print(samples.dtype)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"id": "lucky-paraguay",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"sf.read?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 31,
|
||
|
"id": "annual-christmas",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"librosa.load?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 47,
|
||
|
"id": "infectious-seeker",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"True"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 47,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"np.allclose(x, samples)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "pregnant-conditioning",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import random"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 56,
|
||
|
"id": "logical-happiness",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"np.random.uniform?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 58,
|
||
|
"id": "rocky-plastic",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"random.uniform?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 60,
|
||
|
"id": "focused-compensation",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"np.random.RandomState?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 66,
|
||
|
"id": "centered-repository",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"random.sample?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 95,
|
||
|
"id": "inner-invite",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"array(['3', '5'], dtype='<U1')"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 95,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"np.random.choice(['5','4', '3'], 2, replace=False)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 81,
|
||
|
"id": "russian-chosen",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"['3', '4']"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 81,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"random.sample(['5','4', '3'], 2)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "equal-particle",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def change_speed(samples, speed_rate):\n",
|
||
|
" \"\"\"Change the audio speed by linear interpolation.\n",
|
||
|
"\n",
|
||
|
" Note that this is an in-place transformation.\n",
|
||
|
"\n",
|
||
|
" :param speed_rate: Rate of speed change:\n",
|
||
|
" speed_rate > 1.0, speed up the audio;\n",
|
||
|
" speed_rate = 1.0, unchanged;\n",
|
||
|
" speed_rate < 1.0, slow down the audio;\n",
|
||
|
" speed_rate <= 0.0, not allowed, raise ValueError.\n",
|
||
|
" :type speed_rate: float\n",
|
||
|
" :raises ValueError: If speed_rate <= 0.0.\n",
|
||
|
" \"\"\"\n",
|
||
|
" if speed_rate <= 0:\n",
|
||
|
" raise ValueError(\"speed_rate should be greater than zero.\")\n",
|
||
|
" old_length = samples.shape[0]\n",
|
||
|
" new_length = int(old_length / speed_rate)\n",
|
||
|
" old_indices = np.arange(old_length)\n",
|
||
|
" new_indices = np.linspace(start=0, stop=old_length, num=new_length)\n",
|
||
|
" samples = np.interp(new_indices, old_indices, samples)\n",
|
||
|
" return samples"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "tracked-purse",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"samples, sr = sf.read(wav)\n",
|
||
|
"samples_out = change_speed(samples, 1.0)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"id": "steady-mileage",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/wav;base64,UklGRsLQAQBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YZ7QAQAaAEAAQABLAEAAVQBbAFsAWwBbAHAAdgCAAHYAhgCQAKEAmwCbAKsAywC7ALEA4QDLANwA3ADWAMYA3ADsAPEA9gDsAPwA9gDsAPEA5gDhAOYA8QDhAOwA4QDRANYAxgC7AMEA0QDLANEAxgCxALYAywDBAMsAuwC7AMEAwQC2AKsAwQDBAKYAsQCxAJAAqwChAKYAlgCWAKEAhgBwAHYAgABwAHsAawBrAFAAWwBVAEUAYABbAFAASwBVAEUAVQBFAEAASwA7ADUACgAlACUAEAAKAAUAJQA1ABoAGgAKAAUAEAAQAPb/9v8KAAAABQD2//v/+//r/xAABQAAABoA8P8AAAoACgAVABAAAAAAACAACgAKAAUAAAAAAPv/9v8FAPv/9v8FAPD/8P/b/+D/y//F/9D/sP+b/6v/pf+Q/3r/hf+A/3X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K/2X/X/9P/1//Vf9K/0//T/9V/y//Sv8//0r/L/86/zr/H/8v/yr/Kv8q/yr/FP8U/xr/D/8a/zr/H/8v/yr/L/8//zX/Ov81/0X/P/9F/0r/JP81/zr/Ov9f/z//Vf8//1X/T/9K/1r/T/9q/2X/ev9l/2X/X/9l/1r/Vf9f/1X/Vf9F/1r/X/9q/1//cP91/3D/Vf91/4D/cP+K/3r/ev96/4D/cP91/3r/hf+F/5D/iv+K/5X/pf+l/6D/sP+l/5v/iv+g/6D/oP+r/6X/tf+1/7X/sP+7/8D/pf+b/6X/q/+r/7v/oP+l/7D/tf+1/7X/m/+b/7X/oP+l/7v/oP+r/7D
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"ipd.Audio(samples, rate=sr) # load a NumPy array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"id": "regulated-google",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/wav;base64,UklGRsLQAQBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YZ7QAQAbAEMAQwBOAEMAWQBfAF8AXwBfAHUAewCGAHsAiwCXAKcAogCiALMA1ADDALgA6gDUAOUA5QDfAM4A5QD2APsAAQH2AAYBAQH2APsA8ADqAPAA+wDqAPYA6gDaAN8AzgDDAMkA2gDUANoAzgC4AL4A1ADJANQAwwDDAMkAyQC+ALMAyQDJAK0AuAC4AJcAsgCnAK0AnACcAKcAiwB1AHsAhgB1AIAAbwBvA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GwAAABsAEAAWACAABgAnACwAFgALACEAIQAnACYAGwARACEAKwAGADcAMQAbABAACgD7/wAA+//r/wAA6v/7/wAA7//f/87/1P/O/8n/yP+9/7P/yP+y/7f/p/+4/8j/rf+y/7j/vf/D/7L/uP+4/7j/w//C/63/t/+i/6f/rP+W/5v/gP+W/5H/nP+W/5v/hf+F/4X/cP+F/17/WP9I/1j/Tf9C/0j/SP9N/yf/Qv83/0L/J/8y/zH/Fv8m/yH/If8h/yD/Cv8K/xD/Bf8R/zH/Fv8m/yH/J/83/yz/Mf8s/z3/N/89/0H/HP8s/zL/Mv9Y/zj/Tf84/03/SP9D/1P/Sf9k/1//dP9e/17/Wf9e/1P/Tv9Y/03/Tf89/1P/Wf9k/1n/av9v/2n/Tv9v/3r/av+F/3X/df91/3r/av9v/3X/gP+A/4v/hf+G/5H/of+h/5z/rP+h/5b/hv+c/5z/nP+n/6L/sv+y/7L/rf+4/73/of+W/6L/p/+n/7f/nP+i/63/sv+y/7H/lv+X/7L/nP+i/7f/nP+n/6z
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"ipd.Audio(samples_out, rate=sr) # load a NumPy array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"id": "homeless-forge",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/wav;base64,UklGRoSmAQBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YWCmAQAbAEAAQwBIAEkAWQBcAFwAXABvAH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+7/8H/vv+4/7r/uv/D/8X/sP+3/6b/rP+m/53/jv+U/5X/nv+a/5z/if+J/4D/f/9x/2D/UP9d/1P/Sf9O/1D/Q/88/0L/Rv8y/zj/N/8f/yz/KP8o/yj/Gv8S/xf/Dv8Z/zT/If8s/yr/Nv83/zf/NP9C/z7/RP8//yj/Nf84/1D/Rv9Q/z//U/9N/0z/Vf9a/2b/cf9p/2T/Xv9j/1j/Vv9a/1P/S/9R/13/Z/9f/2//c/9o/17/ef92/4D/ff95/3n/fv9v/3X/ff+E/4r/i/+J/5P/pP+k/6H/rf+h/5L/lf+f/5//qP+l/7X/tf+z/7P/vf+x/57/ov+p/6r/uf+g/6f/sf+1/7X/o/+a/7D/oP+l/7b/ov+s/63/tv+1/7f/w//A/8r/xf/M/9z/1f/b/+f/7//5/wkA6//r/+v/7f/z//7/DAAMABgAIAAbAB4AFAAKAAAA/v8FAP//8v/w/+r/2//X/8X/wf/E/67/tf+o/5r/o/+G/5T/qv+3/7T/qP/B/8r/z//a/8z/8v/n//f/9/8GABEAGQAQAAEAGAANABsAKAAfABwAIAAFAA8ACwAOAAgAEAABAPn/BgAOAB0AJQAgACsAJQAbACMAHQAsAC4ANABAAEAAPwA7AEgAOQA/AE8AOABDAFoAQAAzAEIASwBMAEAAPQBDAEYAUABGAEMANwBRAGAAbwBNAEIARgBaAGAASgBDAD0APgAyAC4AJAAgABs
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"samples_out = change_speed(samples, 1.1)\n",
|
||
|
"ipd.Audio(samples_out, rate=sr) # load a NumPy array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 29,
|
||
|
"id": "exciting-blocking",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"\n",
|
||
|
" <audio controls=\"controls\" >\n",
|
||
|
" <source src=\"data:audio/wav;base64,UklGRmAEAgBXQVZFZm10IBAAAAABAAEAgD4AAAB9AAACABAAZGF0YTwEAgAbAD0AQQBJAEUATABZAFwAXABcAFwAcAB3AH8AfACAAI0AmACiAJ4AngCtAMkAxAC4AM0A3ADUAOAA3wDaAMsA2wDrAPMA+AD3APUA/wD6APAA9QDtAOcA6ADwAO8A6ADuAOMA1QDaAM0AwgDCAM0A0wDRANMAyAC0ALkAywDIAMsAxwC/AMAAxADDALkAsADAAMQAtACuALQAqgCZAK0ApACoAJwAmQCfAJYAfwB0AHoAgQByAHwAcABtAFwAVwBaAFIATABhAFwAUwBNAFQATQBPAFAARQBDAEoAPAA3ABMAHgAmABsADgAJAAwAJwA2AB0AGwAPAAcACgAQAAgA9v/4/woAAQAEAPr/+f/7//T/9v8OAAQAAAAYAPn//P8GAAoADwAUAA0AAAAAAB0ADwAKAAcAAgAAAP//+v/3/wUA/P/3/wAA+f/w/+f/3P/b/8n/xP/O/7X/n/+j/6b/m/+H/3r/gv99/3P/gP9//3f/cP9v/3T/dP9n/2f/Sv9H/07/S/9H/0T/Qf9D/0z/R/9M/z//QP8+/zn/Nv86/0P/Sv82/zb/Mv8h/yX/Kf8f/xX/Ev8G/xD/Af/y/uv+7f71/vj++v4F/wT/+v7//gD//P7z/vL+7P7b/tX+2P7J/s7+xv6w/q/+tv6w/qn+sv6Y/p3+jv6A/nz+gP6F/nz+Z/5d/mD+Vv5H/lP+Tv5I/kb+Sv5S/lj+Xv5G/jz+SP44/jb+OP4s/iP+Kv4q/iX+IP4t/jT+K/4f/hj+Hf4r/hv+Jf4R/hz+HP4T/hX+Gv4c/hz+Ef4f/iT+Kf4m/jn+Q/5C/kn+Tf5B/kb+UP5Z/lz+XP5Z/mH+c/52/nP+gv59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igCLAIkAfwB0AGkAdwBpAFoATwBCADkALwAgABMACwAQAAYABQDy/+T/6//s/97/2v/b/9//xv+y/7L/qv+m/67/tP+x/6f/mP+O/3z/eP97/4D/d/9k/1n/Tf9R/z3/Lv8n/y3/N/8u/yD/Jv8U/wv/EP8H/xH/CP8A//j+9f4A/wL/EP8G/+X+8/76/vr++P7z/vL+/P4L/xr/Ev8k/yT/IP8l/yT/GP8i/yz/O/8l/zD/Ov9C/07/Tv86/zj/Qf83/z//Tf9E/z//RP9K/1D/S/9B/0H/Qf9F/0D/P/9G/07/T/9B/xv/Kv8w/xX/H/8o/yj/K/8z/07/Xf9s/03/M/8r/zT/Rf9Z/2f/Zf9X/03/Q/9J/0X/Sv9P/0r/Sf9U/2L/Z/9a/1f/V/9g/2D/XP9m/2L/Y/9x/27/ef99/4b/if+B/3v/b/9Y/2v/bf9l/2n/dv97/2//Y/97/47/if+N/3b/d/99/3T/af9s/2n/c/99/4b/fP9x/3P/c/9p/2P/aP9t/2j/Xv9h/1v/VP9Z/17/Uf88/0L/S/9R/17/Xv9U/1b/Xv9W/0//Qv9L/0z/SP9D/0H/RP89/yv/Lv88/zz/QP9B/1P/Wv9Q/0r/UP9L/0b/N/9N/1L/Tv9S/1f/W/9m/3L/cv9j/2L/av9m/2j/cv92/3T/d/9z/4L/fv+F/4//n/+k/6L/qv+u/67/qf+p/7X/sv/D/9D/zv/S/83/4P/q//3/8P/u//b/9v/0//X/4//2/wAAAAAIAAoACAAHAAoABADz/wUACgAUAAUABgATAA8ACQAYABEAFgAgAAkAHQApAB8AEQASACAAIQAmACYAHQATABoAJgAbABYANQAuABoAEQALAP/////+//T/8v/7/+3/+/8AAPP/5P/V/9L/0v/N/8r/yP++/7X/xv+6/7f/sf+w/7//w/+v/7T/uf++/8P/uv+3/7n/uf+8/8T
|
||
|
" Your browser does not support the audio element.\n",
|
||
|
" </audio>\n",
|
||
|
" "
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"<IPython.lib.display.Audio object>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 29,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"samples_out = change_speed(samples, 0.9)\n",
|
||
|
"ipd.Audio(samples_out, rate=sr) # load a NumPy array"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 30,
|
||
|
"id": "through-botswana",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"66078\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(len(samples_out))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 22,
|
||
|
"id": "cellular-violence",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Collecting matplotlib\n",
|
||
|
" Downloading matplotlib-3.4.1-cp37-cp37m-manylinux1_x86_64.whl (10.3 MB)\n",
|
||
|
"\u001b[K |████████████████████████████████| 10.3 MB 691 kB/s eta 0:00:01\n",
|
||
|
"\u001b[?25hRequirement already satisfied: pillow>=6.2.0 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from matplotlib) (8.1.0)\n",
|
||
|
"Requirement already satisfied: numpy>=1.16 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from matplotlib) (1.20.1)\n",
|
||
|
"Requirement already satisfied: python-dateutil>=2.7 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from matplotlib) (2.8.1)\n",
|
||
|
"Collecting kiwisolver>=1.0.1\n",
|
||
|
" Downloading kiwisolver-1.3.1-cp37-cp37m-manylinux1_x86_64.whl (1.1 MB)\n",
|
||
|
"\u001b[K |████████████████████████████████| 1.1 MB 45.9 MB/s eta 0:00:01\n",
|
||
|
"\u001b[?25hRequirement already satisfied: pyparsing>=2.2.1 in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from matplotlib) (2.4.7)\n",
|
||
|
"Collecting cycler>=0.10\n",
|
||
|
" Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)\n",
|
||
|
"Requirement already satisfied: six in /workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages (from cycler>=0.10->matplotlib) (1.15.0)\n",
|
||
|
"Installing collected packages: kiwisolver, cycler, matplotlib\n",
|
||
|
"Successfully installed cycler-0.10.0 kiwisolver-1.3.1 matplotlib-3.4.1\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"!pip install matplotlib\n",
|
||
|
"%matplotlib inline\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import librosa.display"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"id": "undefined-parade",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<matplotlib.collections.PolyCollection at 0x7f6a2594afd0>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Z1A+gAAAACXBIWXMAAAsTAAALEwEAmpwYAAA8K0lEQVR4nO2dd3hUZfbHvycdQoAEQpEWmlQVJICoKApqABdcF8u6KlbUXX+77rqrIFZs7Lr2si5WXHXtrigI0myoSFB67xDpoYQEUs/vj7kTJpM7M/fO7XPP53nmye33ZObe97z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8cvCZQH6JVvowdV+t2MGg3DioCZqwDcikADvhrAe8y8kogmEdEoACCi/kS0A8AlAP5NRCuVc4sBPIiAMlkEYJKyzXfE6zXk10nScOL5/rwGA9hbUn58BdE7EOH7UlPqvu4V1TXYsr/UPAEd5sWv/BddbxamzBEw8wxmPpGZOzPzw8q2e5l5mrK8iJnbMnMmMzdj5l4h577KzF2Uz2tmyONF4mnGGJKLx2/0f3gOAODCZwMBhXqem68Vc+ScVbstm1j9YlXkCGIr3ZwPllVICnYDeGayONFRy0QaC2ZgW3H9Hp0f4wqqaxj7E3zCOJQ9JeXIGz8dO+PIMXTDG4VY8Ysy32By23n3/1ZE3Ldwk3WD/QofPvNmIorAJcQTgs9g3Pnh8nrbS3xat7jfQ3NwJIEzTKqN/lbF0YEArIk9eXZu9BTqKckWmu9kMGAIUQQeJpJZyM+eREcSUAlGGy2GNq16TCMXv/CdAYnUeXz2uqj7Uy1UBFpqdYsZNTKiCDxMpBffz7bSRExSN/zpbwA
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"librosa.display.waveplot(samples_out, sr=sr)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 33,
|
||
|
"id": "special-delicious",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import getpass"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 34,
|
||
|
"id": "seasonal-consensus",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"['GetPassWarning',\n",
|
||
|
" '__all__',\n",
|
||
|
" '__builtins__',\n",
|
||
|
" '__cached__',\n",
|
||
|
" '__doc__',\n",
|
||
|
" '__file__',\n",
|
||
|
" '__loader__',\n",
|
||
|
" '__name__',\n",
|
||
|
" '__package__',\n",
|
||
|
" '__spec__',\n",
|
||
|
" '_raw_input',\n",
|
||
|
" 'contextlib',\n",
|
||
|
" 'fallback_getpass',\n",
|
||
|
" 'getpass',\n",
|
||
|
" 'getuser',\n",
|
||
|
" 'io',\n",
|
||
|
" 'os',\n",
|
||
|
" 'sys',\n",
|
||
|
" 'termios',\n",
|
||
|
" 'unix_getpass',\n",
|
||
|
" 'warnings',\n",
|
||
|
" 'win_getpass']"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 34,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"dir(getpass)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 35,
|
||
|
"id": "dress-distinction",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"getpass?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 38,
|
||
|
"id": "rental-anthony",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Worker:"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import multiprocessing\n",
|
||
|
"import cProfile\n",
|
||
|
"import time\n",
|
||
|
"\n",
|
||
|
"def worker(num):\n",
|
||
|
" time.sleep(3)\n",
|
||
|
" print('Worker:', num)\n",
|
||
|
"\n",
|
||
|
"def profile_worker(num):\n",
|
||
|
" cProfile.runctx('worker(num)', globals(), locals(), 'profile-%d.out' %num)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"for i in range(5):\n",
|
||
|
" p = multiprocessing.Process(target=profile_worker, args=(i,))\n",
|
||
|
" p.start()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 41,
|
||
|
"id": "separated-restriction",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"!ls"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "painted-variable",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"(2, 2)\n",
|
||
|
"[ 1 20]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"l = [(1, 20), (2, 30)]\n",
|
||
|
"scores = np.array(l)\n",
|
||
|
"print(scores.shape)\n",
|
||
|
"print(scores[0])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"id": "satellite-insider",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[0 1]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sort_idx = np.argsort(scores[:, -1])\n",
|
||
|
"print(sort_idx)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "developed-thirty",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[[ 1 20]\n",
|
||
|
" [ 2 30]]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sorted_val_scores = scores[sort_idx][::1]\n",
|
||
|
"print(sorted_val_scores)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"id": "official-bench",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[[ 1 20]\n",
|
||
|
" [ 2 30]]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"sorted_val_scores = scores[sort_idx]\n",
|
||
|
"print(sorted_val_scores)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"id": "ranking-camera",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"b'\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x1e\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\n",
|
||
|
"[ 1 20 2 30]\n",
|
||
|
"[[ 1 20]\n",
|
||
|
" [ 2 30]]\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.\n",
|
||
|
" \"\"\"Entry point for launching an IPython kernel.\n",
|
||
|
"/workspace/DeepSpeech-2.x/tools/venv/lib/python3.7/site-packages/ipykernel_launcher.py:3: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead\n",
|
||
|
" This is separate from the ipykernel package so we can avoid doing imports until\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"a = scores.tostring()\n",
|
||
|
"print(a)\n",
|
||
|
"b = np.fromstring(a, scores.dtype)\n",
|
||
|
"print(b)\n",
|
||
|
"print(scores)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "breeding-proxy",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"numpy.int16"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"np.int16"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "coordinate-hungary",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"dtype = np.dtype('int16')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"id": "specified-jackson",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"int16\n",
|
||
|
"16\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"print(dtype)\n",
|
||
|
"dtype is np.int16\n",
|
||
|
"print(np.iinfo(dtype).bits)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "activated-insight",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"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.0"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|