Skip to content

Commit

Permalink
deploy: c2ea5e1
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Jan 3, 2025
1 parent c915dcb commit 540ebc5
Show file tree
Hide file tree
Showing 38 changed files with 154 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: b201529e79aae5fdf2e6626e37e9091e
config: 2482da82aa430d690918cff7dfeb34b2
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file modified .doctrees/api/audiofile.read.doctree
Binary file not shown.
Binary file modified .doctrees/changelog.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified _images/audiofile-read-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/audiofile-read-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/audiofile-read-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/audiofile-read-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/audiofile-read-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions _modules/audiofile/core/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@


<div class="version">
v1.5.0
v1.5.1
</div>


Expand Down Expand Up @@ -142,10 +142,12 @@

<h1>Source code for audiofile.core.info</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;Read, write, and get information about audio files.&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">subprocess</span>
<span class="kn">import</span> <span class="nn">tempfile</span>
<span class="kn">import</span> <span class="nn">typing</span>

<span class="kn">import</span> <span class="nn">soundfile</span>

Expand All @@ -159,7 +161,7 @@ <h1>Source code for audiofile.core.info</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">audiofile.core.utils</span> <span class="kn">import</span> <span class="n">run</span>


<div class="viewcode-block" id="bit_depth"><a class="viewcode-back" href="../../../api/audiofile.bit_depth.html#audiofile.bit_depth">[docs]</a><span class="k">def</span> <span class="nf">bit_depth</span><span class="p">(</span><span class="n">file</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]:</span>
<div class="viewcode-block" id="bit_depth"><a class="viewcode-back" href="../../../api/audiofile.bit_depth.html#audiofile.bit_depth">[docs]</a><span class="k">def</span> <span class="nf">bit_depth</span><span class="p">(</span><span class="n">file</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;Bit depth of audio file.</span>

<span class="sd"> For lossy audio files,</span>
Expand Down Expand Up @@ -461,15 +463,15 @@ <h1>Source code for audiofile.core.info</h1><div class="highlight"><pre>



Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2024/07/26 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>
Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2025/01/03 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>

</p>
</div>

<div role="contentinfo">
<p>

&copy; 2018-2024 audEERING GmbH
&copy; 2018-2025 audEERING GmbH
</p>
</div>

Expand Down
36 changes: 22 additions & 14 deletions _modules/audiofile/core/io.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@


<div class="version">
v1.5.0
v1.5.1
</div>


Expand Down Expand Up @@ -141,9 +141,10 @@
<div itemprop="articleBody">

<h1>Source code for audiofile.core.io</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">os</span>
<span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">annotations</span>

<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">tempfile</span>
<span class="kn">import</span> <span class="nn">typing</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">soundfile</span>
Expand All @@ -161,8 +162,8 @@ <h1>Source code for audiofile.core.io</h1><div class="highlight"><pre>
<div class="viewcode-block" id="convert_to_wav"><a class="viewcode-back" href="../../../api/audiofile.convert_to_wav.html#audiofile.convert_to_wav">[docs]</a><span class="k">def</span> <span class="nf">convert_to_wav</span><span class="p">(</span>
<span class="n">infile</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">outfile</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">offset</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">duration</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">offset</span><span class="p">:</span> <span class="nb">float</span> <span class="o">|</span> <span class="nb">int</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">duration</span><span class="p">:</span> <span class="nb">float</span> <span class="o">|</span> <span class="nb">int</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">bit_depth</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">16</span><span class="p">,</span>
<span class="n">normalize</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">overwrite</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
Expand Down Expand Up @@ -265,12 +266,12 @@ <h1>Source code for audiofile.core.io</h1><div class="highlight"><pre>

<div class="viewcode-block" id="read"><a class="viewcode-back" href="../../../api/audiofile.read.html#audiofile.read">[docs]</a><span class="k">def</span> <span class="nf">read</span><span class="p">(</span>
<span class="n">file</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
<span class="n">duration</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">offset</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">float</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">duration</span><span class="p">:</span> <span class="nb">float</span> <span class="o">|</span> <span class="nb">int</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">offset</span><span class="p">:</span> <span class="nb">float</span> <span class="o">|</span> <span class="nb">int</span> <span class="o">|</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">np</span><span class="o">.</span><span class="n">timedelta64</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">always_2d</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">dtype</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;float32&quot;</span><span class="p">,</span>
<span class="o">**</span><span class="n">kwargs</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">typing</span><span class="o">.</span><span class="n">Tuple</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="nb">int</span><span class="p">]:</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">tuple</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="nb">int</span><span class="p">]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Read audio file.</span>

<span class="sd"> It uses :func:`soundfile.read` for WAV, FLAC, MP3, and OGG files.</span>
Expand Down Expand Up @@ -396,6 +397,7 @@ <h1>Source code for audiofile.core.io</h1><div class="highlight"><pre>

<span class="sd"> &quot;&quot;&quot;</span> <span class="c1"># noqa: E501</span>
<span class="n">file</span> <span class="o">=</span> <span class="n">audeer</span><span class="o">.</span><span class="n">safe_path</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
<span class="n">sampling_rate</span> <span class="o">=</span> <span class="kc">None</span>

<span class="c1"># Parse offset and duration values</span>
<span class="k">if</span> <span class="p">(</span>
Expand Down Expand Up @@ -519,17 +521,23 @@ <h1>Source code for audiofile.core.io</h1><div class="highlight"><pre>
<span class="c1"># the returned magnitude</span>
<span class="c1"># (https://github.com/librosa/librosa/issues/811).</span>
<span class="c1">#</span>
<span class="c1"># It might be the case that MP3 files will be supported by soundfile in</span>
<span class="c1"># the future as well. For a discussion on MP3 support in the underlying</span>
<span class="c1"># libsndfile see https://github.com/erikd/libsndfile/issues/258.</span>
<span class="k">with</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">TemporaryDirectory</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="s2">&quot;audiofile&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">tmpdir</span><span class="p">:</span>
<span class="n">tmpfile</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">join</span><span class="p">(</span><span class="n">tmpdir</span><span class="p">,</span> <span class="s2">&quot;tmp.wav&quot;</span><span class="p">)</span>
<span class="c1"># offset and duration have to be given in seconds</span>
<span class="k">if</span> <span class="n">offset</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">offset</span> <span class="o">/=</span> <span class="n">sampling_rate</span>
<span class="k">if</span> <span class="n">duration</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">duration</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">duration</span> <span class="o">/=</span> <span class="n">sampling_rate</span>
<span class="n">convert</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">tmpfile</span><span class="p">,</span> <span class="n">offset</span><span class="p">,</span> <span class="n">duration</span><span class="p">)</span>
<span class="k">if</span> <span class="n">sampling_rate</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="c1"># Infer sampling rate using mediainfo before conversion,</span>
<span class="c1"># as ffmpeg does ignore the original sampling rate for opus files,</span>
<span class="c1"># see:</span>
<span class="c1"># * https://trac.ffmpeg.org/ticket/5240</span>
<span class="c1"># * https://github.com/audeering/audiofile/issues/157</span>
<span class="kn">from</span> <span class="nn">audiofile.core.info</span> <span class="kn">import</span> <span class="n">sampling_rate</span> <span class="k">as</span> <span class="n">get_sampling_rate</span>

<span class="n">sampling_rate</span> <span class="o">=</span> <span class="n">get_sampling_rate</span><span class="p">(</span><span class="n">file</span><span class="p">)</span>
<span class="n">convert</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="n">tmpfile</span><span class="p">,</span> <span class="n">offset</span><span class="p">,</span> <span class="n">duration</span><span class="p">,</span> <span class="n">sampling_rate</span><span class="p">)</span>
<span class="n">signal</span><span class="p">,</span> <span class="n">sampling_rate</span> <span class="o">=</span> <span class="n">soundfile</span><span class="o">.</span><span class="n">read</span><span class="p">(</span>
<span class="n">tmpfile</span><span class="p">,</span>
<span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">,</span>
Expand Down Expand Up @@ -658,15 +666,15 @@ <h1>Source code for audiofile.core.io</h1><div class="highlight"><pre>



Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2024/07/26 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>
Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2025/01/03 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>

</p>
</div>

<div role="contentinfo">
<p>

&copy; 2018-2024 audEERING GmbH
&copy; 2018-2025 audEERING GmbH
</p>
</div>

Expand Down
6 changes: 3 additions & 3 deletions _modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@


<div class="version">
v1.5.0
v1.5.1
</div>


Expand Down Expand Up @@ -157,15 +157,15 @@ <h1>All modules for which code is available</h1>



Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2024/07/26 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>
Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2025/01/03 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>

</p>
</div>

<div role="contentinfo">
<p>

&copy; 2018-2024 audEERING GmbH
&copy; 2018-2025 audEERING GmbH
</p>
</div>

Expand Down
12 changes: 6 additions & 6 deletions api/audiofile.bit_depth.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@


<div class="version">
v1.5.0
v1.5.1
</div>


Expand Down Expand Up @@ -164,16 +164,16 @@ <h1>bit_depth()<a class="headerlink" href="#bit-depth" title="Permalink to this
<code class="docutils literal notranslate"><span class="pre">None</span></code> is returned as they have a varying bit depth.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>file</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>) – file name of input audio file</p>
<dd class="field-odd"><p><strong>file</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.13)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>) – file name of input audio file</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>]</p>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Optional" title="(in Python v3.13)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.13)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>]</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>bit depth of audio file</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#RuntimeError" title="(in Python v3.12)"><strong>RuntimeError</strong></a> – if <code class="docutils literal notranslate"><span class="pre">file</span></code> is missing,
<dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#RuntimeError" title="(in Python v3.13)"><strong>RuntimeError</strong></a> – if <code class="docutils literal notranslate"><span class="pre">file</span></code> is missing,
broken or format is not supported</p>
</dd>
</dl>
Expand Down Expand Up @@ -209,15 +209,15 @@ <h1>bit_depth()<a class="headerlink" href="#bit-depth" title="Permalink to this



Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2024/07/26 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>
Built with <a href="https://www.sphinx-doc.org">Sphinx</a> on 2025/01/03 using the <a href="https://github.com/audeering/sphinx-audeering-theme/">audEERING theme</a>

</p>
</div>

<div role="contentinfo">
<p>

&copy; 2018-2024 audEERING GmbH
&copy; 2018-2025 audEERING GmbH
</p>
</div>

Expand Down
Loading

0 comments on commit 540ebc5

Please sign in to comment.