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

new mfcc

parent 85aecb73
......@@ -202,7 +202,8 @@
<span class="n">rasta</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">keep_all_features</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">spec</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">mspec</span><span class="o">=</span><span class="bp">False</span>
<span class="n">mspec</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">mask</span><span class="o">=</span><span class="bp">None</span>
<span class="p">):</span>
<span class="sd">&quot;&quot;&quot; Process of extracting the feature frames (LFCC or MFCC) from an audio signal.</span>
<span class="sd"> Speech Activity Detection, MFCC (or LFCC) extraction and normalization.</span>
......@@ -245,7 +246,8 @@
<span class="bp">self</span><span class="o">.</span><span class="n">sdc_config</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">7</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">delta</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">double_delta</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">filter</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">delta_filter</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="o">.</span><span class="mi">25</span><span class="p">,</span> <span class="o">.</span><span class="mi">5</span><span class="p">,</span> <span class="o">.</span><span class="mi">25</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-.</span><span class="mi">25</span><span class="p">,</span> <span class="o">-.</span><span class="mi">5</span><span class="p">,</span> <span class="o">-.</span><span class="mi">25</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">mask</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">rasta</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">keep_all_features</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">spec</span> <span class="o">=</span> <span class="bp">False</span>
......@@ -319,7 +321,9 @@
<span class="k">if</span> <span class="n">double_delta</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">double_delta</span> <span class="o">=</span> <span class="n">double_delta</span>
<span class="k">if</span> <span class="n">delta_filter</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">filter</span> <span class="o">=</span> <span class="n">delta_filter</span>
<span class="bp">self</span><span class="o">.</span><span class="n">delta_filter</span> <span class="o">=</span> <span class="n">delta_filter</span>
<span class="k">if</span> <span class="n">mask</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">mask</span> <span class="o">=</span> <span class="n">mask</span>
<span class="k">if</span> <span class="n">rasta</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">rasta</span> <span class="o">=</span> <span class="n">rasta</span>
<span class="k">if</span> <span class="n">keep_all_features</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
......@@ -597,7 +601,7 @@
<span class="n">nwin</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">window_size</span><span class="p">,</span> <span class="n">nlogfilt</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">log_filters</span><span class="p">,</span>
<span class="n">nceps</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">ceps_number</span><span class="p">,</span> <span class="n">get_spec</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">spec</span><span class="p">,</span>
<span class="n">get_mspec</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">mspec</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ceps_number</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">mspec</span><span class="p">:</span>
<span class="n">cep</span> <span class="o">=</span> <span class="n">c</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
<span class="n">label</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_vad</span><span class="p">(</span><span class="n">c</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">x</span><span class="p">,</span> <span class="n">channel_ext</span><span class="p">,</span> <span class="n">show</span><span class="p">)</span>
......@@ -688,11 +692,11 @@
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">delta</span><span class="p">:</span>
<span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;add delta&#39;</span><span class="p">)</span>
<span class="n">delta</span> <span class="o">=</span> <span class="n">compute_delta</span><span class="p">(</span><span class="n">cep</span><span class="p">)</span>
<span class="n">delta</span> <span class="o">=</span> <span class="n">compute_delta</span><span class="p">(</span><span class="n">cep</span><span class="p">,</span> <span class="n">filt</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">delta_filter</span><span class="p">)</span>
<span class="n">cep</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">column_stack</span><span class="p">((</span><span class="n">cep</span><span class="p">,</span> <span class="n">delta</span><span class="p">))</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">double_delta</span><span class="p">:</span>
<span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;add delta delta&#39;</span><span class="p">)</span>
<span class="n">double_delta</span> <span class="o">=</span> <span class="n">compute_delta</span><span class="p">(</span><span class="n">delta</span><span class="p">)</span>
<span class="n">double_delta</span> <span class="o">=</span> <span class="n">compute_delta</span><span class="p">(</span><span class="n">delta</span><span class="p">,</span> <span class="n">filt</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">delta_filter</span><span class="p">)</span>
<span class="n">cep</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">column_stack</span><span class="p">((</span><span class="n">cep</span><span class="p">,</span> <span class="n">double_delta</span><span class="p">))</span>
<span class="k">return</span> <span class="n">cep</span>
......@@ -768,10 +772,10 @@
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">label</span> <span class="o">=</span> <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">True</span><span class="p">]</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])]</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_filter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mask</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_filter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
<span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mask</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">keep_all_features</span><span class="p">:</span>
<span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;!!! no keep all feature !!!&#39;</span><span class="p">)</span>
......@@ -781,16 +785,16 @@
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cep</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">label</span>
</div>
<span class="k">def</span> <span class="nf">_filter</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cep</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">_mask</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cep</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> keep only the MFCC index present in the filter list</span>
<span class="sd"> :param cep:</span>
<span class="sd"> :return: return the list of MFCC given by filter list</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filter</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mask</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">&#39;filter list is empty&#39;</span><span class="p">)</span>
<span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;applied filter&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">cep</span><span class="p">[:,</span> <span class="bp">self</span><span class="o">.</span><span class="n">filter</span><span class="p">]</span>
<span class="n">logging</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s">&#39;applied mask&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">cep</span><span class="p">[:,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask</span><span class="p">]</span>
<div class="viewcode-block" id="FeaturesServer.save"><a class="viewcode-back" href="../featuresserver.html#features_server.FeaturesServer.save">[docs]</a> <span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">show</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">mfcc_format</span><span class="p">,</span> <span class="n">and_label</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
......
......@@ -382,13 +382,11 @@
<span class="sd"> Default is 0.</span>
<span class="sd"> :param nlogfilt: number of log-linear filters to use in high frequencies.</span>
<span class="sd"> Default is 24.</span>
<span class="sd"> :param nwin: length of the sliding window in milliseconds</span>
<span class="sd"> :param nwin: length of the sliding window in seconds</span>
<span class="sd"> Default is 0.025.</span>
<span class="sd"> :param fs: sampling frequency of the original signal. Default is 16000Hz.</span>
<span class="sd"> :param nceps: number of cepstral coefficients to extract. </span>
<span class="sd"> Default is 13.</span>
<span class="sd"> :param midfreq: frequency boundary between linear and log-linear filters.</span>
<span class="sd"> Default is 1000Hz.</span>
<span class="sd"> :param shift: shift between two analyses. Default is 0.01 (10ms).</span>
<span class="sd"> :param get_spec: boolean, if true returns the spectrogram</span>
<span class="sd"> :param get_mspec: boolean, if true returns the output of the filter banks</span>
......
......@@ -439,7 +439,7 @@
<span class="k">return</span> <span class="n">y</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">info</span><span class="p">[</span><span class="mi">8</span><span class="p">])</span>
</div>
<div class="viewcode-block" id="read_audio"><a class="viewcode-back" href="../../frontend/io.html#frontend.io.read_audio">[docs]</a><span class="k">def</span> <span class="nf">read_audio</span><span class="p">(</span><span class="n">inputFileName</span><span class="p">,</span> <span class="n">fs</span><span class="o">=</span><span class="mi">16000</span><span class="p">):</span>
<div class="viewcode-block" id="read_audio"><a class="viewcode-back" href="../../frontend/io.html#frontend.io.read_audio">[docs]</a><span class="k">def</span> <span class="nf">read_audio</span><span class="p">(</span><span class="n">inputFileName</span><span class="p">,</span> <span class="n">fs</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot; Read a 1 or 2-channel audio file in SPHERE, WAVE or RAW PCM format.</span>
<span class="sd"> The format is determined from the file extension.</span>
<span class="sd"> If the sample rate read from the file is a multiple of the one given</span>
......@@ -450,6 +450,8 @@
<span class="sd"> :return: the signal as a numpy array and the sampling frequency</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">fs</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s">&quot;Expected sampling frequency required in sidekit.frontend.io.read_audio&quot;</span><span class="p">)</span>
<span class="n">ext</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">inputFileName</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="k">if</span> <span class="n">ext</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s">&#39;.sph&#39;</span><span class="p">:</span>
<span class="n">sig</span><span class="p">,</span> <span class="n">read_fs</span> <span class="o">=</span> <span class="n">read_sph</span><span class="p">(</span><span class="n">inputFileName</span><span class="p">,</span> <span class="s">&#39;p&#39;</span><span class="p">)</span>
......@@ -462,8 +464,11 @@
<span class="n">logging</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span><span class="s">&#39;Unknown extension of audio file&#39;</span><span class="p">)</span>
<span class="n">sig</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">fs</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">read_fs</span> <span class="o">%</span> <span class="nb">float</span><span class="p">(</span><span class="n">fs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">sig</span> <span class="o">=</span> <span class="n">decimate</span><span class="p">(</span><span class="n">sig</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">read_fs</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">fs</span><span class="p">)),</span> <span class="n">n</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">ftype</span><span class="o">=</span><span class="s">&#39;iir&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=-</span><span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="n">fs</span> <span class="o">&gt;</span> <span class="n">read_fs</span><span class="p">:</span>
<span class="k">print</span><span class="p">(</span><span class="s">&quot;Warning in read_audio, up-sampling function is not implemented yet!&quot;</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">read_fs</span> <span class="o">%</span> <span class="nb">float</span><span class="p">(</span><span class="n">fs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">fs</span> <span class="o">==</span> <span class="n">read_fs</span><span class="p">:</span>
<span class="k">print</span><span class="p">(</span><span class="s">&quot;Sub-sampling from {} Hz to {} Hz&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">read_fs</span><span class="p">,</span> <span class="n">fs</span><span class="p">))</span>
<span class="n">sig</span> <span class="o">=</span> <span class="n">decimate</span><span class="p">(</span><span class="n">sig</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">read_fs</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="n">fs</span><span class="p">)),</span> <span class="n">n</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">ftype</span><span class="o">=</span><span class="s">&#39;iir&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="k">return</span> <span class="n">sig</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">float32</span><span class="p">),</span> <span class="n">fs</span>
</div>
<span class="nd">@check_path_existance</span>
......
......@@ -179,7 +179,7 @@
<span class="c"># speechFeatures = features[label, :]</span>
<span class="n">mu</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">features</span><span class="p">[</span><span class="n">label</span><span class="p">,</span> <span class="p">:],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">stdev</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">features</span><span class="p">[</span><span class="n">label</span><span class="p">,</span> <span class="p">:],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="n">features</span> <span class="o">-=</span> <span class="n">mu</span>
<span class="n">features</span> <span class="o">/=</span> <span class="n">stdev</span>
</div>
......
......@@ -214,9 +214,25 @@
<span class="k">with</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">pickle</span><span class="o">.</span><span class="n">dump</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">write_dict_hdf5</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">outpuFileName</span><span class="p">):</span>
<span class="k">with</span> <span class="n">h5py</span><span class="o">.</span><span class="n">File</span><span class="p">(</span><span class="n">outpuFileName</span><span class="p">,</span> <span class="s">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
<span class="c">#print(type(value))</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">f</span><span class="o">.</span><span class="n">create_dataset</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">value</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s">&quot;gzip&quot;</span><span class="p">,</span> <span class="n">fletcher32</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">f</span><span class="o">.</span><span class="n">create_dataset</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">value</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">read_dict_hdf5</span><span class="p">(</span><span class="n">outpuFileName</span><span class="p">):</span>
<span class="n">data</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="k">with</span> <span class="n">h5py</span><span class="o">.</span><span class="n">File</span><span class="p">(</span><span class="n">outpuFileName</span><span class="p">,</span> <span class="s">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">f</span><span class="o">.</span><span class="n">keys</span><span class="p">:</span>
<span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">get</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="k">return</span> <span class="n">data</span>
<span class="k">def</span> <span class="nf">write_norm_hdf5</span><span class="p">(</span><span class="n">means</span><span class="p">,</span> <span class="n">covs</span><span class="p">,</span> <span class="n">outpuFileName</span><span class="p">):</span>
<span class="k">with</span> <span class="n">h5py</span><span class="o">.</span><span class="n">File</span><span class="p">(</span><span class="n">outpuFileName</span><span class="p">,</span> <span class="s">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="c">#a = np.zeros(1)</span>
<span class="n">a</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">means</span><span class="p">)</span>
<span class="n">f</span><span class="o">.</span><span class="n">create_dataset</span><span class="p">(</span><span class="s">&quot;len&quot;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">a</span><span class="p">,</span>
<span class="n">maxshape</span><span class="o">=</span><span class="p">(</span><span class="bp">None</span><span class="p">,))</span>
......
......@@ -89,7 +89,7 @@
<h1>FeaturesServer<a class="headerlink" href="#featuresserver" title="Permalink to this headline"></a></h1>
<dl class="class">
<dt id="features_server.FeaturesServer">
<em class="property">class </em><code class="descclassname">features_server.</code><code class="descname">FeaturesServer</code><span class="sig-paren">(</span><em>input_dir=None</em>, <em>input_file_extension=None</em>, <em>label_dir=None</em>, <em>label_file_extension=None</em>, <em>from_file=None</em>, <em>config=None</em>, <em>single_channel_extension=''</em>, <em>double_channel_extension=('_a'</em>, <em>'_b')</em>, <em>sampling_frequency=None</em>, <em>lower_frequency=None</em>, <em>higher_frequency=None</em>, <em>linear_filters=None</em>, <em>log_filters=None</em>, <em>window_size=None</em>, <em>shift=None</em>, <em>ceps_number=None</em>, <em>snr=None</em>, <em>vad=None</em>, <em>feat_norm=None</em>, <em>log_e=None</em>, <em>dct_pca=False</em>, <em>dct_pca_config=None</em>, <em>sdc=False</em>, <em>sdc_config=None</em>, <em>delta=None</em>, <em>double_delta=None</em>, <em>delta_filter=None</em>, <em>rasta=None</em>, <em>keep_all_features=None</em>, <em>spec=False</em>, <em>mspec=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/features_server.html#FeaturesServer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#features_server.FeaturesServer" title="Permalink to this definition"></a></dt>
<em class="property">class </em><code class="descclassname">features_server.</code><code class="descname">FeaturesServer</code><span class="sig-paren">(</span><em>input_dir=None</em>, <em>input_file_extension=None</em>, <em>label_dir=None</em>, <em>label_file_extension=None</em>, <em>from_file=None</em>, <em>config=None</em>, <em>single_channel_extension=''</em>, <em>double_channel_extension=('_a'</em>, <em>'_b')</em>, <em>sampling_frequency=None</em>, <em>lower_frequency=None</em>, <em>higher_frequency=None</em>, <em>linear_filters=None</em>, <em>log_filters=None</em>, <em>window_size=None</em>, <em>shift=None</em>, <em>ceps_number=None</em>, <em>snr=None</em>, <em>vad=None</em>, <em>feat_norm=None</em>, <em>log_e=None</em>, <em>dct_pca=False</em>, <em>dct_pca_config=None</em>, <em>sdc=False</em>, <em>sdc_config=None</em>, <em>delta=None</em>, <em>double_delta=None</em>, <em>delta_filter=None</em>, <em>rasta=None</em>, <em>keep_all_features=None</em>, <em>spec=False</em>, <em>mspec=False</em>, <em>mask=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/features_server.html#FeaturesServer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#features_server.FeaturesServer" title="Permalink to this definition"></a></dt>
<dd><p>A class for acoustic feature management.
FeaturesServer should be used to extract acoustic features (MFCC or LFCC)
from audio files in SPHERE, WAV or RAW PCM format.
......
......@@ -275,13 +275,11 @@ Default is 8000Hz.</li>
Default is 0.</li>
<li><strong>nlogfilt</strong> &#8211; number of log-linear filters to use in high frequencies.
Default is 24.</li>
<li><strong>nwin</strong> &#8211; length of the sliding window in milliseconds
<li><strong>nwin</strong> &#8211; length of the sliding window in seconds
Default is 0.025.</li>
<li><strong>fs</strong> &#8211; sampling frequency of the original signal. Default is 16000Hz.</li>
<li><strong>nceps</strong> &#8211; number of cepstral coefficients to extract.
Default is 13.</li>
<li><strong>midfreq</strong> &#8211; frequency boundary between linear and log-linear filters.
Default is 1000Hz.</li>
<li><strong>shift</strong> &#8211; shift between two analyses. Default is 0.01 (10ms).</li>
<li><strong>get_spec</strong> &#8211; boolean, if true returns the spectrogram</li>
<li><strong>get_mspec</strong> &#8211; boolean, if true returns the output of the filter banks</li>
......
......@@ -114,7 +114,7 @@ has a mean square value of unity corresponding to 0 dBm0.
<dl class="function">
<dt id="frontend.io.read_audio">
<code class="descclassname">frontend.io.</code><code class="descname">read_audio</code><span class="sig-paren">(</span><em>inputFileName</em>, <em>fs=16000</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/frontend/io.html#read_audio"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#frontend.io.read_audio" title="Permalink to this definition"></a></dt>
<code class="descclassname">frontend.io.</code><code class="descname">read_audio</code><span class="sig-paren">(</span><em>inputFileName</em>, <em>fs=None</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/frontend/io.html#read_audio"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#frontend.io.read_audio" title="Permalink to this definition"></a></dt>
<dd><p>Read a 1 or 2-channel audio file in SPHERE, WAVE or RAW PCM format.
The format is determined from the file extension.
If the sample rate read from the file is a multiple of the one given
......
......@@ -239,12 +239,12 @@
<dt><a href="statserver.html#statserver.StatServer.estimate_hidden">estimate_hidden() (statserver.StatServer method)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="statserver.html#statserver.StatServer.estimate_map">estimate_map() (statserver.StatServer method)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="statserver.html#statserver.StatServer.estimate_spectral_norm_stat1">estimate_spectral_norm_stat1() (statserver.StatServer method)</a>
</dt>
......@@ -254,10 +254,6 @@
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.evaluations">evaluations() (in module libsvm.svmutil)</a>
</dt>
<dt><a href="theano_utils.html#theano_utils.export_params">export_params() (in module theano_utils)</a>
</dt>
......@@ -526,23 +522,15 @@
</dt>
<dt><a href="libsvm/libsvm_core.html#module-libsvm.svm">libsvm.svm (module)</a>
</dt>
<dt><a href="libsvm/libsvm_core.html#module-libsvm.svmutil">libsvm.svmutil (module)</a>
</dt>
<dt><a href="featuresserver.html#features_server.FeaturesServer.load">load() (features_server.FeaturesServer method)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="featuresserver.html#features_server.FeaturesServer.load_and_stack">load_and_stack() (features_server.FeaturesServer method)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="featuresserver.html#features_server.FeaturesServer.load_and_stack_threading">load_and_stack_threading() (features_server.FeaturesServer method)</a>
</dt>
......@@ -830,15 +818,9 @@
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.read_svm">read_svm() (in module libsvm.svmutil)</a>
<dt><a href="sv_utils.html#sv_utils.read_svm">read_svm() (in module sv_utils)</a>
</dt>
<dd><dl>
<dt><a href="sv_utils.html#sv_utils.read_svm">(in module sv_utils)</a>
</dt>
</dl></dd>
<dt><a href="bosaris/idmap.html#bosaris.IdMap.read_txt">read_txt() (bosaris.IdMap method)</a>
</dt>
......@@ -884,15 +866,9 @@
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.save_svm">save_svm() (in module libsvm.svmutil)</a>
</dt>
<dd><dl>
<dt><a href="sv_utils.html#sv_utils.save_svm">(in module sv_utils)</a>
<dt><a href="sv_utils.html#sv_utils.save_svm">save_svm() (in module sv_utils)</a>
</dt>
</dl></dd>
<dt><a href="bosaris/scores.html#bosaris.Scores">Scores (class in bosaris)</a>
</dt>
......@@ -941,6 +917,8 @@
<dt><a href="sidekit_io.html#module-sidekit_io">sidekit_io (module)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="bosaris/scores.html#bosaris.Scores.sort">sort() (bosaris.Scores method)</a>
</dt>
......@@ -953,8 +931,6 @@
<dt><a href="frontend/vad.html#frontend.vad.speech_enhancement">speech_enhancement() (in module frontend.vad)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="statserver.html#statserver.StatServer">StatServer (class in statserver)</a>
</dt>
......@@ -980,22 +956,6 @@
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.svm_load_model">svm_load_model() (in module libsvm.svmutil)</a>
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.svm_predict">svm_predict() (in module libsvm.svmutil)</a>
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.svm_read_problem">svm_read_problem() (in module libsvm.svmutil)</a>
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.svm_save_model">svm_save_model() (in module libsvm.svmutil)</a>
</dt>
<dt><a href="svm_scoring.html#module-svm_scoring">svm_scoring (module)</a>
</dt>
......@@ -1008,10 +968,6 @@
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svmutil.svm_train">svm_train() (in module libsvm.svmutil)</a>
</dt>
<dt><a href="svm_training.html#module-svm_training">svm_training (module)</a>
</dt>
......@@ -1038,16 +994,12 @@
</dt>
<dt><a href="libsvm/libsvm_core.html#libsvm.svm.toPyModel">toPyModel() (in module libsvm.svm)</a>
<dt><a href="theano_utils.html#theano_utils.FForwardNetwork.train">train() (theano_utils.FForwardNetwork method)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="theano_utils.html#theano_utils.FForwardNetwork.train">train() (theano_utils.FForwardNetwork method)</a>
</dt>
<dt><a href="frontend/features.html#frontend.features.trfbank">trfbank() (in module frontend.features)</a>
</dt>
......
......@@ -206,7 +206,7 @@ Sylvain Meignier</td>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="tutorial/shorttuto.html">Enter the SIDEKIT</a><ul>
<li class="toctree-l3"><a class="reference internal" href="tutorial/featureExtraction.html">Extract acoustic features</a></li>
<li class="toctree-l3"><a class="reference internal" href="tutorial/featureExtraction.html">Acoustic parametrization</a></li>
<li class="toctree-l3"><a class="reference internal" href="tutorial/ubmTraining.html">Train a Universal Background Model</a></li>
<li class="toctree-l3"><a class="reference internal" href="tutorial/factoranalysis.html">The unified Factor Analyser training</a></li>
</ul>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment