Commit a9a8a713 authored by Anthony Larcher's avatar Anthony Larcher
Browse files

refactoring

parent b79c7e66
......@@ -142,10 +142,6 @@ if libsvm_loaded:
from sidekit.svm_scoring import *
from sidekit.svm_training import *
<<<<<<< HEAD
=======
>>>>>>> 53905f205277f2583f550029fcba48a3e2af94d5
__author__ = "Anthony Larcher and Sylvain Meignier"
__copyright__ = "Copyright 2014-2016 Anthony Larcher and Sylvain Meignier"
__license__ = "LGPL"
......
......@@ -35,7 +35,7 @@ import numpy
import matplotlib
import os
if not "DISPLAY" in os.environ:
if "DISPLAY" not in os.environ:
matplotlib.use('PDF')
import matplotlib.pyplot as mpl
import scipy
......@@ -382,8 +382,6 @@ def rocch2eer(pmiss, pfa):
# candidate for EER, eer is highest candidate
eerseg = 1 / (numpy.sum(seg))
eer = max([eer, eerseg])
return eer
......@@ -807,9 +805,8 @@ class DetPlot:
in the legend.
"""
mindcf, pmiss, pfa, prbep, eer = fast_minDCF(self.__tar__[idx],
self.__non__[idx], __logit__(target_prior), True)
if (pfa < self.__plotwindow__.__pfa_limits__[0]) \
| (pfa > self.__plotwindow__.__pfa_limits__[1]):
self.__non__[idx], __logit__(target_prior), True)
if (pfa < self.__plotwindow__.__pfa_limits__[0]) | (pfa > self.__plotwindow__.__pfa_limits__[1]):
logging.warning('pfa of %f is not between %f and %f mindcf point will not be plotted.', format(pfa),
self.__plotwindow__.__pfa_limits__[0],
self.__plotwindow__.__pfa_limits__[1])
......
......@@ -46,20 +46,18 @@ class PlotWindow:
def __init__(self, input_type=''):
"""Initialize PlotWindow object to one of the pre-defined ploting type.
- 'new'
- 'old'
- 'big'
- 'sre10'
- 'new'
- 'old'
- 'big'
- 'sre10'
:param inputType: the type of DET plot to display. Default is 'old'
:param input_type: the type of DET plot to display. Default is 'old'
"""
if input_type == '':
self.__pfa_limits__ = numpy.array([5e-4, 5e-1])
self.__pmiss_limits__ = numpy.array([5e-4, 5e-1])
self.__xticks__ = numpy.array([0.001, 0.002, 0.005, 0.01,
0.02, 0.05, 0.1, 0.2, 0.3, 0.4])
self.__xticks__ = numpy.array([0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.4])
self.__xticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ', ' 5 ', '10 ', '20 ', '30 ', '40 '])
self.__yticks__ = numpy.array([0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.4])
self.__yticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ', ' 5 ', '10 ', '20 ', '30 ', '40 '])
......@@ -94,67 +92,56 @@ class PlotWindow:
def axis_new(self):
"""Set axis value to new ones
- pfa ranges from 0.000005 to 0.005
- pmiss ranges from 0.01 to 0.99
"""
- pfa ranges from 0.000005 to 0.005
- pmiss ranges from 0.01 to 0.99
"""
self.__pfa_limits__ = numpy.array([5e-6, 5e-3])
self.__pmiss_limits__ = numpy.array([1e-2, 0.99])
self.__xticks__ = numpy.array([1e-5, 2e-5, 5e-5, 1e-4,
2e-4, 5e-4, 1e-3, 2e-3])
self.__xticklabels__ = numpy.array(['1e-3', '2e-3', '5e-3', '0.01',
'0.02', '0.05', '0.1 ', '0.2 '])
self.__yticks__ = numpy.array([0.02, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5,
0.6, 0.7, 0.8, 0.9, 0.95, 0.98])
self.__xticks__ = numpy.array([1e-5, 2e-5, 5e-5, 1e-4, 2e-4, 5e-4, 1e-3, 2e-3])
self.__xticklabels__ = numpy.array(['1e-3', '2e-3', '5e-3', '0.01', '0.02', '0.05', '0.1 ', '0.2 '])
self.__yticks__ = numpy.array([0.02, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.98])
self.__yticklabels__ = numpy.array([' 2 ', ' 5 ', '10 ', '20 ', '30 ',
'40 ', '50 ', '60 ', '70 ', '80 ', '90 ', '95 ', '98 '])
'40 ', '50 ', '60 ', '70 ', '80 ', '90 ', '95 ', '98 '])
def axis_old(self):
"""Set axis value to old ones (NIST-SRE08 style)
- pfa ranges from 0.0005 to 0.5
- pmiss ranges from 0.0005 to 0.5
"""
- pfa ranges from 0.0005 to 0.5
- pmiss ranges from 0.0005 to 0.5
"""
self.__pfa_limits__ = numpy.array([5e-4, 5e-1])
self.__pmiss_limits__ = numpy.array([5e-4, 5e-1])
self.__xticks__ = numpy.array([0.001, 0.002, 0.005, 0.01, 0.02, 0.05,
0.1, 0.2, 0.3, 0.4])
self.__xticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ',
' 5 ', '10 ', '20 ', '30 ', '40 '])
self.__yticks__ = numpy.array([0.001, 0.002, 0.005, 0.01, 0.02, 0.05,
0.1, 0.2, 0.3, 0.4])
self.__yticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ',
' 5 ', '10 ', '20 ', '30 ', '40 '])
self.__xticks__ = numpy.array([0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.4])
self.__xticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ', ' 5 ', '10 ', '20 ', '30 ', '40 '])
self.__yticks__ = numpy.array([0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.3, 0.4])
self.__yticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ', ' 5 ', '10 ', '20 ', '30 ', '40 '])
def axis_big(self):
"""Set axis value to big ones
- pfa ranges from 0.000005 to 0.99
- pmiss ranges from 0.000005 to0.99
"""
- pfa ranges from 0.000005 to 0.99
- pmiss ranges from 0.000005 to0.99
"""
self.__pfa_limits__ = numpy.array([5e-6, 0.99])
self.__pmiss_limits__ = numpy.array([5e-6, 0.99])
self.__yticks__ = numpy.array([5e-6, 5e-5, 5e-4, 0.5e-2, 2.5e-2, 10e-2,
25e-2, 50e-2, 72e-2, 88e-2, 96e-2, 99e-2])
25e-2, 50e-2, 72e-2, 88e-2, 96e-2, 99e-2])
self.__yticklabels__ = numpy.array(['5e-4', '5e-3', '0.05', '0.5 ',
'2.5 ', ' 10 ', ' 25 ', ' 50 ', ' 72 ', ' 88 ', ' 96 ', ' 99 '])
self.__xticks__ = numpy.array([5e-5, 5e-4, 0.5e-2, 2.5e-2, 10e-2, 25e-2,
50e-2, 72e-2, 88e-2, 96e-2, 99e-2])
'2.5 ', ' 10 ', ' 25 ', ' 50 ', ' 72 ', ' 88 ', ' 96 ', ' 99 '])
self.__xticks__ = numpy.array([5e-5, 5e-4, 0.5e-2, 2.5e-2, 10e-2, 25e-2, 50e-2, 72e-2, 88e-2, 96e-2, 99e-2])
self.__xticklabels__ = numpy.array(['5e-3', '0.05', '0.5 ', '2.5 ',
' 10 ', ' 25 ', ' 50 ', ' 72 ', ' 88 ', ' 96 ', ' 99 '])
' 10 ', ' 25 ', ' 50 ', ' 72 ', ' 88 ', ' 96 ', ' 99 '])
def axis_sre10(self):
"""Set axis value to NIST-SRE10 style
- pfa ranges from 0.000003 to 0.5
- pmiss ranges from 0.0003 to 0.9
"""
- pfa ranges from 0.000003 to 0.5
- pmiss ranges from 0.0003 to 0.9
"""
self.__pfa_limits__ = numpy.array([3e-6, 5e-1])
self.__pmiss_limits__ = numpy.array([3e-4, 9e-1])
self.__xticks__ = numpy.array([1e-5, 1e-4, 1e-3, 2e-3, 5e-3, 1e-2, 2e-2,
5e-2, 1e-1, 2e-1, 4e-1])
self.__xticks__ = numpy.array([1e-5, 1e-4, 1e-3, 2e-3, 5e-3, 1e-2, 2e-2, 5e-2, 1e-1, 2e-1, 4e-1])
self.__xticklabels__ = numpy.array(['0.001', ' 0.01', ' 0.1', ' 0.2',
' 0.5', ' 1', ' 2', ' 5', ' 10', ' 20', ' 40'])
self.__yticks__ = numpy.array([1e-3, 2e-3, 5e-3, 1e-2, 2e-2, 5e-2, 1e-1,
2e-1, 4e-1, 8e-1])
self.__yticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ',
' 5 ', ' 10', ' 20', ' 40', ' 80'])
' 0.5', ' 1', ' 2', ' 5', ' 10', ' 20', ' 40'])
self.__yticks__ = numpy.array([1e-3, 2e-3, 5e-3, 1e-2, 2e-2, 5e-2, 1e-1, 2e-1, 4e-1, 8e-1])
self.__yticklabels__ = numpy.array(['0.1', '0.2', '0.5', ' 1 ', ' 2 ', ' 5 ', ' 10', ' 20', ' 40', ' 80'])
......@@ -310,7 +310,7 @@ class Scores:
def read(input_file_name):
"""Read a Scores object from information in a hdf5 file.
:param input_file_name: name of the file to read from
:param input_file_name: name of the file to read from
"""
with h5py.File(input_file_name, "r") as f:
scores = Scores()
......@@ -431,38 +431,27 @@ class Scores:
scr_new.segset = numpy.union1d(scr1.segset, scr2.segset)
# expand scr1 matrices
scoremat_1 = numpy.zeros((scr_new.modelset.shape[0],
scr_new.segset.shape[0]))
scoremask_1 = numpy.zeros((scr_new.modelset.shape[0],
scr_new.segset.shape[0]), dtype='bool')
scoremat_1 = numpy.zeros((scr_new.modelset.shape[0], scr_new.segset.shape[0]))
scoremask_1 = numpy.zeros((scr_new.modelset.shape[0], scr_new.segset.shape[0]), dtype='bool')
model_index_a = numpy.argwhere(numpy.in1d(scr_new.modelset, scr1.modelset))
model_index_b = numpy.argwhere(numpy.in1d(scr1.modelset, scr_new.modelset))
seg_index_a = numpy.argwhere(numpy.in1d(scr_new.segset, scr1.segset))
seg_index_b = numpy.argwhere(numpy.in1d(scr1.segset, scr_new.segset))
scoremat_1[model_index_a[:, None], seg_index_a] \
= scr1.scoremat[model_index_b[:, None], seg_index_b]
scoremask_1[model_index_a[:, None], seg_index_a] \
= scr1.scoremask[model_index_b[:, None], seg_index_b]
scoremat_1[model_index_a[:, None], seg_index_a] = scr1.scoremat[model_index_b[:, None], seg_index_b]
scoremask_1[model_index_a[:, None], seg_index_a] = scr1.scoremask[model_index_b[:, None], seg_index_b]
# expand scr2 matrices
scoremat_2 = numpy.zeros((scr_new.modelset.shape[0],
scr_new.segset.shape[0]))
scoremask_2 = numpy.zeros((scr_new.modelset.shape[0],
scr_new.segset.shape[0]), dtype='bool')
model_index_a = numpy.argwhere(numpy.in1d(scr_new.modelset,
scr2.modelset))
model_index_b = numpy.argwhere(numpy.in1d(scr2.modelset,
scr_new.modelset))
scoremat_2 = numpy.zeros((scr_new.modelset.shape[0], scr_new.segset.shape[0]))
scoremask_2 = numpy.zeros((scr_new.modelset.shape[0], scr_new.segset.shape[0]), dtype='bool')
model_index_a = numpy.argwhere(numpy.in1d(scr_new.modelset, scr2.modelset))
model_index_b = numpy.argwhere(numpy.in1d(scr2.modelset, scr_new.modelset))
seg_index_a = numpy.argwhere(numpy.in1d(scr_new.segset, scr2.segset))
seg_index_b = numpy.argwhere(numpy.in1d(scr2.segset, scr_new.segset))
scoremat_2[model_index_a[:, None], seg_index_a] \
= scr2.scoremat[model_index_b[:, None], seg_index_b]
scoremask_2[model_index_a[:, None], seg_index_a] \
= scr2.scoremask[model_index_b[:, None], seg_index_b]
scoremat_2[model_index_a[:, None], seg_index_a] = scr2.scoremat[model_index_b[:, None], seg_index_b]
scoremask_2[model_index_a[:, None], seg_index_a] = scr2.scoremask[model_index_b[:, None], seg_index_b]
# check for clashes
assert numpy.sum(scoremask_1 & scoremask_2) == 0, \
"Conflict in the new scoremask"
assert numpy.sum(scoremask_1 & scoremask_2) == 0, "Conflict in the new scoremask"
# merge masks
self.scoremat = scoremat_1 + scoremat_2
......@@ -496,6 +485,3 @@ class Scores:
raise Exception('No such segment as: %s', segID)
else:
return self.scoremat[model_idx, seg_idx]
This diff is collapsed.
......@@ -55,7 +55,7 @@
</ul>
</li>
<li><a class="reference internal" href="#tutorials">Tutorials</a></li>
<li><a class="reference internal" href="#module-sidekit">API description</a></li>
<li><a class="reference internal" href="#api-description">API description</a></li>
<li><a class="reference internal" href="#contacts-and-info">Contacts and info</a></li>
<li><a class="reference internal" href="#additional-material">Additional material</a></li>
<li><a class="reference internal" href="#sponsors">Sponsors</a></li>
......@@ -238,19 +238,8 @@ via <strong>pip</strong> or <strong>conda</strong>.</p>
</ul>
</div>
</div>
<div class="section" id="module-sidekit">
<span id="api-description"></span><h1>API description<a class="headerlink" href="#module-sidekit" title="Permalink to this headline"></a></h1>
<p>Copyright 2014-2016 Anthony Larcher and Sylvain Meignier</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Authors:</th><td class="field-body">Anthony LACHER, Sylvain MEIGNIER &amp; Kong Aik LEE</td>
</tr>
<tr class="field-even field"><th class="field-name">Version:</th><td class="field-body">1.1.6 of 2016/10/31</td>
</tr>
</tbody>
</table>
<div class="section" id="api-description">
<h1>API description<a class="headerlink" href="#api-description" title="Permalink to this headline"></a></h1>
<div class="line-block">
<div class="line">This package is the core of the <strong>SIDEKIT</strong> toolkit.</div>
<div class="line">While developing <strong>SIDEKIT</strong>, we tried to keep in mind two</div>
......@@ -264,7 +253,7 @@ via <strong>pip</strong> or <strong>conda</strong>.</p>
<div class="line">To reach this target, we have created four Main Classes</div>
<div class="line">(<code class="xref py py-mod docutils literal"><span class="pre">FeaturesExtractor`</span></code>, <code class="xref py py-mod docutils literal"><span class="pre">FeaturesServer</span></code>, <code class="xref py py-mod docutils literal"><span class="pre">Mixture</span></code> and <code class="xref py py-mod docutils literal"><span class="pre">StatServer</span></code>) which can be used</div>
<div class="line">together with a number of tools available in companion</div>
<div class="line">modules (<a class="reference internal" href="sidekit_io.html#module-sidekit_io" title="sidekit_io"><code class="xref py py-mod docutils literal"><span class="pre">sidekit_io</span></code></a> and <a class="reference internal" href="sv_utils.html#module-sv_utils" title="sv_utils"><code class="xref py py-mod docutils literal"><span class="pre">sv_utils</span></code></a>).</div>
<div class="line">modules (<code class="xref py py-mod docutils literal"><span class="pre">sidekit_io</span></code> and <a class="reference internal" href="sv_utils.html#module-sv_utils" title="sv_utils"><code class="xref py py-mod docutils literal"><span class="pre">sv_utils</span></code></a>).</div>
<div class="line"><br /></div>
<div class="line">Front-end and back-end processing such as acoustic feature extraction</div>
<div class="line">and score analysis are handled in two packages: <a class="reference internal" href="frontend.html#module-frontend" title="frontend"><code class="xref py py-mod docutils literal"><span class="pre">frontend</span></code></a> and <code class="xref py py-mod docutils literal"><span class="pre">bosaris</span></code>.</div>
......
......@@ -26,10 +26,6 @@
<link rel="top" title="SIDEKIT 1.1.6 documentation" href="index.html" />
<script type="text/javascript">
DOCUMENTATION_OPTIONS.COLLAPSE_INDEX = true;
</script>
</head>
<body role="document">
......@@ -147,26 +143,11 @@
<tr class="pcap"><td></td><td>&nbsp;</td><td></td></tr>
<tr class="cap" id="cap-s"><td></td><td>
<strong>s</strong></td><td></td></tr>
<tr>
<td></td>
<td>
<a href="index.html#module-sidekit"><code class="xref">sidekit</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
<a href="sidekit_io.html#module-sidekit_io"><code class="xref">sidekit_io</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
<a href="sv_utils.html#module-sv_utils"><code class="xref">sv_utils</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
<a href="svm_scoring.html#module-svm_scoring"><code class="xref">svm_scoring</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
......
This diff is collapsed.
......@@ -20,7 +20,6 @@ import os
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../../frontend'))
#sys.path.insert(0, os.path.abspath('/Users/larcher/LIUM/src/python/env3/lib/python3.4/site-packages/'))
# -- General configuration ------------------------------------------------
......@@ -197,14 +196,14 @@ htmlhelp_basename = 'SIDEKITdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
......@@ -217,23 +216,23 @@ latex_documents = [
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
......@@ -246,7 +245,7 @@ man_pages = [
]
# If true, show URL addresses after external links.
#man_show_urls = False
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
......@@ -261,16 +260,16 @@ texinfo_documents = [
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# texinfo_no_detailmenu = False
# -- Options for Epub output ----------------------------------------------
......@@ -282,62 +281,62 @@ epub_publisher = u'Anthony LARCHER, Sylvain MEIGNIER & Kong Aik LEE'
epub_copyright = u'2014-16, Anthony LARCHER, Sylvain MEIGNIER & Kong Aik LEE'
# The basename for the epub file. It defaults to the project name.
#epub_basename = u'SIDEKIT'
# epub_basename = u'SIDEKIT'
# The HTML theme for the epub output. Since the default themes are not optimized
# for small screen space, using the same theme for HTML and epub output is
# usually not wise. This defaults to 'epub', a theme designed to save visual
# space.
#epub_theme = 'epub'
# epub_theme = 'epub'
# The language of the text. It defaults to the language option
# or en if the language is not set.
#epub_language = ''
# epub_language = ''
# The scheme of the identifier. Typical schemes are ISBN or URL.
#epub_scheme = ''
# epub_scheme = ''
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#epub_identifier = ''
# epub_identifier = ''
# A unique identification for the text.
#epub_uid = ''
# epub_uid = ''
# A tuple containing the cover image and cover page html template filenames.
#epub_cover = ()
# epub_cover = ()
# A sequence of (type, uri, title) tuples for the guide element of content.opf.
#epub_guide = ()
# epub_guide = ()
# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_pre_files = []
# epub_pre_files = []
# HTML files shat should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_post_files = []
# epub_post_files = []
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# The depth of the table of contents in toc.ncx.
#epub_tocdepth = 3
# epub_tocdepth = 3
# Allow duplicate toc entries.
#epub_tocdup = True
# epub_tocdup = True
# Choose between 'default' and 'includehidden'.
#epub_tocscope = 'default'
# epub_tocscope = 'default'
# Fix unsupported image types using the PIL.
#epub_fix_images = False
# epub_fix_images = False
# Scale large images.
#epub_max_image_width = 0
# epub_max_image_width = 0
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#epub_show_urls = 'inline'
# epub_show_urls = 'inline'
# If false, no index is generated.
#epub_use_index = True
# epub_use_index = True
.. _license:
License
=============
=======
| SIDEKIT is released under LGPL license which is an extension of the GPL license.
| See below the terms of the license.
......
......@@ -290,6 +290,6 @@ Plot DET curve and compute minDCF and EER
After running this script you should obtain the following curve
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: SVM-GMM_128g.png
.. image:: SVM-GMM_NAP_512g.png
......@@ -3,7 +3,7 @@ Run an `i`-vector system
This script runs an experiment on the male NIST Speaker Recognition
Evaluation 2010 extended core task.
For more details about the protocol, refer to the NIST_ website.
For more details about the protocol, refer to the `NIST<http://www.itl.nist.gov/iad/mig/tests/spk/>`_ website.
.. The complete Python script can be downloaded :download:`here <sre10_i-vector.zip>`
......
......@@ -394,6 +394,7 @@ class FeaturesExtractor(object):
:param input_audio_filename:
:param output_feature_filename:
:param keep_all:
:param skip_existing_file:
:return:
"""
param_vad = self.vad
......
......@@ -190,7 +190,7 @@ def trfbank(fs, nfft, lowfreq, maxfreq, nlinfilt, nlogfilt, midfreq=1000):
low_mel = hz2mel(lowfreq)
max_mel = hz2mel(maxfreq)
mels = numpy.zeros(nlogfilt + 2)
mels[nlinfilt:]
# mels[nlinfilt:]
melsc = (max_mel - low_mel) / (nfilt + 1)
mels[:nlogfilt + 2] = low_mel + numpy.arange(nlogfilt + 2) * melsc
# Back to the frequency domain
......@@ -232,17 +232,17 @@ def trfbank(fs, nfft, lowfreq, maxfreq, nlinfilt, nlogfilt, midfreq=1000):
cen = frequences[i + 1]
hi = frequences[i + 2]
lid = numpy.arange(numpy.floor(low * nfft / fs) + 1,
numpy.floor(cen * nfft / fs) + 1, dtype=numpy.int)
lid = numpy.arange(numpy.floor(low * nfft / fs) + 1, numpy.floor(cen * nfft / fs) + 1, dtype=numpy.int)
left_slope = heights[i] / (cen - low)
rid = numpy.arange(numpy.floor(cen * nfft / fs) + 1,
min(numpy.floor(hi * nfft / fs) + 1, nfft), dtype=numpy.int)
min(numpy.floor(hi * nfft / fs) + 1, nfft), dtype=numpy.int)
right_slope = heights[i] / (hi - cen)
fbank[i][lid] = left_slope * (n_frequences[lid] - low)
fbank[i][rid[:-1]] = right_slope * (hi - n_frequences[rid[:-1]])
return fbank, frequences
def mel_filter_bank(fs, nfft, lowfreq, maxfreq, widest_nlogfilt, widest_lowfreq, widest_maxfreq,):
"""Compute triangular filterbank for cepstral coefficient computation.
......@@ -250,22 +250,24 @@ def mel_filter_bank(fs, nfft, lowfreq, maxfreq, widest_nlogfilt, widest_lowfreq,
:param nfft: number of points for the Fourier Transform
:param lowfreq: lower limit of the frequency band filtered
:param maxfreq: higher limit of the frequency band filtered
:param widest_nlogfilt:
:param widest_lowfreq:
:param widest_nlogfilt: number of log filters
:param widest_lowfreq: lower frequency of the filter bank
:param widest_maxfreq: higher frequency of the filter bank
:param widest_maxfreq: higher frequency of the filter bank
:return: the filter bank and the central frequencies of each filter
"""
#------------------------
# ------------------------
# Compute the filter bank
#------------------------
# ------------------------
# Compute start/middle/end points of the triangular filters in spectral
# domain
widest_freqs = numpy.zeros(widest_nlogfilt + 2, dtype=PARAM_TYPE)
low_mel= hz2mel(widest_lowfreq)
low_mel = hz2mel(widest_lowfreq)
max_mel = hz2mel(widest_maxfreq)
mels = numpy.zeros(widest_nlogfilt+2)
melsc = (max_mel - low_mel)/ (widest_nlogfilt + 1)
melsc = (max_mel - low_mel) / (widest_nlogfilt + 1)
mels[:widest_nlogfilt + 2] = low_mel + numpy.arange(widest_nlogfilt + 2) * melsc
# Back to the frequency domain
widest_freqs = mel2hz(mels)
......@@ -285,11 +287,10 @@ def mel_filter_bank(fs, nfft, lowfreq, maxfreq, widest_nlogfilt, widest_lowfreq,
low = sub_band_freqs[i]
cen = sub_band_freqs[i+1]
hi = sub_band_freqs[i+2]
lid = numpy.arange(numpy.floor(low * nfft / fs) + 1,
numpy.floor(cen * nfft / fs) + 1, dtype=numpy.int)
lid = numpy.arange(numpy.floor(low * nfft / fs) + 1, numpy.floor(cen * nfft / fs) + 1, dtype=numpy.int)
left_slope = heights[i] / (cen - low)
rid = numpy.arange(numpy.floor(cen * nfft / fs) + 1,
min(numpy.floor(hi * nfft / fs) + 1,nfft), dtype=numpy.int)
rid = numpy.arange(numpy.floor(cen * nfft / fs) + 1, min(numpy.floor(hi * nfft / fs) + 1,
nfft), dtype=numpy.int)
right_slope = heights[i] / (hi - cen)
fbank[i][lid] = left_slope * (nfreqs[lid] - low)