<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://wooters.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://wooters.github.io/" rel="alternate" type="text/html" /><updated>2026-02-16T21:46:14+00:00</updated><id>https://wooters.github.io/feed.xml</id><title type="html">Notes to my future-self</title><subtitle>Stuff I think I&apos;ll want to remember, at some point.</subtitle><entry><title type="html">Python function to check if a host is reachable</title><link href="https://wooters.github.io/2020/04/12/host_reachable.html" rel="alternate" type="text/html" title="Python function to check if a host is reachable" /><published>2020-04-12T00:00:00+00:00</published><updated>2020-04-12T00:00:00+00:00</updated><id>https://wooters.github.io/2020/04/12/host_reachable</id><content type="html" xml:base="https://wooters.github.io/2020/04/12/host_reachable.html"><![CDATA[<p>(Tested on MacOS 10.15.3)</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">os</span>

<span class="k">def</span> <span class="nf">host_is_reachable</span><span class="p">(</span><span class="n">host</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
  <span class="k">return</span> <span class="bp">True</span> <span class="k">if</span> <span class="n">os</span><span class="p">.</span><span class="n">system</span><span class="p">(</span><span class="sa">f</span><span class="s">"ping -t 1 -o </span><span class="si">{</span><span class="n">host</span><span class="si">}</span><span class="s">"</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span> <span class="k">else</span> <span class="bp">False</span>
</code></pre></div></div>

<p>Note: this is <strong>not safe</strong> if the <code class="language-plaintext highlighter-rouge">host</code> parameter will be coming from an untrusted user.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[(Tested on MacOS 10.15.3)]]></summary></entry><entry><title type="html">SSH Tunneling</title><link href="https://wooters.github.io/2020/04/12/port-forwarding.html" rel="alternate" type="text/html" title="SSH Tunneling" /><published>2020-04-12T00:00:00+00:00</published><updated>2020-04-12T00:00:00+00:00</updated><id>https://wooters.github.io/2020/04/12/port-forwarding</id><content type="html" xml:base="https://wooters.github.io/2020/04/12/port-forwarding.html"><![CDATA[<p>The meaning of the parts in the <code class="language-plaintext highlighter-rouge">-L</code> arg:</p>

<blockquote>
  <p>local_port:remote_host:remote_port</p>
</blockquote>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh $user@$remote_host -L 8080:$remote_host:8000 -N
</code></pre></div></div>

<p>The above will reroute port 8080 on the local host to port 8000 on <code class="language-plaintext highlighter-rouge">$remote_host</code> over
the <code class="language-plaintext highlighter-rouge">ssh</code> connection.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[The meaning of the parts in the -L arg:]]></summary></entry><entry><title type="html">Using the gentle forced aligner</title><link href="https://wooters.github.io/2019/12/16/forced_alignment.html" rel="alternate" type="text/html" title="Using the gentle forced aligner" /><published>2019-12-16T00:00:00+00:00</published><updated>2019-12-16T00:00:00+00:00</updated><id>https://wooters.github.io/2019/12/16/forced_alignment</id><content type="html" xml:base="https://wooters.github.io/2019/12/16/forced_alignment.html"><![CDATA[<p>A quick and easy way of aligning orthographic transcripts with audio to get word-level timing information.</p>

<h2 id="start-the-server">Start the server:</h2>
<p>Assumes you have <code class="language-plaintext highlighter-rouge">docker</code> installed. See the <a href="https://github.com/lowerquality/gentle">lowerquality/gentle github repo</a> for more info.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>docker run <span class="nt">-p</span> 8765:8765 lowerquality/gentle
</code></pre></div></div>

<h2 id="run-forced-alignment-from-command-line">Run forced-alignment from command-line</h2>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>curl <span class="nt">-F</span> <span class="s2">"audio=@/path/to/audio.wav"</span> <span class="se">\</span>
  <span class="nt">-F</span> <span class="s2">"transcript=@/path/to/transcript.txt"</span> <span class="se">\</span>
  <span class="s2">"http://localhost:8765/transcriptions?async=false"</span>
</code></pre></div></div>

<p>It appears to run about 2x faster than real-time on my macbook pro.</p>

<h2 id="example">Example</h2>
<p>Running the above <code class="language-plaintext highlighter-rouge">curl</code> command using:</p>

<ul>
  <li>audio: <a href="https://www2.cs.uic.edu/~i101/SoundFiles/gettysburg10.wav">10 seconds of the Gettysburg address</a> from https://www2.cs.uic.edu/~i101/SoundFiles/</li>
  <li>transcript: <code class="language-plaintext highlighter-rouge">four score and seven years ago our fathers brought forth on this continent a new nation conceived in liberty and dedicated to the proposition that all men are created equal</code></li>
</ul>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>curl <span class="nt">-F</span> <span class="s2">"audio=@gettysburg10.wav"</span> <span class="nt">-F</span> <span class="s2">"transcript=@gettysburg10.txt"</span> <span class="s2">"http://localhost:8765/transcriptions?async=false"</span>
</code></pre></div></div>

<p>Output (truncated):</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{
  "transcript": "four score and seven years ago our fathers brought forth on this continent a new nation conceived in liberty and dedicated to the proposition that all men are created equal\n",
  "words": [
    {
      "alignedWord": "four",
      "case": "success",
      "end": 0.71,
      "endOffset": 4,
      "phones": [
        {
          "duration": 0.15,
          "phone": "f_B"
        },
        {
          "duration": 0.13,
          "phone": "ao_I"
        },
        {
          "duration": 0.1,
          "phone": "r_E"
        }
      ],
      "start": 0.33,
      "startOffset": 0,
      "word": "four"
    },
    {
      "alignedWord": "score",
      "case": "success",
      "end": 1.1099999999999999,
      "endOffset": 10,
      "phones": [
        {
          "duration": 0.1,
          "phone": "s_B"
        },
        {
          "duration": 0.07,
          "phone": "k_I"
        },
        {
          "duration": 0.17,
          "phone": "ao_I"
        },
        {
          "duration": 0.06,
          "phone": "r_E"
        }
      ],
      "start": 0.71,
      "startOffset": 5,
      "word": "score"
    },
    
    ...
    
  ]
}
</code></pre></div></div>]]></content><author><name></name></author><summary type="html"><![CDATA[A quick and easy way of aligning orthographic transcripts with audio to get word-level timing information.]]></summary></entry><entry><title type="html">Create a persistent ssh connection to a screen session</title><link href="https://wooters.github.io/2015/07/15/persistent-ssh-screen-session.html" rel="alternate" type="text/html" title="Create a persistent ssh connection to a screen session" /><published>2015-07-15T00:00:00+00:00</published><updated>2015-07-15T00:00:00+00:00</updated><id>https://wooters.github.io/2015/07/15/persistent-ssh-screen-session</id><content type="html" xml:base="https://wooters.github.io/2015/07/15/persistent-ssh-screen-session.html"><![CDATA[<p>(Install <code class="language-plaintext highlighter-rouge">autossh</code> via homebrew)</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>autossh -M50000 -t server.example.com 'screen -raAd mysession'
</code></pre></div></div>]]></content><author><name></name></author><summary type="html"><![CDATA[(Install autossh via homebrew)]]></summary></entry><entry><title type="html">Resumable copy of large files</title><link href="https://wooters.github.io/2015/07/15/resume_copy_large_files.html" rel="alternate" type="text/html" title="Resumable copy of large files" /><published>2015-07-15T00:00:00+00:00</published><updated>2015-07-15T00:00:00+00:00</updated><id>https://wooters.github.io/2015/07/15/resume_copy_large_files</id><content type="html" xml:base="https://wooters.github.io/2015/07/15/resume_copy_large_files.html"><![CDATA[<p>In case you have a spotty internet connection, you can use <a href="https://en.wikipedia.org/wiki/Rsync">rsync</a> to
copy files to/from a remote host.</p>

<p>If your connection drops in the middle of the transfer, you can just re-run the command and it will pick
up where it left off.</p>

<h2 id="local--remote">local –&gt; remote</h2>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>rsync –partial –progress –rsh<span class="o">=</span>ssh <span class="nv">$local_file</span> <span class="nv">$user</span>@<span class="nv">$host</span>:<span class="nv">$destination_file</span>
</code></pre></div></div>

<h2 id="local--remote-1">local &lt;– remote</h2>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>rsync –partial –progress –rsh<span class="o">=</span>ssh <span class="nv">$user</span>@<span class="nv">$host</span>:<span class="nv">$remote_file</span> <span class="nv">$local_file</span>
</code></pre></div></div>]]></content><author><name></name></author><summary type="html"><![CDATA[In case you have a spotty internet connection, you can use rsync to copy files to/from a remote host.]]></summary></entry></feed>