mirror of https://github.com/coqui-ai/TTS.git
780 lines
54 KiB
Plaintext
780 lines
54 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Overview\n",
|
|
"\n",
|
|
"This notebook can be used with both a single or multi- speaker corpus and allows the interactive plotting of speaker embeddings linked to underlying audio (see instructions in the repo's speaker_embedding directory)\n",
|
|
"\n",
|
|
"Depending on the directory structure used for your corpus, you may need to adjust handling of **speaker_to_utter** and **locations**."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import os\n",
|
|
"import glob\n",
|
|
"import random\n",
|
|
"import numpy as np\n",
|
|
"import torch\n",
|
|
"import umap\n",
|
|
"\n",
|
|
"from TTS.speaker_encoder.model import SpeakerEncoder\n",
|
|
"from TTS.utils.audio import AudioProcessor\n",
|
|
"from TTS.utils.generic_utils import load_config\n",
|
|
"\n",
|
|
"from bokeh.io import output_notebook, show\n",
|
|
"from bokeh.plotting import figure\n",
|
|
"from bokeh.models import HoverTool, ColumnDataSource, BoxZoomTool, ResetTool, OpenURL, TapTool\n",
|
|
"from bokeh.transform import factor_cmap, factor_mark\n",
|
|
"from bokeh.palettes import Category10"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"For larger sets of speakers, you can use **Category20**, but you need to change it in the **pal** variable too\n",
|
|
"\n",
|
|
"List of Bokeh palettes here: http://docs.bokeh.org/en/1.4.0/docs/reference/palettes.html\n",
|
|
"\n",
|
|
"**NB:** if you have problems with other palettes, first see https://stackoverflow.com/questions/48333820/why-do-some-bokeh-palettes-raise-a-valueerror-when-used-in-factor-cmap"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"\n",
|
|
" <div class=\"bk-root\">\n",
|
|
" <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
|
|
" <span id=\"1001\">Loading BokehJS ...</span>\n",
|
|
" </div>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"application/javascript": [
|
|
"\n",
|
|
"(function(root) {\n",
|
|
" function now() {\n",
|
|
" return new Date();\n",
|
|
" }\n",
|
|
"\n",
|
|
" var force = true;\n",
|
|
"\n",
|
|
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
|
|
" root._bokeh_onload_callbacks = [];\n",
|
|
" root._bokeh_is_loading = undefined;\n",
|
|
" }\n",
|
|
"\n",
|
|
" var JS_MIME_TYPE = 'application/javascript';\n",
|
|
" var HTML_MIME_TYPE = 'text/html';\n",
|
|
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
|
|
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
|
|
"\n",
|
|
" /**\n",
|
|
" * Render data to the DOM node\n",
|
|
" */\n",
|
|
" function render(props, node) {\n",
|
|
" var script = document.createElement(\"script\");\n",
|
|
" node.appendChild(script);\n",
|
|
" }\n",
|
|
"\n",
|
|
" /**\n",
|
|
" * Handle when an output is cleared or removed\n",
|
|
" */\n",
|
|
" function handleClearOutput(event, handle) {\n",
|
|
" var cell = handle.cell;\n",
|
|
"\n",
|
|
" var id = cell.output_area._bokeh_element_id;\n",
|
|
" var server_id = cell.output_area._bokeh_server_id;\n",
|
|
" // Clean up Bokeh references\n",
|
|
" if (id != null && id in Bokeh.index) {\n",
|
|
" Bokeh.index[id].model.document.clear();\n",
|
|
" delete Bokeh.index[id];\n",
|
|
" }\n",
|
|
"\n",
|
|
" if (server_id !== undefined) {\n",
|
|
" // Clean up Bokeh references\n",
|
|
" var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
|
|
" cell.notebook.kernel.execute(cmd, {\n",
|
|
" iopub: {\n",
|
|
" output: function(msg) {\n",
|
|
" var id = msg.content.text.trim();\n",
|
|
" if (id in Bokeh.index) {\n",
|
|
" Bokeh.index[id].model.document.clear();\n",
|
|
" delete Bokeh.index[id];\n",
|
|
" }\n",
|
|
" }\n",
|
|
" }\n",
|
|
" });\n",
|
|
" // Destroy server and session\n",
|
|
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
|
|
" cell.notebook.kernel.execute(cmd);\n",
|
|
" }\n",
|
|
" }\n",
|
|
"\n",
|
|
" /**\n",
|
|
" * Handle when a new output is added\n",
|
|
" */\n",
|
|
" function handleAddOutput(event, handle) {\n",
|
|
" var output_area = handle.output_area;\n",
|
|
" var output = handle.output;\n",
|
|
"\n",
|
|
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
|
|
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
|
|
" return\n",
|
|
" }\n",
|
|
"\n",
|
|
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
|
|
"\n",
|
|
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
|
|
" toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
|
|
" // store reference to embed id on output_area\n",
|
|
" output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
|
|
" }\n",
|
|
" if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
|
|
" var bk_div = document.createElement(\"div\");\n",
|
|
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
|
|
" var script_attrs = bk_div.children[0].attributes;\n",
|
|
" for (var i = 0; i < script_attrs.length; i++) {\n",
|
|
" toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
|
|
" }\n",
|
|
" // store reference to server id on output_area\n",
|
|
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
|
|
" }\n",
|
|
" }\n",
|
|
"\n",
|
|
" function register_renderer(events, OutputArea) {\n",
|
|
"\n",
|
|
" function append_mime(data, metadata, element) {\n",
|
|
" // create a DOM node to render to\n",
|
|
" var toinsert = this.create_output_subarea(\n",
|
|
" metadata,\n",
|
|
" CLASS_NAME,\n",
|
|
" EXEC_MIME_TYPE\n",
|
|
" );\n",
|
|
" this.keyboard_manager.register_events(toinsert);\n",
|
|
" // Render to node\n",
|
|
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
|
|
" render(props, toinsert[toinsert.length - 1]);\n",
|
|
" element.append(toinsert);\n",
|
|
" return toinsert\n",
|
|
" }\n",
|
|
"\n",
|
|
" /* Handle when an output is cleared or removed */\n",
|
|
" events.on('clear_output.CodeCell', handleClearOutput);\n",
|
|
" events.on('delete.Cell', handleClearOutput);\n",
|
|
"\n",
|
|
" /* Handle when a new output is added */\n",
|
|
" events.on('output_added.OutputArea', handleAddOutput);\n",
|
|
"\n",
|
|
" /**\n",
|
|
" * Register the mime type and append_mime function with output_area\n",
|
|
" */\n",
|
|
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
|
|
" /* Is output safe? */\n",
|
|
" safe: true,\n",
|
|
" /* Index of renderer in `output_area.display_order` */\n",
|
|
" index: 0\n",
|
|
" });\n",
|
|
" }\n",
|
|
"\n",
|
|
" // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
|
|
" if (root.Jupyter !== undefined) {\n",
|
|
" var events = require('base/js/events');\n",
|
|
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
|
|
"\n",
|
|
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
|
|
" register_renderer(events, OutputArea);\n",
|
|
" }\n",
|
|
" }\n",
|
|
"\n",
|
|
" \n",
|
|
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
|
|
" root._bokeh_timeout = Date.now() + 5000;\n",
|
|
" root._bokeh_failed_load = false;\n",
|
|
" }\n",
|
|
"\n",
|
|
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
|
|
" \"<div style='background-color: #fdd'>\\n\"+\n",
|
|
" \"<p>\\n\"+\n",
|
|
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
|
|
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
|
|
" \"</p>\\n\"+\n",
|
|
" \"<ul>\\n\"+\n",
|
|
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
|
|
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
|
|
" \"</ul>\\n\"+\n",
|
|
" \"<code>\\n\"+\n",
|
|
" \"from bokeh.resources import INLINE\\n\"+\n",
|
|
" \"output_notebook(resources=INLINE)\\n\"+\n",
|
|
" \"</code>\\n\"+\n",
|
|
" \"</div>\"}};\n",
|
|
"\n",
|
|
" function display_loaded() {\n",
|
|
" var el = document.getElementById(\"1001\");\n",
|
|
" if (el != null) {\n",
|
|
" el.textContent = \"BokehJS is loading...\";\n",
|
|
" }\n",
|
|
" if (root.Bokeh !== undefined) {\n",
|
|
" if (el != null) {\n",
|
|
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
|
|
" }\n",
|
|
" } else if (Date.now() < root._bokeh_timeout) {\n",
|
|
" setTimeout(display_loaded, 100)\n",
|
|
" }\n",
|
|
" }\n",
|
|
"\n",
|
|
"\n",
|
|
" function run_callbacks() {\n",
|
|
" try {\n",
|
|
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
|
|
" if (callback != null)\n",
|
|
" callback();\n",
|
|
" });\n",
|
|
" } finally {\n",
|
|
" delete root._bokeh_onload_callbacks\n",
|
|
" }\n",
|
|
" console.debug(\"Bokeh: all callbacks have finished\");\n",
|
|
" }\n",
|
|
"\n",
|
|
" function load_libs(css_urls, js_urls, callback) {\n",
|
|
" if (css_urls == null) css_urls = [];\n",
|
|
" if (js_urls == null) js_urls = [];\n",
|
|
"\n",
|
|
" root._bokeh_onload_callbacks.push(callback);\n",
|
|
" if (root._bokeh_is_loading > 0) {\n",
|
|
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
|
|
" return null;\n",
|
|
" }\n",
|
|
" if (js_urls == null || js_urls.length === 0) {\n",
|
|
" run_callbacks();\n",
|
|
" return null;\n",
|
|
" }\n",
|
|
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
|
|
" root._bokeh_is_loading = css_urls.length + js_urls.length;\n",
|
|
"\n",
|
|
" function on_load() {\n",
|
|
" root._bokeh_is_loading--;\n",
|
|
" if (root._bokeh_is_loading === 0) {\n",
|
|
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
|
|
" run_callbacks()\n",
|
|
" }\n",
|
|
" }\n",
|
|
"\n",
|
|
" function on_error() {\n",
|
|
" console.error(\"failed to load \" + url);\n",
|
|
" }\n",
|
|
"\n",
|
|
" for (var i = 0; i < css_urls.length; i++) {\n",
|
|
" var url = css_urls[i];\n",
|
|
" const element = document.createElement(\"link\");\n",
|
|
" element.onload = on_load;\n",
|
|
" element.onerror = on_error;\n",
|
|
" element.rel = \"stylesheet\";\n",
|
|
" element.type = \"text/css\";\n",
|
|
" element.href = url;\n",
|
|
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
|
|
" document.body.appendChild(element);\n",
|
|
" }\n",
|
|
"\n",
|
|
" for (var i = 0; i < js_urls.length; i++) {\n",
|
|
" var url = js_urls[i];\n",
|
|
" var element = document.createElement('script');\n",
|
|
" element.onload = on_load;\n",
|
|
" element.onerror = on_error;\n",
|
|
" element.async = false;\n",
|
|
" element.src = url;\n",
|
|
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
|
|
" document.head.appendChild(element);\n",
|
|
" }\n",
|
|
" };var element = document.getElementById(\"1001\");\n",
|
|
" if (element == null) {\n",
|
|
" console.error(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n",
|
|
" return false;\n",
|
|
" }\n",
|
|
"\n",
|
|
" function inject_raw_css(css) {\n",
|
|
" const element = document.createElement(\"style\");\n",
|
|
" element.appendChild(document.createTextNode(css));\n",
|
|
" document.body.appendChild(element);\n",
|
|
" }\n",
|
|
"\n",
|
|
" var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.3.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.3.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.3.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.3.4.min.js\"];\n",
|
|
" var css_urls = [];\n",
|
|
"\n",
|
|
" var inline_js = [\n",
|
|
" function(Bokeh) {\n",
|
|
" Bokeh.set_log_level(\"info\");\n",
|
|
" },\n",
|
|
" \n",
|
|
" function(Bokeh) {\n",
|
|
" \n",
|
|
" },\n",
|
|
" function(Bokeh) {} // ensure no trailing comma for IE\n",
|
|
" ];\n",
|
|
"\n",
|
|
" function run_inline_js() {\n",
|
|
" \n",
|
|
" if ((root.Bokeh !== undefined) || (force === true)) {\n",
|
|
" for (var i = 0; i < inline_js.length; i++) {\n",
|
|
" inline_js[i].call(root, root.Bokeh);\n",
|
|
" }if (force === true) {\n",
|
|
" display_loaded();\n",
|
|
" }} else if (Date.now() < root._bokeh_timeout) {\n",
|
|
" setTimeout(run_inline_js, 100);\n",
|
|
" } else if (!root._bokeh_failed_load) {\n",
|
|
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
|
|
" root._bokeh_failed_load = true;\n",
|
|
" } else if (force !== true) {\n",
|
|
" var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n",
|
|
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
|
|
" }\n",
|
|
"\n",
|
|
" }\n",
|
|
"\n",
|
|
" if (root._bokeh_is_loading === 0) {\n",
|
|
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
|
|
" run_inline_js();\n",
|
|
" } else {\n",
|
|
" load_libs(css_urls, js_urls, function() {\n",
|
|
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
|
|
" run_inline_js();\n",
|
|
" });\n",
|
|
" }\n",
|
|
"}(window));"
|
|
],
|
|
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"1001\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };var element = document.getElementById(\"1001\");\n if (element == null) {\n console.error(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n return false;\n }\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.3.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.3.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.3.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.3.4.min.js\"];\n var css_urls = [];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"output_notebook()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"You should also adjust all the path constants to point at the relevant locations for you locally"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"MODEL_RUN_PATH = \"/home/neil/main/Projects/TTS3/speaker_encoder/libritts_360-half-September-28-2019_10+46AM-8565c50/\"\n",
|
|
"MODEL_PATH = MODEL_RUN_PATH + \"best_model.pth.tar\"\n",
|
|
"CONFIG_PATH = MODEL_RUN_PATH + \"config.json\"\n",
|
|
"\n",
|
|
"# My single speaker locations\n",
|
|
"#EMBED_PATH = \"/home/neil/main/Projects/TTS3/embeddings/neil14/\"\n",
|
|
"#AUDIO_PATH = \"/home/neil/data/Projects/NeilTTS/neil14/wavs/\"\n",
|
|
"\n",
|
|
"# My multi speaker locations\n",
|
|
"EMBED_PATH = \"/home/neil/main/Projects/TTS3/embeddings/libritts_360/\"\n",
|
|
"AUDIO_PATH = \"/home/neil/main/Projects/LibriTTS/LibriTTS/train-clean-360/\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"best_model.pth.tar\r\n",
|
|
"config.json\r\n",
|
|
"events.out.tfevents.1569660396.erogol-desktop\r\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"!ls -1 $MODEL_RUN_PATH"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" > Setting up Audio Processor...\n",
|
|
" | > sample_rate:24000\n",
|
|
" | > num_mels:40\n",
|
|
" | > min_level_db:-100\n",
|
|
" | > frame_shift_ms:12.5\n",
|
|
" | > frame_length_ms:50\n",
|
|
" | > ref_level_db:20\n",
|
|
" | > num_freq:1025\n",
|
|
" | > power:None\n",
|
|
" | > preemphasis:0.98\n",
|
|
" | > griffin_lim_iters:None\n",
|
|
" | > signal_norm:True\n",
|
|
" | > symmetric_norm:True\n",
|
|
" | > mel_fmin:0\n",
|
|
" | > mel_fmax:8000.0\n",
|
|
" | > max_norm:4.0\n",
|
|
" | > clip_norm:True\n",
|
|
" | > do_trim_silence:False\n",
|
|
" | > sound_norm:False\n",
|
|
" | > n_fft:2048\n",
|
|
" | > hop_length:300\n",
|
|
" | > win_length:1200\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"CONFIG = load_config(CONFIG_PATH)\n",
|
|
"ap = AudioProcessor(**CONFIG['audio'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Bring in the embeddings created by **compute_embeddings.py**"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Embeddings found: 116500\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"embed_files = glob.glob(EMBED_PATH+\"/**/*.npy\", recursive=True)\n",
|
|
"print(f'Embeddings found: {len(embed_files)}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Check that we did indeed find an embedding"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"'/home/neil/main/Projects/TTS3/embeddings/libritts_360/7732/107520/7732_107520_000009_000003.npy'"
|
|
]
|
|
},
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"embed_files[0]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Process the speakers\n",
|
|
"\n",
|
|
"Assumes count of **speaker_paths** corresponds to number of speakers (so a corpus in just one directory would be treated like a single speaker and the multiple directories of LibriTTS are treated as distinct speakers)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Speaker count: 904\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"speaker_paths = list(set([os.path.dirname(os.path.dirname(embed_file)) for embed_file in embed_files]))\n",
|
|
"speaker_to_utter = {}\n",
|
|
"for embed_file in embed_files:\n",
|
|
" speaker_path = os.path.dirname(os.path.dirname(embed_file))\n",
|
|
" try:\n",
|
|
" speaker_to_utter[speaker_path].append(embed_file)\n",
|
|
" except:\n",
|
|
" speaker_to_utter[speaker_path]=[embed_file]\n",
|
|
"print(f'Speaker count: {len(speaker_paths)}')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Set up the embeddings\n",
|
|
"\n",
|
|
"Adjust the number of speakers to select and the number of utterances from each speaker and they will be randomly sampled from the corpus"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"embeds = []\n",
|
|
"labels = []\n",
|
|
"locations = []\n",
|
|
"\n",
|
|
"# single speaker \n",
|
|
"#num_speakers = 1\n",
|
|
"#num_utters = 1000\n",
|
|
"\n",
|
|
"# multi speaker\n",
|
|
"num_speakers = 10\n",
|
|
"num_utters = 20\n",
|
|
"\n",
|
|
"\n",
|
|
"speaker_idxs = np.random.choice(range(len(speaker_paths)), num_speakers, replace=False )\n",
|
|
"\n",
|
|
"for speaker_num, speaker_idx in enumerate(speaker_idxs):\n",
|
|
" speaker_path = speaker_paths[speaker_idx]\n",
|
|
" speakers_utter = speaker_to_utter[speaker_path]\n",
|
|
" utter_idxs = np.random.randint(0, len(speakers_utter) , num_utters)\n",
|
|
" for utter_idx in utter_idxs:\n",
|
|
" embed_path = speaker_to_utter[speaker_path][utter_idx]\n",
|
|
" embed = np.load(embed_path)\n",
|
|
" embeds.append(embed)\n",
|
|
" labels.append(str(speaker_num))\n",
|
|
" locations.append(embed_path.replace(EMBED_PATH, '').replace('.npy','.wav'))\n",
|
|
"embeds = np.concatenate(embeds)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Load embeddings with UMAP"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"model = umap.UMAP()\n",
|
|
"projection = model.fit_transform(embeds)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Interactively charting the data in Bokeh\n",
|
|
"\n",
|
|
"Set up various details for Bokeh to plot the data\n",
|
|
"\n",
|
|
"You can use the regular Bokeh [tools](http://docs.bokeh.org/en/1.4.0/docs/user_guide/tools.html?highlight=tools) to explore the data, with reset setting it back to normal\n",
|
|
"\n",
|
|
"Once you have started the local server (see cell below) you can then click on plotted points which will open a tab to play the audio for that point, enabling easy exploration of your corpus\n",
|
|
"\n",
|
|
"File location in the tooltip is given relative to **AUDIO_PATH**"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 11,
|
|
"metadata": {
|
|
"scrolled": false
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
" <div class=\"bk-root\" id=\"e515e894-9f0f-4373-b879-972fbfc359fa\" data-root-id=\"1007\"></div>\n"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"application/javascript": [
|
|
"(function(root) {\n",
|
|
" function embed_document(root) {\n",
|
|
" \n",
|
|
" var docs_json = {\"95a95da2-6471-485d-aafc-7fcb3a90c6fa\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1016\",\"type\":\"LinearAxis\"}],\"center\":[{\"id\":\"1020\",\"type\":\"Grid\"},{\"id\":\"1025\",\"type\":\"Grid\"}],\"left\":[{\"id\":\"1021\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"renderers\":[{\"id\":\"1035\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"1038\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"1026\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"1008\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1012\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"1010\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"1014\",\"type\":\"LinearScale\"}},\"id\":\"1007\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"source\":{\"id\":\"1002\",\"type\":\"ColumnDataSource\"}},\"id\":\"1036\",\"type\":\"CDSView\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1038\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null},\"id\":\"1008\",\"type\":\"DataRange1d\"},{\"attributes\":{\"url\":\"http://localhost:8000/@desc\"},\"id\":\"1046\",\"type\":\"OpenURL\"},{\"attributes\":{\"callback\":null},\"id\":\"1010\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1045\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1012\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1039\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1003\",\"type\":\"HoverTool\"},{\"id\":\"1004\",\"type\":\"BoxZoomTool\"},{\"id\":\"1005\",\"type\":\"ResetTool\"},{\"id\":\"1006\",\"type\":\"TapTool\"}]},\"id\":\"1026\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1014\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1044\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1022\",\"type\":\"BasicTicker\"},{\"attributes\":{\"ticker\":{\"id\":\"1017\",\"type\":\"BasicTicker\"}},\"id\":\"1020\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":{\"id\":\"1046\",\"type\":\"OpenURL\"}},\"id\":\"1006\",\"type\":\"TapTool\"},{\"attributes\":{},\"id\":\"1017\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fill_color\":{\"field\":\"label\",\"transform\":{\"id\":\"1031\",\"type\":\"CategoricalColorMapper\"}},\"line_color\":{\"field\":\"label\",\"transform\":{\"id\":\"1031\",\"type\":\"CategoricalColorMapper\"}},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1033\",\"type\":\"Circle\"},{\"attributes\":{\"formatter\":{\"id\":\"1041\",\"type\":\"BasicTickFormatter\"},\"ticker\":{\"id\":\"1017\",\"type\":\"BasicTicker\"}},\"id\":\"1016\",\"type\":\"LinearAxis\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1043\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"formatter\":{\"id\":\"1039\",\"type\":\"BasicTickFormatter\"},\"ticker\":{\"id\":\"1022\",\"type\":\"BasicTicker\"}},\"id\":\"1021\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1041\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"file\",\"@desc\"],[\"speaker\",\"@label\"]]},\"id\":\"1003\",\"type\":\"HoverTool\"},{\"attributes\":{\"callback\":null,\"data\":{\"desc\":[\"8193/116804/8193_116804_000036_000003.wav\",\"8193/116805/8193_116805_000019_000000.wav\",\"8193/116804/8193_116804_000071_000003.wav\",\"8193/116805/8193_116805_000013_000000.wav\",\"8193/116805/8193_116805_000009_000001.wav\",\"8193/116805/8193_116805_000058_000000.wav\",\"8193/116805/8193_116805_000005_000000.wav\",\"8193/116804/8193_116804_000047_000000.wav\",\"8193/116805/8193_116805_000015_000003.wav\",\"8193/116804/8193_116804_000035_000000.wav\",\"8193/116805/8193_116805_000036_000001.wav\",\"8193/116804/8193_116804_000070_000001.wav\",\"8193/116805/8193_116805_000012_000000.wav\",\"8193/116805/8193_116805_000014_000000.wav\",\"8193/116804/8193_116804_000055_000003.wav\",\"8193/116805/8193_116805_000039_000003.wav\",\"8193/116805/8193_116805_000016_000000.wav\",\"8193/116804/8193_116804_000017_000003.wav\",\"8193/116804/8193_116804_000070_000001.wav\",\"8193/116805/8193_116805_000065_000001.wav\",\"829/123192/829_123192_000032_000000.wav\",\"829/123192/829_123192_000059_000000.wav\",\"829/123192/829_123192_000059_000000.wav\",\"829/123191/829_123191_000006_000000.wav\",\"829/123191/829_123191_000053_000001.wav\",\"829/123192/829_123192_000059_000000.wav\",\"829/123192/829_123192_000076_000000.wav\",\"829/123191/829_123191_000077_000003.wav\",\"829/123192/829_123192_000069_000000.wav\",\"829/123192/829_123192_000025_000000.wav\",\"829/123192/829_123192_000011_000000.wav\",\"829/123191/829_123191_000023_000000.wav\",\"829/123192/829_123192_000027_000000.wav\",\"829/123192/829_123192_000011_000000.wav\",\"829/123191/829_123191_000020_000000.wav\",\"829/123191/829_123191_000036_000000.wav\",\"829/123192/829_123192_000025_000002.wav\",\"829/123191/829_123191_000032_000001.wav\",\"829/123192/829_123192_000011_000000.wav\",\"829/123191/829_123191_000048_000000.wav\",\"2577/157236/2577_157236_000055_000001.wav\",\"2577/157236/2577_157236_000179_000001.wav\",\"2577/157236/2577_157236_000067_000000.wav\",\"2577/157236/2577_157236_000031_000001.wav\",\"2577/157236/2577_157236_000176_000001.wav\",\"2577/157236/2577_157236_000164_000000.wav\",\"2577/157236/2577_157236_000179_000001.wav\",\"2577/157236/2577_157236_000023_000001.wav\",\"2577/157236/2577_157236_000158_000000.wav\",\"2577/157236/2577_157236_000179_000003.wav\",\"2577/157236/2577_157236_000180_000000.wav\",\"2577/157236/2577_157236_000164_000001.wav\",\"2577/157236/2577_157236_000179_000001.wav\",\"2577/157236/2577_157236_000126_000004.wav\",\"2577/157236/2577_157236_000118_000000.wav\",\"2577/157236/2577_157236_000045_000000.wav\",\"2577/157236/2577_157236_000017_000001.wav\",\"2577/157236/2577_157236_000102_000005.wav\",\"2577/157236/2577_157236_000044_000000.wav\",\"2577/157236/2577_157236_000105_000001.wav\",\"511/131228/511_131228_000094_000001.wav\",\"511/131228/511_131228_000078_000001.wav\",\"511/131226/511_131226_000051_000000.wav\",\"511/131228/511_131228_000084_000000.wav\",\"511/131228/511_131228_000078_000001.wav\",\"511/131226/511_131226_000041_000001.wav\",\"511/131226/511_131226_000060_000000.wav\",\"511/131228/511_131228_000040_000001.wav\",\"511/131226/511_131226_000074_000000.wav\",\"511/131226/511_131226_000032_000000.wav\",\"511/131226/511_131226_000042_000000.wav\",\"511/131226/511_131226_000035_000000.wav\",\"511/131228/511_131228_000078_000001.wav\",\"511/131228/511_131228_000067_000000.wav\",\"511/131228/511_131228_000029_000000.wav\",\"511/131226/511_131226_000019_000000.wav\",\"511/131228/511_131228_000087_000002.wav\",\"511/131226/511_131226_000040_000007.wav\",\"511/131226/511_131226_000020_000000.wav\",\"511/131228/511_131228_000026_000000.wav\",\"5583/38026/5583_38026_000050_000000.wav\",\"5583/41919/5583_41919_000007_000002.wav\",\"5583/38026/5583_38026_000008_000000.wav\",\"5583/41919/5583_41919_000012_000001.wav\",\"5583/41259/5583_41259_000007_000002.wav\",\"5583/41919/5583_41919_000010_000002.wav\",\"5583/38026/5583_38026_000023_000001.wav\",\"5583/38026/5583_38026_000064_000000.wav\",\"5583/38026/5583_38026_000050_000000.wav\",\"5583/38026/5583_38026_000019_000000.wav\",\"5583/41259/5583_41259_000022_000000.wav\",\"5583/41919/5583_41919_000014_000003.wav\",\"5583/38026/5583_38026_000023_000000.wav\",\"5583/38026/5583_38026_000054_000002.wav\",\"5583/41259/5583_41259_000017_000001.wav\",\"5583/38026/5583_38026_000021_000002.wav\",\"5583/38026/5583_38026_000037_000000.wav\",\"5583/41259/5583_41259_000007_000005.wav\",\"5583/38026/5583_38026_000015_000000.wav\",\"5583/41259/5583_41259_000001_000003.wav\",\"1827/143625/1827_143625_000069_000000.wav\",\"1827/143625/1827_143625_000031_000005.wav\",\"1827/143625/1827_143625_000034_000009.wav\",\"1827/143625/1827_143625_000004_000000.wav\",\"1827/143625/1827_143625_000006_000000.wav\",\"1827/143625/1827_143625_000054_000000.wav\",\"1827/143625/1827_143625_000021_000001.wav\",\"1827/143625/1827_143625_000010_000000.wav\",\"1827/143625/1827_143625_000006_000000.wav\",\"1827/143625/1827_143625_000002_000004.wav\",\"1827/143625/1827_143625_000026_000005.wav\",\"1827/143625/1827_143625_000006_000000.wav\",\"1827/143625/1827_143625_000029_000003.wav\",\"1827/143625/1827_143625_000029_000003.wav\",\"1827/143625/1827_143625_000025_000000.wav\",\"1827/143625/1827_143625_000026_000004.wav\",\"1827/143625/1827_143625_000054_000000.wav\",\"1827/143625/1827_143625_000054_000000.wav\",\"1827/143625/1827_143625_000071_000000.wav\",\"1827/143625/1827_143625_000002_000010.wav\",\"4222/12898/4222_12898_000015_000000.wav\",\"4222/12898/4222_12898_000018_000002.wav\",\"4222/12898/4222_12898_000020_000000.wav\",\"4222/187005/4222_187005_000030_000002.wav\",\"4222/12898/4222_12898_000007_000004.wav\",\"4222/12898/4222_12898_000045_000007.wav\",\"4222/187005/4222_187005_000005_000000.wav\",\"4222/187005/4222_187005_000031_000000.wav\",\"4222/12898/4222_12898_000014_000000.wav\",\"4222/187006/4222_187006_000026_000000.wav\",\"4222/187005/4222_187005_000035_000001.wav\",\"4222/12898/4222_12898_000040_000000.wav\",\"4222/12898/4222_12898_000007_000005.wav\",\"4222/187005/4222_187005_000031_000000.wav\",\"4222/187006/4222_187006_000007_000001.wav\",\"4222/187005/4222_187005_000001_000000.wav\",\"4222/12898/4222_12898_000044_000000.wav\",\"4222/187005/4222_187005_000033_000001.wav\",\"4222/12898/4222_12898_000040_000001.wav\",\"4222/187005/4222_187005_000014_000000.wav\",\"1046/133224/1046_133224_000021_000008.wav\",\"1046/133225/1046_133225_000041_000002.wav\",\"1046/133225/1046_133225_000036_000005.wav\",\"1046/133224/1046_133224_000015_000001.wav\",\"1046/133225/1046_133225_000044_000000.wav\",\"1046/133225/1046_133225_000036_000003.wav\",\"1046/133225/1046_133225_000010_000001.wav\",\"1046/133224/1046_133224_000021_000001.wav\",\"1046/133224/1046_133224_000015_000000.wav\",\"1046/133225/1046_133225_000027_000000.wav\",\"1046/133225/1046_133225_000021_000000.wav\",\"1046/133224/1046_133224_000021_000007.wav\",\"1046/133225/1046_133225_000013_000001.wav\",\"1046/133224/1046_133224_000015_000003.wav\",\"1046/133224/1046_133224_000013_000006.wav\",\"1046/133225/1046_133225_000009_000000.wav\",\"1046/133225/1046_133225_000006_000000.wav\",\"1046/133225/1046_133225_000018_000001.wav\",\"1046/133225/1046_133225_000013_000001.wav\",\"1046/133224/1046_133224_000021_000001.wav\",\"1903/132499/1903_132499_000068_000000.wav\",\"1903/132499/1903_132499_000025_000000.wav\",\"1903/132499/1903_132499_000036_000003.wav\",\"1903/132499/1903_132499_000069_000002.wav\",\"1903/132499/1903_132499_000068_000002.wav\",\"1903/132499/1903_132499_000090_000004.wav\",\"1903/132499/1903_132499_000036_000000.wav\",\"1903/132499/1903_132499_000027_000002.wav\",\"1903/132499/1903_132499_000088_000018.wav\",\"1903/132499/1903_132499_000022_000001.wav\",\"1903/132499/1903_132499_000076_000000.wav\",\"1903/132499/1903_132499_000016_000003.wav\",\"1903/132499/1903_132499_000034_000003.wav\",\"1903/132499/1903_132499_000069_000000.wav\",\"1903/132499/1903_132499_000036_000003.wav\",\"1903/132499/1903_132499_000057_000009.wav\",\"1903/132499/1903_132499_000024_000003.wav\",\"1903/132499/1903_132499_000075_000003.wav\",\"1903/132499/1903_132499_000088_000007.wav\",\"1903/132499/1903_132499_000043_000001.wav\",\"6727/10344/6727_10344_000004_000000.wav\",\"6727/10344/6727_10344_000046_000001.wav\",\"6727/10344/6727_10344_000025_000000.wav\",\"6727/10344/6727_10344_000055_000002.wav\",\"6727/10344/6727_10344_000039_000004.wav\",\"6727/10344/6727_10344_000004_000000.wav\",\"6727/10344/6727_10344_000035_000002.wav\",\"6727/10344/6727_10344_000025_000006.wav\",\"6727/10344/6727_10344_000037_000009.wav\",\"6727/10344/6727_10344_000011_000000.wav\",\"6727/10344/6727_10344_000003_000000.wav\",\"6727/10344/6727_10344_000056_000000.wav\",\"6727/10344/6727_10344_000035_000002.wav\",\"6727/10344/6727_10344_000035_000001.wav\",\"6727/10344/6727_10344_000037_000008.wav\",\"6727/10344/6727_10344_000046_000001.wav\",\"6727/10344/6727_10344_000026_000000.wav\",\"6727/10344/6727_10344_000025_000005.wav\",\"6727/10344/6727_10344_000056_000003.wav\",\"6727/10344/6727_10344_000003_000000.wav\"],\"label\":[\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"1\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"2\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"3\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"4\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"5\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"6\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"7\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"8\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\",\"9\"],\"x\":[-3.1606812477111816,-2.77486515045166,-2.711012363433838,-3.2670810222625732,-3.1857569217681885,-2.6762382984161377,-2.798220634460449,-2.858726978302002,-2.9737770557403564,-2.956408739089966,-3.2381250858306885,-2.7951786518096924,-3.1397297382354736,-3.0064949989318848,-2.912095785140991,-3.1187150478363037,-3.173401117324829,-2.726390838623047,-2.8833956718444824,-2.947739839553833,-4.567573547363281,-4.578644752502441,-4.489212989807129,-4.270125865936279,-4.242483139038086,-4.417922496795654,-4.561956882476807,-3.563723564147949,-4.580752849578857,-4.431382179260254,-4.529460430145264,-4.122570991516113,-4.557018280029297,-4.619349002838135,-3.9843428134918213,-4.022738933563232,-4.3805060386657715,-3.8634088039398193,-4.519543647766113,-4.133539199829102,-10.116006851196289,-10.468204498291016,-10.254526138305664,-9.573077201843262,-9.981188774108887,-10.456389427185059,-10.501800537109375,-9.995732307434082,-10.34338665008545,-9.893121719360352,-10.395406723022461,-10.239717483520508,-10.539709091186523,-10.006428718566895,-9.72574520111084,-10.0088529586792,-10.255437850952148,-9.602444648742676,-7.1522746086120605,-9.79308795928955,-3.1828737258911133,-2.590296983718872,-2.440516948699951,-3.13976788520813,-2.631514549255371,-3.0425379276275635,-3.19071364402771,-2.4660489559173584,-2.8677256107330322,-2.691175937652588,-2.5749831199645996,-2.580756902694702,-2.5031492710113525,-3.0418972969055176,-2.584686756134033,-2.504948377609253,-2.7618863582611084,-2.7913360595703125,-3.0896430015563965,-2.5815749168395996,-6.891053676605225,-7.192995071411133,-6.7999091148376465,-6.9263997077941895,-7.041645050048828,-6.889425754547119,-7.002328395843506,-7.757612705230713,-6.999520778656006,-7.205618858337402,-7.174541473388672,-6.9610066413879395,-7.220072269439697,-7.408241271972656,-7.139148712158203,-7.064228534698486,-7.006400108337402,-6.549012660980225,-7.300623416900635,-7.20405387878418,-10.411309242248535,-10.857507705688477,-10.736696243286133,-10.88607120513916,-10.718442916870117,-10.645585060119629,-10.463425636291504,-10.558672904968262,-10.757495880126953,-10.860898971557617,-10.468467712402344,-10.784775733947754,-10.311744689941406,-10.550034523010254,-10.568222045898438,-10.75507640838623,-10.651739120483398,-10.556307792663574,-2.4752986431121826,-10.332552909851074,4.079848289489746,4.148099899291992,3.9534146785736084,3.423797369003296,3.4712212085723877,4.227757930755615,3.6290574073791504,3.791252613067627,4.359233379364014,4.4114155769348145,3.4708900451660156,4.244836807250977,3.6779139041900635,3.5986037254333496,3.8014416694641113,3.966369152069092,4.181628227233887,3.544233798980713,4.110950946807861,3.6406750679016113,6.199300289154053,6.082859992980957,6.082491874694824,6.0002546310424805,6.251781940460205,6.489964962005615,6.091195106506348,6.56417989730835,5.920825958251953,-3.5338377952575684,5.9702935218811035,6.291346549987793,6.024093151092529,6.016243934631348,6.132412910461426,6.1469197273254395,6.090811729431152,6.089906692504883,5.971016883850098,6.564464569091797,-3.8190841674804688,-4.3313164710998535,-4.202746391296387,-3.847559690475464,-4.692848205566406,-4.631866931915283,-4.271998405456543,-4.553844451904297,-4.715179443359375,-4.688408851623535,-4.05075216293335,-3.789729118347168,-4.062368869781494,-4.068924903869629,-4.206252574920654,-3.922722339630127,-4.003933429718018,-3.9797093868255615,-4.593817234039307,-3.7913308143615723,-2.7009692192077637,-3.2700228691101074,-3.022752523422241,-2.9041662216186523,-3.153395652770996,-2.8796653747558594,-2.957716703414917,-3.0767505168914795,-3.1752121448516846,-3.0709822177886963,-2.7455992698669434,-3.1914548873901367,-2.894855260848999,-3.2783260345458984,-2.998671054840088,-3.2107696533203125,-2.730574131011963,-2.7013425827026367,-2.952733039855957,-2.774390697479248],\"y\":[6.166264057159424,6.380192756652832,6.683015823364258,6.252046585083008,6.0565185546875,6.164169788360596,6.067956924438477,6.222115993499756,6.460431098937988,6.349257469177246,6.389455795288086,6.617327690124512,6.003944396972656,6.220587730407715,6.522432327270508,6.430699825286865,6.511539936065674,6.61389684677124,6.66624641418457,6.270698070526123,9.375914573669434,9.911813735961914,9.927233695983887,8.124340057373047,8.134218215942383,10.012815475463867,9.81711483001709,6.935359001159668,9.927690505981445,9.367259979248047,9.5027437210083,8.045830726623535,9.794713973999023,9.574983596801758,8.256868362426758,8.26749038696289,9.32170581817627,7.726580619812012,9.437990188598633,8.230162620544434,11.174026489257812,10.898594856262207,10.980513572692871,11.359804153442383,10.978575706481934,11.159407615661621,10.959506034851074,11.395026206970215,11.250273704528809,11.374359130859375,10.816308975219727,11.365285873413086,10.99096393585205,11.222780227661133,11.515741348266602,10.894570350646973,11.09619140625,11.345845222473145,12.66846752166748,11.416616439819336,0.6150201559066772,0.5727664828300476,1.197059988975525,0.6711833477020264,0.8181120157241821,0.7986350059509277,0.5980774760246277,0.5483988523483276,0.8343006372451782,1.3131901025772095,1.2926685810089111,0.8192294836044312,0.60872483253479,0.6371785402297974,1.2419419288635254,0.789923906326294,0.9895642995834351,1.070288896560669,0.6442015767097473,0.9097402095794678,12.529427528381348,12.068403244018555,12.773029327392578,12.189614295959473,11.962052345275879,12.334823608398438,12.443355560302734,12.330665588378906,12.443488121032715,12.466773986816406,11.987349510192871,12.070545196533203,12.491742134094238,12.424216270446777,11.917981147766113,12.826085090637207,12.716790199279785,12.624031066894531,12.453993797302246,12.088994026184082,-5.1096415519714355,-5.317790508270264,-5.642304420471191,-5.1158976554870605,-5.0864081382751465,-5.466678142547607,-5.034519672393799,-5.114104747772217,-4.975529193878174,-5.178981304168701,-5.059814453125,-4.997513294219971,-5.348056793212891,-5.387124538421631,-5.2672247886657715,-5.725089073181152,-5.443286895751953,-5.466362953186035,-4.693160533905029,-5.192424774169922,5.956725120544434,5.905540466308594,5.80776309967041,5.851162910461426,5.585705280303955,5.638182640075684,5.862408638000488,5.927237033843994,5.950323581695557,5.777632713317871,5.926275730133057,5.671252250671387,5.654463768005371,5.951079845428467,5.758546352386475,5.5899858474731445,5.831849575042725,5.761802673339844,5.802149772644043,5.752105712890625,-18.17595100402832,-17.9041690826416,-17.924606323242188,-17.878761291503906,-18.0015869140625,-18.020288467407227,-18.54057502746582,-18.124919891357422,-17.983484268188477,-4.850675582885742,-18.01740264892578,-18.182519912719727,-18.39446258544922,-18.001667022705078,-18.04789924621582,-18.63656234741211,-18.55376625061035,-18.309518814086914,-18.34510040283203,-18.189838409423828,-16.757017135620117,-17.429935455322266,-17.380504608154297,-16.918798446655273,-17.39818000793457,-17.20540428161621,-17.333026885986328,-17.362947463989258,-17.398563385009766,-17.306306838989258,-16.770545959472656,-17.02341651916504,-17.152599334716797,-16.911453247070312,-17.31295394897461,-16.897735595703125,-17.118011474609375,-17.056303024291992,-17.276948928833008,-17.049142837524414,-4.215534210205078,-5.0766801834106445,-4.91635274887085,-4.7257232666015625,-4.711700439453125,-4.1083807945251465,-4.3584303855896,-5.018618583679199,-4.9661865234375,-4.581928730010986,-4.2590484619140625,-5.0669074058532715,-4.388965129852295,-5.096145153045654,-4.534728050231934,-5.012913227081299,-4.557061672210693,-4.7465009689331055,-4.890029430389404,-4.341127872467041]},\"selected\":{\"id\":\"1044\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"1045\",\"type\":\"UnionRenderers\"}},\"id\":\"1002\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"1002\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1033\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1034\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"1036\",\"type\":\"CDSView\"}},\"id\":\"1035\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1034\",\"type\":\"Circle\"},{\"attributes\":{\"overlay\":{\"id\":\"1043\",\"type\":\"BoxAnnotation\"}},\"id\":\"1004\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"factors\":[\"1\",\"6\",\"3\",\"4\",\"0\",\"7\",\"9\",\"2\",\"8\",\"5\"],\"palette\":[\"#1f77b4\",\"#ff7f0e\",\"#2ca02c\",\"#d62728\",\"#9467bd\",\"#8c564b\",\"#e377c2\",\"#7f7f7f\",\"#bcbd22\",\"#17becf\"]},\"id\":\"1031\",\"type\":\"CategoricalColorMapper\"},{\"attributes\":{\"dimension\":1,\"ticker\":{\"id\":\"1022\",\"type\":\"BasicTicker\"}},\"id\":\"1025\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1005\",\"type\":\"ResetTool\"}],\"root_ids\":[\"1007\"]},\"title\":\"Bokeh Application\",\"version\":\"1.3.4\"}};\n",
|
|
" var render_items = [{\"docid\":\"95a95da2-6471-485d-aafc-7fcb3a90c6fa\",\"roots\":{\"1007\":\"e515e894-9f0f-4373-b879-972fbfc359fa\"}}];\n",
|
|
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
|
|
"\n",
|
|
" }\n",
|
|
" if (root.Bokeh !== undefined) {\n",
|
|
" embed_document(root);\n",
|
|
" } else {\n",
|
|
" var attempts = 0;\n",
|
|
" var timer = setInterval(function(root) {\n",
|
|
" if (root.Bokeh !== undefined) {\n",
|
|
" embed_document(root);\n",
|
|
" clearInterval(timer);\n",
|
|
" }\n",
|
|
" attempts++;\n",
|
|
" if (attempts > 100) {\n",
|
|
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
|
|
" clearInterval(timer);\n",
|
|
" }\n",
|
|
" }, 10, root)\n",
|
|
" }\n",
|
|
"})(window);"
|
|
],
|
|
"application/vnd.bokehjs_exec.v0+json": ""
|
|
},
|
|
"metadata": {
|
|
"application/vnd.bokehjs_exec.v0+json": {
|
|
"id": "1007"
|
|
}
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"source_wav_stems = ColumnDataSource(\n",
|
|
" data=dict(\n",
|
|
" x = projection.T[0].tolist(),\n",
|
|
" y = projection.T[1].tolist(),\n",
|
|
" desc=locations,\n",
|
|
" label=labels\n",
|
|
" )\n",
|
|
" )\n",
|
|
"\n",
|
|
"hover = HoverTool(\n",
|
|
" tooltips=[\n",
|
|
" (\"file\", \"@desc\"),\n",
|
|
" (\"speaker\", \"@label\"),\n",
|
|
" ]\n",
|
|
" )\n",
|
|
"\n",
|
|
"# optionally consider adding these to the tooltips if you want additional detail\n",
|
|
"# for the coordinates: (\"(x,y)\", \"($x, $y)\"),\n",
|
|
"# for the index of the embedding / wav file: (\"index\", \"$index\"),\n",
|
|
"\n",
|
|
"factors = list(set(labels))\n",
|
|
"pal_size = max(len(factors), 3)\n",
|
|
"pal = Category10[pal_size]\n",
|
|
"\n",
|
|
"p = figure(plot_width=600, plot_height=400, tools=[hover,BoxZoomTool(), ResetTool(), TapTool()])\n",
|
|
"\n",
|
|
"\n",
|
|
"p.circle('x', 'y', source=source_wav_stems, color=factor_cmap('label', palette=pal, factors=factors),)\n",
|
|
"\n",
|
|
"url = \"http://localhost:8000/@desc\"\n",
|
|
"taptool = p.select(type=TapTool)\n",
|
|
"taptool.callback = OpenURL(url=url)\n",
|
|
"\n",
|
|
"show(p)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Local server to serve wav files from corpus\n",
|
|
"\n",
|
|
"This is required so that when you click on a data point the hyperlink associated with it will be served the file locally.\n",
|
|
"\n",
|
|
"There are other ways to serve this if you prefer and you can also run the commands manually on the command line\n",
|
|
"\n",
|
|
"The server will continue to run until stopped. To stop it simply interupt the kernel (ie square button or under Kernel menu)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/home/neil/main/Projects/LibriTTS/LibriTTS/train-clean-360\n",
|
|
"Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...\n",
|
|
"^C\n",
|
|
"\n",
|
|
"Keyboard interrupt received, exiting.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"%cd $AUDIO_PATH\n",
|
|
"%pwd\n",
|
|
"!python -m http.server"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"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.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|