<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>robmsmt</title>
 <link href="https://robmsmt.github.io/atom.xml" rel="self"/>
 <link href="https://robmsmt.github.io/"/>
 <updated>2022-07-21T18:11:57+00:00</updated>
 <id>https://robmsmt.github.io</id>
 <author>
   <name>robmsmt</name>
   <email>robmsmt@gmail.com</email>
 </author>

 
 <entry>
   <title>Benchmarking ASRs - Results from the first 'Out of the Box' Test on an open source dataset</title>
   <link href="https://robmsmt.github.io/2021/09/04/benchmarking-asr-first-test/"/>
   <updated>2021-09-04T00:00:00+00:00</updated>
   <id>https://robmsmt.github.io/2021/09/04/benchmarking-asr-first-test</id>
   <content type="html">&lt;p&gt;First ‘Out of the box’ results for 5 ASRs: VOSK vs Sphinx vs Coqui vs Google vs Amazon&lt;/p&gt;

&lt;hr /&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;/public/css/mermaid.min.css&quot; /&gt;

&lt;script src=&quot;/public/js/gridjs.umd.js&quot;&gt;&lt;/script&gt;

&lt;h2 id=&quot;1-overview&quot;&gt;1. Overview&lt;/h2&gt;

&lt;p&gt;In this post the testing procedure is discussed on the initial small dataset that is included with
SpeechLoop. Speech systems are updated continuously so it’s sometimes hard to keep track of what the latest WER of each
system is. This tool allows for easy benchmarking for a given dataset, to answer that question.&lt;/p&gt;

&lt;p&gt;Although the test itself has a few limitations, it’s very small and the simplest which may be useful for those who want
to quickly get up and running and evaluating different speech systems.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;2-the-data&quot;&gt;2. The Data&lt;/h2&gt;

&lt;p&gt;There are 78 WAVs of a single female person speaking very short nouns (mostly single words).&lt;/p&gt;

&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    FileCount: 78
    TotalLength: 00:01:15
    ReadType: read
    AudioQualityType: high
    AudioNoiseType: none
    MicQuality: high
    AudioDist: near-field
    Persons: solo
    Language: EN
    Accent: US
    Gender: female
    Filetype: wav
    AudioFile: Signed 16 bit Little Endian, Rate 16000 Hz, Mono
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Although this isn’t a great comprehensive test on it’s own - it is another single data point that can help paint the
picture of how good the ASR is in real world settings. The details on the dataset can be
found &lt;a href=&quot;https://github.com/robmsmt/SpeechLoop/tree/master/speechloop/data/simple_test&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;message&quot;&gt;
  🎉 The dataset is open sourced under creative commons along with the &lt;a href=&quot;https://github.com/robmsmt/SpeechLoop&quot;&gt;SpeechLoop tool&lt;/a&gt; under Apache2 for anyone to download and repeat.
I would appreciate anyone who validates and double checks and finds flaws in any part of the data/test.
&lt;/div&gt;

&lt;p&gt;Sometimes single word commands are harder for ASRs when using WER as the metric. This is for two reasons, firstly, because the utterances are usually very short
there’s less information to evaluate (relies on the acoustic matching more so than pure unigram probabilities). Secondly, a single character when wrong can cause the word to be incorrect which contributes very large
error to the overall score. This can make this a useful test to run!&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;3-setup&quot;&gt;3. Setup&lt;/h2&gt;

&lt;p&gt;Since this is the first benchmark, every step is repeated in detail so that others can follow.&lt;/p&gt;

&lt;p&gt;Since we are planning to use GoogleASR and AWSTranscribe we need to setup the credentials. Suggested way is in the ~
/.bashrc:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#AWS&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;AWS_ACCESS_KEY_ID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;lt;accesskeyhere&amp;gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;AWS_SECRET_ACCESS_KEY&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&amp;lt;secret_access_key_here&amp;gt;
&lt;span class=&quot;c&quot;&gt;#GOOGLE&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;GOOGLE_APPLICATION_CREDENTIALS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/home/you/path/to/your/creds.json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then re-source the bashrc with: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source ~/.bashrc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, setup the repo as per the &lt;a href=&quot;https://github.com/robmsmt/SpeechLoop#developer---2-step-install&quot;&gt;instructions&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/robmsmt/SpeechLoop &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;SpeechLoop
python3 &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; venv venv/py3
&lt;span class=&quot;nb&quot;&gt;source &lt;/span&gt;venv/py3/bin/activate
pip &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; requirements-dev.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;speechloop
python main.py &lt;span class=&quot;nt&quot;&gt;--input_csv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'data/simple_test/simple_test.csv'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--wanted_asr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;all
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;4-asrs&quot;&gt;4. ASRs&lt;/h2&gt;

&lt;p&gt;When we run the script we provide &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--wanted_asr=all&lt;/code&gt; this means (as of writing):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;sp = Sphinx - pocketsphinx 0.1.15&lt;/li&gt;
  &lt;li&gt;vs = Vosk - based off of model en-small-us-0.15&lt;/li&gt;
  &lt;li&gt;cq = Coqui - based off of model v0.9.3&lt;/li&gt;
  &lt;li&gt;gg = GoogleASR - 21-09-06&lt;/li&gt;
  &lt;li&gt;aw = AwsTranscribe - 21-09-06&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last two being cloud ASRs so all we can use to distinguish is today’s date.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;5-results&quot;&gt;5. Results&lt;/h2&gt;

&lt;p&gt;After some minor tidying up of the dataframe, see
the &lt;a href=&quot;https://github.com/robmsmt/SpeechLoop/blob/master/notebooks/21-09-04-Benchmarking-ASR-first-test.ipynb&quot;&gt;Jupyter notebook&lt;/a&gt;
for details… a dataframe is generated which we can export to JSON, as seen below.&lt;/p&gt;

&lt;div id=&quot;wrapper&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    new gridjs.Grid({
      columns: [&quot;filename&quot;,&quot;vs&quot;,&quot;sp&quot;,&quot;cq&quot;,&quot;gg&quot;,&quot;aw&quot;,&quot;transcript&quot;,&quot;vs_wer&quot;,&quot;sp_wer&quot;,&quot;cq_wer&quot;,&quot;gg_wer&quot;,&quot;aw_wer&quot;, &quot;comb_wer&quot;],
      sort: true,
      pagination: {
        enabled: true,
        limit: 20,
        summary: true
      },
      resizable: false,
      search: true,
      autoWidth: true,
      width: &quot;150%&quot;,
      style: {
        td: {
          'padding-left': '1px',
          'padding-right': '1px'
        },
        th: {
          'padding-left': '1px',
          'padding-right': '1px'
        },
        table: {
          'font-size': '14px',
          'margin': '2px'
        },
        gridjs:{
          &quot;width&quot;: &quot;150%&quot;
        }
      },
      data: [[&quot;109865_bear_ch0_16k.wav&quot;,&quot;bear&quot;,&quot;they are&quot;,&quot;beare&quot;,&quot;bear&quot;,&quot;There&quot;,&quot;bear&quot;,0.0,1.0,1.0,0.0,1.0,3.0],[&quot;109879_frog_ch0_16k.wav&quot;,&quot;frog&quot;,&quot;for ah ok &quot;,&quot;forog&quot;,&quot;frog&quot;,&quot;Frog&quot;,&quot;frog&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109886_ice-cream_ch0_16k.wav&quot;,&quot;ice cream&quot;,&quot;ice cream&quot;,&quot;i cream&quot;,&quot;ice cream&quot;,&quot;Scream&quot;,&quot;ice cream&quot;,0.0,0.0,0.5,0.0,1.0,1.5],[&quot;109881_glass_ch0_16k.wav&quot;,&quot;glass&quot;,&quot;glass&quot;,&quot;glass&quot;,&quot;glass&quot;,&quot;Glass&quot;,&quot;glass&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109868_camera_ch0_16k.wav&quot;,&quot;camera&quot;,&quot;camera&quot;,&quot;camera&quot;,&quot;camera&quot;,&quot;Camera&quot;,&quot;camera&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109869_car_ch0_16k.wav&quot;,&quot;car&quot;,&quot;hello &quot;,&quot;car&quot;,&quot;car&quot;,&quot;Car&quot;,&quot;car&quot;,0.0,1.0,0.0,0.0,0.0,1.0],[&quot;109902_nail_ch0_16k.wav&quot;,&quot;nail&quot;,&quot;nail &quot;,&quot;nail&quot;,&quot;nail&quot;,&quot;Nail&quot;,&quot;nail&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109885_horse_ch0_16k.wav&quot;,&quot;horst&quot;,&quot;horses&quot;,&quot;horse&quot;,&quot;horse&quot;,&quot;Horse&quot;,&quot;horse&quot;,1.0,1.0,0.0,0.0,0.0,2.0],[&quot;109920_tiger_ch0_16k.wav&quot;,&quot;tiger&quot;,&quot;hiking&quot;,&quot;tiger&quot;,&quot;tiger&quot;,&quot;Tiger&quot;,&quot;tiger&quot;,0.0,1.0,0.0,0.0,0.0,1.0],[&quot;109874_earth_ch0_16k.wav&quot;,&quot;earth&quot;,&quot;earth&quot;,&quot;h&quot;,&quot;Earth&quot;,&quot;Earth&quot;,&quot;earth&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109864_apple_ch0_16k.wav&quot;,&quot;apple&quot;,&quot;at home&quot;,&quot;aple&quot;,&quot;Apple&quot;,&quot;Apple&quot;,&quot;apple&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109917_skateboard_ch0_16k.wav&quot;,&quot;skateboard&quot;,&quot;skateboard&quot;,&quot;skateboard&quot;,&quot;skateboard&quot;,&quot;Skateboard&quot;,&quot;skateboard&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109931_windows_ch0_16k.wav&quot;,&quot;windows&quot;,&quot;windows&quot;,&quot;windows&quot;,&quot;windows&quot;,&quot;Windows&quot;,&quot;windows&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109924_uniform_ch0_16k.wav&quot;,&quot;uniform&quot;,&quot;you know for him&quot;,&quot;youniform&quot;,&quot;uniform&quot;,&quot;Uniform&quot;,&quot;uniform&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109928_volcano_ch0_16k.wav&quot;,&quot;for kaino&quot;,&quot;volcano&quot;,&quot;full cano&quot;,&quot;volcano&quot;,&quot;Volcano&quot;,&quot;volcano&quot;,1.0,0.0,1.0,0.0,0.0,2.0],[&quot;109911_quartz_ch0_16k.wav&quot;,&quot;quartz&quot;,&quot;quartz&quot;,&quot;cuorts&quot;,&quot;forts&quot;,&quot;Quartz&quot;,&quot;quartz&quot;,0.0,0.0,1.0,1.0,0.0,2.0],[&quot;109916_rhinoceros_ch0_16k.wav&quot;,&quot;rhinoceros&quot;,&quot;rhinoceros&quot;,&quot;ri noseris&quot;,&quot;rhinoceros&quot;,&quot;Rhinoceros&quot;,&quot;rhinoceros&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109935_yacht_ch0_16k.wav&quot;,&quot;the ot&quot;,&quot;yeah  its&quot;,&quot;heoght&quot;,&quot;yacht&quot;,&quot;Yacht&quot;,&quot;yacht&quot;,1.0,1.0,1.0,0.0,0.0,3.0],[&quot;109883_hammer_ch0_16k.wav&quot;,&quot;hammer&quot;,&quot;hammer&quot;,&quot;hammer&quot;,&quot;hammer&quot;,&quot;Hammer&quot;,&quot;hammer&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109900_mouse_ch0_16k.wav&quot;,&quot;mouse&quot;,&quot;malice&quot;,&quot;nows&quot;,&quot;Mouse&quot;,&quot;Mouse&quot;,&quot;mouse&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109904_nutshell_ch0_16k.wav&quot;,&quot;nut shell&quot;,&quot;next show &quot;,&quot;not shell&quot;,&quot;nutshell&quot;,&quot;Nutshell&quot;,&quot;nutshell&quot;,1.0,1.0,1.0,0.0,0.0,3.0],[&quot;109913_question-mark_ch0_16k.wav&quot;,&quot;question mark&quot;,&quot;question mark&quot;,&quot;question mark&quot;,&quot;question mark&quot;,&quot;Question Mark&quot;,&quot;question mark&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109922_train_ch0_16k.wav&quot;,&quot;train&quot;,&quot;train&quot;,&quot;train&quot;,&quot;train&quot;,&quot;Train&quot;,&quot;train&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109932_xebec_ch0_16k.wav&quot;,&quot;z back&quot;,&quot;citibank&quot;,&quot;zeback&quot;,&quot;the back&quot;,&quot;Z back&quot;,&quot;xebec&quot;,1.0,1.0,1.0,1.0,1.0,5.0],[&quot;109919_star_ch0_16k.wav&quot;,&quot;star&quot;,&quot;star&quot;,&quot;star&quot;,&quot;star&quot;,&quot;Star&quot;,&quot;star&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109870_cow_ch0_16k.wav&quot;,&quot;cow&quot;,&quot;town&quot;,&quot;cow&quot;,&quot;cow&quot;,&quot;How&quot;,&quot;cow&quot;,0.0,1.0,0.0,0.0,1.0,2.0],[&quot;109896_leaf_ch0_16k.wav&quot;,&quot;leaf&quot;,&quot;leaf &quot;,&quot;leaf&quot;,&quot;leaf&quot;,&quot;Leave&quot;,&quot;leaf&quot;,0.0,0.0,0.0,0.0,1.0,1.0],[&quot;109899_mars_ch0_16k.wav&quot;,&quot;mars&quot;,&quot;maurice&quot;,&quot;mars&quot;,&quot;Mars&quot;,&quot;Mars&quot;,&quot;mars&quot;,0.0,1.0,0.0,0.0,0.0,1.0],[&quot;109906_orange_ch0_16k.wav&quot;,&quot;orange&quot;,&quot;orange&quot;,&quot;ornge&quot;,&quot;Orange&quot;,&quot;Orange&quot;,&quot;orange&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109923_umbrella_ch0_16k.wav&quot;,&quot;umbrella&quot;,&quot;umbrella&quot;,&quot;umbrella&quot;,&quot;umbrella&quot;,&quot;Umbrella&quot;,&quot;umbrella&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109912_queen_ch0_16k.wav&quot;,&quot;queen&quot;,&quot;queen&quot;,&quot;queen&quot;,&quot;Queen&quot;,&quot;Queen&quot;,&quot;queen&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109929_waffle_ch0_16k.wav&quot;,&quot;waffle&quot;,&quot;waffle&quot;,&quot;waffl&quot;,&quot;waffle&quot;,&quot;Waffle&quot;,&quot;waffle&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109867_butterfly_ch0_16k.wav&quot;,&quot;butterfly&quot;,&quot;butterfly&quot;,&quot;terfly&quot;,&quot;butterfly&quot;,&quot;Butterfly&quot;,&quot;butterfly&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109937_yarn_ch0_16k.wav&quot;,&quot;yarn&quot;,&quot;yeah lines&quot;,&quot;yan&quot;,&quot;yarn&quot;,&quot;Joan&quot;,&quot;yarn&quot;,0.0,1.0,1.0,0.0,1.0,3.0],[&quot;109898_lion_ch0_16k.wav&quot;,&quot;lion&quot;,&quot;lie in&quot;,&quot;lion&quot;,&quot;lion&quot;,&quot;Lion&quot;,&quot;lion&quot;,0.0,1.0,0.0,0.0,0.0,1.0],[&quot;109905_oars_ch0_16k.wav&quot;,&quot;worse&quot;,&quot;lawyers&quot;,&quot;or&quot;,&quot;ORS&quot;,&quot;Wars&quot;,&quot;oars&quot;,1.0,1.0,1.0,1.0,1.0,5.0],[&quot;109925_union_ch0_16k.wav&quot;,&quot;union&quot;,&quot;union&quot;,&quot;yunion&quot;,&quot;Union&quot;,&quot;Union&quot;,&quot;union&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109877_fire_ch0_16k.wav&quot;,&quot;fire&quot;,&quot;fire&quot;,&quot;fire&quot;,&quot;fire&quot;,&quot;Fire&quot;,&quot;fire&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109927_violin_ch0_16k.wav&quot;,&quot;violin&quot;,&quot;wyoming&quot;,&quot;sioin&quot;,&quot;violin&quot;,&quot;Violin&quot;,&quot;violin&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109918_spoon_ch0_16k.wav&quot;,&quot;spoon&quot;,&quot;spoon&quot;,&quot;spoon&quot;,&quot;spoon&quot;,&quot;Spoon&quot;,&quot;spoon&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109894_key_ch0_16k.wav&quot;,&quot;key&quot;,&quot;key&quot;,&quot;key&quot;,&quot;key&quot;,&quot;Key&quot;,&quot;key&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109863_ant_ch0_16k.wav&quot;,&quot;yet&quot;,&quot;and&quot;,&quot;ant&quot;,&quot;aunt&quot;,&quot;Yet&quot;,&quot;ant&quot;,1.0,1.0,0.0,1.0,1.0,4.0],[&quot;109884_helicopter_ch0_16k.wav&quot;,&quot;helicopter&quot;,&quot;helicopter&quot;,&quot;helocopter&quot;,&quot;helicopter&quot;,&quot;Helicopter&quot;,&quot;helicopter&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109933_xiphias_ch0_16k.wav&quot;,&quot;z fierce&quot;,&quot;fifty s&quot;,&quot;sif hes&quot;,&quot;xiphias&quot;,&quot;Ziff Ius&quot;,&quot;xiphias&quot;,1.0,1.0,1.0,0.0,1.0,4.0],[&quot;109888_iron_ch0_16k.wav&quot;,&quot;iron&quot;,&quot;i am and&quot;,&quot;arn&quot;,&quot;iron&quot;,&quot;Iron&quot;,&quot;iron&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109936_yak_ch0_16k.wav&quot;,&quot;yak&quot;,&quot;yeah&quot;,&quot;yeh&quot;,&quot;yak&quot;,&quot;Jack&quot;,&quot;yak&quot;,0.0,1.0,1.0,0.0,1.0,3.0],[&quot;109897_lemon_ch0_16k.wav&quot;,&quot;men&quot;,&quot;lenin&quot;,&quot;lemon&quot;,&quot;lemon&quot;,&quot;Lemon&quot;,&quot;lemon&quot;,1.0,1.0,0.0,0.0,0.0,2.0],[&quot;109875_egg_ch0_16k.wav&quot;,&quot;a good&quot;,&quot;a p&quot;,&quot;a&quot;,&quot;egg&quot;,&quot;Big&quot;,&quot;egg&quot;,1.0,1.0,1.0,0.0,1.0,4.0],[&quot;109921_tomato_ch0_16k.wav&quot;,&quot;tomato&quot;,&quot;tomato &quot;,&quot;to mateo&quot;,&quot;tomato&quot;,&quot;Tomato&quot;,&quot;tomato&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109907_owl_ch0_16k.wav&quot;,&quot;our&quot;,&quot;now on&quot;,&quot;ou&quot;,&quot;owl&quot;,&quot;How will&quot;,&quot;owl&quot;,1.0,1.0,1.0,0.0,1.0,4.0],[&quot;109873_duck_ch0_16k.wav&quot;,&quot;duck&quot;,&quot;doc&quot;,null,&quot;duck&quot;,&quot;Duck&quot;,&quot;duck&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109862_airplane_ch0_16k.wav&quot;,&quot;airplane&quot;,&quot;airplane&quot;,&quot;plane&quot;,&quot;airplane&quot;,&quot;Airplane&quot;,&quot;airplane&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109940_zucchini_ch0_16k.wav&quot;,&quot;zucchini&quot;,&quot;zucchini&quot;,&quot;sux keny&quot;,&quot;zucchini&quot;,&quot;Zucchini&quot;,&quot;zucchini&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109889_jacket_ch0_16k.wav&quot;,&quot;jacket&quot;,&quot;jackets&quot;,&quot;jacket&quot;,&quot;jackets&quot;,&quot;Jacket&quot;,&quot;jacket&quot;,0.0,1.0,0.0,1.0,0.0,2.0],[&quot;109880_galaxy_ch0_16k.wav&quot;,&quot;galaxy&quot;,&quot;galaxy&quot;,null,&quot;Galaxy&quot;,&quot;Galaxy&quot;,&quot;galaxy&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109910_pig_ch0_16k.wav&quot;,&quot;peak&quot;,&quot;panic&quot;,&quot;pick&quot;,&quot;Pig&quot;,&quot;Take&quot;,&quot;pig&quot;,1.0,1.0,1.0,0.0,1.0,4.0],[&quot;109882_glove_ch0_16k.wav&quot;,&quot;love&quot;,&quot;i love &quot;,&quot;love&quot;,&quot;glove&quot;,&quot;Love&quot;,&quot;glove&quot;,1.0,1.0,1.0,0.0,1.0,4.0],[&quot;109930_wallet_ch0_16k.wav&quot;,&quot;wallet&quot;,&quot;was it&quot;,&quot;wallet&quot;,&quot;wallet&quot;,&quot;Wallet&quot;,&quot;wallet&quot;,0.0,1.0,0.0,0.0,0.0,1.0],[&quot;109915_rain_ch0_16k.wav&quot;,&quot;mean&quot;,&quot;maine&quot;,&quot;rain&quot;,&quot;rain&quot;,&quot;Rain&quot;,&quot;rain&quot;,1.0,1.0,0.0,0.0,0.0,2.0],[&quot;109938_zebra_ch0_16k.wav&quot;,&quot;zebra&quot;,&quot;zebra&quot;,&quot;zebra&quot;,&quot;zebra&quot;,&quot;Zebra&quot;,&quot;zebra&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109893_kayak_ch0_16k.wav&quot;,&quot;kayak&quot;,&quot;kayak&quot;,&quot;kayk&quot;,&quot;kayak&quot;,&quot;Kayak&quot;,&quot;kayak&quot;,0.0,0.0,1.0,0.0,0.0,1.0],[&quot;109887_igloo_ch0_16k.wav&quot;,&quot;the glue&quot;,&quot;a clue&quot;,&quot;lue&quot;,&quot;igloo&quot;,&quot;Igloo&quot;,&quot;igloo&quot;,1.0,1.0,1.0,0.0,0.0,3.0],[&quot;109926_video-camera_ch0_16k.wav&quot;,&quot;video camera&quot;,&quot;video camera&quot;,&quot;fideo camera&quot;,&quot;video camera&quot;,&quot;Video camera&quot;,&quot;video camera&quot;,0.0,0.0,0.5,0.0,0.0,0.5],[&quot;109939_zero2_ch0_16k.wav&quot;,&quot;zero&quot;,&quot;zero&quot;,&quot;zero&quot;,&quot;zero&quot;,&quot;Zero&quot;,&quot;zero&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109914_rabbit_ch0_16k.wav&quot;,&quot;rabbit&quot;,&quot;maggots&quot;,&quot;rabbit&quot;,&quot;rabbit&quot;,&quot;Rabbit&quot;,&quot;rabbit&quot;,0.0,1.0,0.0,0.0,0.0,1.0],[&quot;109866_boat_ch0_16k.wav&quot;,&quot;boat&quot;,&quot;boat&quot;,&quot;o&quot;,&quot;boats&quot;,&quot;Vote&quot;,&quot;boat&quot;,0.0,0.0,1.0,1.0,1.0,3.0],[&quot;109872_dog_ch0_16k.wav&quot;,&quot;dog&quot;,&quot;dog&quot;,&quot;dog&quot;,&quot;dog&quot;,&quot;Dog&quot;,&quot;dog&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109934_xylophone_ch0_16k.wav&quot;,&quot;xylophone&quot;,&quot;silent &quot;,&quot;zi o phone&quot;,&quot;xylophone&quot;,&quot;Xylophone&quot;,&quot;xylophone&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109909_pen_ch0_16k.wav&quot;,&quot;penn&quot;,&quot;palin&quot;,&quot;pen&quot;,&quot;pain&quot;,&quot;Pen&quot;,&quot;pen&quot;,1.0,1.0,0.0,1.0,0.0,3.0],[&quot;109895_king_ch0_16k.wav&quot;,&quot;king&quot;,&quot;king&quot;,&quot;king&quot;,&quot;King&quot;,&quot;King&quot;,&quot;king&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109876_elephant_ch0_16k.wav&quot;,&quot;elephant&quot;,&quot;elephants&quot;,&quot;ant&quot;,&quot;elephant&quot;,&quot;Elephant&quot;,&quot;elephant&quot;,0.0,1.0,1.0,0.0,0.0,2.0],[&quot;109892_juice_ch0_16k.wav&quot;,&quot;juice&quot;,&quot;she reads the&quot;,&quot;hoose&quot;,&quot;shoes&quot;,&quot;Juice&quot;,&quot;juice&quot;,0.0,1.0,1.0,1.0,0.0,3.0],[&quot;109871_daisy_ch0_16k.wav&quot;,&quot;daisy&quot;,&quot;daisy&quot;,&quot;y&quot;,&quot;Daisy&quot;,&quot;Easy&quot;,&quot;daisy&quot;,0.0,0.0,1.0,0.0,1.0,2.0],[&quot;109903_neptune_ch0_16k.wav&quot;,&quot;neptune&quot;,&quot;neptune&quot;,&quot;neptune&quot;,&quot;Neptune&quot;,&quot;Neptune&quot;,&quot;neptune&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109878_fork_ch0_16k.wav&quot;,&quot;for&quot;,&quot;fork&quot;,&quot;for&quot;,&quot;Fork&quot;,&quot;Fork&quot;,&quot;fork&quot;,1.0,0.0,1.0,0.0,0.0,2.0],[&quot;109890_jaguar_ch0_16k.wav&quot;,&quot;jag you are&quot;,&quot;jake you are&quot;,&quot;jakyu are&quot;,&quot;Jaguar&quot;,&quot;Shake. You are&quot;,&quot;jaguar&quot;,1.0,1.0,1.0,0.0,1.0,4.0],[&quot;109901_mushroom_ch0_16k.wav&quot;,&quot;mushroom&quot;,&quot;mushroom&quot;,&quot;mushroom&quot;,&quot;mushroom&quot;,&quot;Mushroom&quot;,&quot;mushroom&quot;,0.0,0.0,0.0,0.0,0.0,0.0],[&quot;109908_paint_ch0_16k.wav&quot;,&quot;paint&quot;,&quot;paint&quot;,&quot;paint&quot;,&quot;paint&quot;,&quot;Paint&quot;,&quot;paint&quot;,0.0,0.0,0.0,0.0,0.0,0.0]]
    }).render(document.getElementById(&quot;wrapper&quot;));
  &lt;/script&gt;

&lt;p&gt;Something interesting to note, all ASRs mistranscribed the WAVs “xebec” and “oars”.&lt;/p&gt;

&lt;p&gt;There were many words that ALL ASRs got correct e.g. “class”, “camera”, “nail”, “skateboard”, “windows”, and “hammer”.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;6-conclusion&quot;&gt;6. Conclusion&lt;/h2&gt;

&lt;p&gt;In summary, after transcription corrections for each ASR output, the following are the results.&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;img-fluid&quot; src=&quot;../../../../public/images/210904_benchmark_wer.png&quot; alt=&quot;wer&quot; width=&quot;650&quot; /&gt;&lt;/p&gt;

&lt;div id=&quot;wrapper2&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    new gridjs.Grid({
      columns: [&quot;ASR&quot;, &quot;Type&quot;, &quot;Mean WER&quot;],
      sort: true,
      pagination: false,
      data: [
        [&quot;Vosk (vs)&quot;, &quot;Offline - Docker&quot;, &quot;0.23&quot;],
        [&quot;Sphinx (sp)&quot;, &quot;Offline - Docker&quot;, &quot;0.47&quot;],
        [&quot;Coqui (cq)&quot;, &quot;Offline - Docker&quot;, &quot;0.53&quot;],
        [&quot;GoogleASR (gg)&quot;, &quot;API&quot;, &quot;0.10&quot;],
        [&quot;AWSTranscribe (aw)&quot;, &quot;API&quot;, &quot;0.21&quot;]
      ]
    }).render(document.getElementById(&quot;wrapper2&quot;));
  &lt;/script&gt;

&lt;p&gt;&lt;br /&gt;
Overall the results are somewhat expected. CloudASRs tend to dominate, with VOSK being very good modern alternative. Coqui had
surprisingly bad results but it is expected to do better on longer sentences or with a customized language model.&lt;/p&gt;

&lt;p&gt;For the next tests, we will attempt to tune each for the above dataset (where possible). As well as
trying on everyone’s favourite opensource dataset…!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Introducing SpeechLoop</title>
   <link href="https://robmsmt.github.io/2021/08/14/introducing-speechloop/"/>
   <updated>2021-08-14T00:00:00+00:00</updated>
   <id>https://robmsmt.github.io/2021/08/14/introducing-speechloop</id>
   <content type="html">&lt;p&gt;Here is a &lt;a href=&quot;https://github.com/robmsmt/SpeechLoop&quot;&gt;tool&lt;/a&gt; developed to evaluate multiple ASR (automatic speech recognition) engines and benchmark them to help answer the question, what is the best ASR for my dataset?&lt;/p&gt;

&lt;h2 id=&quot;the-problems&quot;&gt;The Problem(s)&lt;/h2&gt;

&lt;p&gt;Every time an ASR is released, commercial or otherwise, it often comes with a claim that they are the best.&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;img-fluid&quot; src=&quot;../../../../public/images/best_diner.jpg&quot; alt=&quot;best-diner&quot; width=&quot;700&quot; /&gt;
It’s a very difficult claim to substantiate. How do they know they’re the best? Maybe they’ve publicly benchmarked? Sometimes they release a vague chart with cherry picked results.
Other times there’s a more detailed study. But still it’s hard to believe that the person doing the benchmarking is likely to report findings that show their ASR in a bad light.&lt;/p&gt;

&lt;p&gt;Progress in the ML space moves very quickly. Overnight a new model is trained.
What about the papers last year with the new dizzying end-2-end-2-end with mega-transformers? and with guest appearances from all your favourite childhood tv-shows. Were these compared?
It can be difficult to keep track, plus you don’t want to keep hitting your competitors’ ASR all the time - this takes time away from R&amp;amp;D.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;i&gt;One can judge from experiment, or one can blindly accept authority.&lt;/i&gt;
&lt;br /&gt;Robert A. Heinlein&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is one of the reasons why SpeechLoop was developed.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;design-decisions&quot;&gt;Design Decisions&lt;/h2&gt;
&lt;p&gt;The following were some design decisions made while developing SpeechLoop:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Easy to use with sensible defaults&lt;/strong&gt; - following the “for humans” philosophy that other python packages have popularized.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Heavy use of docker where required&lt;/strong&gt; - Docker completely solves the issue of having to install big and heavily conflicting libraries, some of which are only needed for the
install part of the process. If you have a reasonable amount of disk space and any x86_64 cpu you can go quite far with just sending bytes to an already built container.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Limited number of 3rd party dependencies&lt;/strong&gt; - this can be a challenge when installing a library, the more packages there are, the more that can go wrong.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Pandas Dataframes&lt;/strong&gt; - for easy analysis and simple WER calculation… the dataframe felt like the best fit where each row corresponds to an audio file and each ASR transcript would be a column.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;features&quot;&gt;Features&lt;/h2&gt;
&lt;p&gt;There are many features to list, but a video of simple usage will be even more useful.&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;img-fluid&quot; src=&quot;../../../../public/images/cli_fast.gif&quot; alt=&quot;cli&quot; width=&quot;700&quot; /&gt;
Here we demonstrate using the CLI to record microphone and pipe the data into the selected 3 ASRs.&lt;/p&gt;

&lt;video style=&quot;display:block; width:700px; height:auto;&quot; autoplay=&quot;&quot; controls=&quot;&quot; loop=&quot;loop&quot;&gt;
           &lt;source src=&quot;../../../../public/images/cli_testwavs.webm&quot; type=&quot;video/webm&quot; /&gt;
 &lt;/video&gt;
&lt;p&gt;Above we run the CLI to evaluate against the included test dataset. It outputs a CSV. Below is a copy of the output text - following blogposts will focus on ASR results themselves.&lt;/p&gt;
&lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;------------------------------
Average value of vs_corrected_wer is 0.2308

------------------------------
Average value of sp_corrected_wer is 0.5128

------------------------------
Average value of cq_corrected_wer is 0.5513

Total inference time taken for vs is 0:01:15.081824
Total inference time taken for sp is 0:00:42.342496
Total inference time taken for cq is 0:01:27.646377
------------------------------
------------------------------
Finished, with total runtime: 0:03:42
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img class=&quot;img-fluid&quot; src=&quot;../../../../public/images/calc.png&quot; alt=&quot;cli&quot; width=&quot;700&quot; /&gt;
Often it’s good to load the CSV in excel-like tools to quickly skim the results. For anything more advanced a jupyter notebook might be the way to go.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;future&quot;&gt;Future&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Different data formats (e.g. Kaldi has SCP, it would be nice to read those)&lt;/li&gt;
  &lt;li&gt;Cost calculator for APIs&lt;/li&gt;
  &lt;li&gt;More ASRs&lt;/li&gt;
  &lt;li&gt;Automated benchmarks of common datasets - for example librispeech or one of the &lt;a href=&quot;https://github.com/robmsmt/ASR-Audio-Data-Links/#1-free&quot;&gt;newly released huge datasets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;thanks&quot;&gt;Thanks&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Thanks to all ASRs - this tool just builds on top of others work. Without them it wouldn’t make sense.&lt;/li&gt;
  &lt;li&gt;My employer &lt;a href=&quot;https://www.merlyn.org&quot;&gt;MerlynMind&lt;/a&gt; who have actively encouraged this work - note that we are currently hiring for many roles.&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>Audio from inside a Pandas Dataframe in a Jupyter Notebook</title>
   <link href="https://robmsmt.github.io/2021/01/29/jupyter-audio-pandas/"/>
   <updated>2021-01-29T00:00:00+00:00</updated>
   <id>https://robmsmt.github.io/2021/01/29/jupyter-audio-pandas</id>
   <content type="html">&lt;p&gt;Jupyter notebooks are fantastic tools to explore data. You can also play audio within them.&lt;/p&gt;

&lt;div class=&quot;message&quot;&gt;
  In order to make ASR better you often have to review and listen to many audio files.
  One great way I've found to do this is through a Pandas dataframe in a Jupyter notebook.
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;../../../../public/images/audio_play.png&quot; alt=&quot;image of commandline&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As you can see from the picture above, it keeps the audio component hidden until you click on the wav
filename which triggers some javascript to make the audio HTML components visible. Kinda neat.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Within Jupyter notebooks you can use the &lt;a href=&quot;https://ipython.readthedocs.io/en/stable/interactive/magics.html#cellmagic-html&quot;&gt;magic tags&lt;/a&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%%html&lt;/code&gt; in which are you able to define some javascript and CSS. See segment below:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;%%html
&lt;span class=&quot;nt&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;toggle_visibility&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;display&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;display&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
          &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;display&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;.filenameclass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nl&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;pointer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;nl&quot;&gt;text-decoration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;blue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;nl&quot;&gt;text-underline-position&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;under&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;nl&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;blue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;audio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nl&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;200px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Next we just need to define a function for creating the HTML with the new audio widget in, this takes a path and returns some HTML with a special unique ID we can use to identify the component:&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;path_to_audio_html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;myuuid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'x'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uuid4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())[:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rsplit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'/'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'''
    &amp;lt;div&amp;gt;
        &amp;lt;div class='filenameclass' onclick=&quot;toggle_visibility(&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;myuuid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;)&quot;&amp;gt;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;lt;/div&amp;gt;
        &amp;lt;div id=&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;myuuid&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; style=&quot;display:none;&quot;&amp;gt;
            &amp;lt;audio controls&amp;gt;
              &amp;lt;source src=&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; type=&quot;audio/wav&quot; preload=&quot;none&quot;&amp;gt;
                Your browser does not support the audio element.
            &amp;lt;/audio&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    '''&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Assuming we already have a dataframe (with column to filepath), we just need to call the HTML function from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IPython.core.display&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;HTML&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;escape&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;formatters&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path_to_audio_html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;../../../../public/images/audio_play2.png&quot; alt=&quot;image of commandline&quot; /&gt;
&lt;img src=&quot;../../../../public/images/audio_play3.png&quot; alt=&quot;image of commandline&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;ideas&quot;&gt;Ideas&lt;/h2&gt;

&lt;p&gt;It’s interesting where this could lead to, could a more powerful javascript player be used?
Or could this even be used for a basic transcription service with a text field to correct or save the annotation?&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/robmsmt/SpeechLoop/blob/master/notebooks/play_audio_in_df.ipynb&quot;&gt;Link&lt;/a&gt; to the full jupyter notebook code&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>Bash Tricks</title>
   <link href="https://robmsmt.github.io/2021/01/22/bashrc/"/>
   <updated>2021-01-22T00:00:00+00:00</updated>
   <id>https://robmsmt.github.io/2021/01/22/bashrc</id>
   <content type="html">&lt;p&gt;One of the great things about bash is just how flexible and configurable it is. In this post I’ll explain some changes that I use frequently.&lt;/p&gt;

&lt;div class=&quot;message&quot;&gt;
  This is the first blog post. 🎉
&lt;/div&gt;

&lt;p&gt;This post is mostly for my own benefit, so I can quickly copy these configs onto a new machine and see how the layout styling works.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;As a general rule I try not install any packages/plugins or anything which pushes you too far from the stock setup… e.g. zsh!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;bash-changes&quot;&gt;Bash Changes&lt;/h2&gt;

&lt;p&gt;Here are the changes I have made to my config in order of most important.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;git-branch-highlighting&quot;&gt;Git Branch Highlighting&lt;/h3&gt;

&lt;p&gt;I find knowing that I am in a git repo one of the most important pieces of information. On top of that it will tell me what branch I am on. This was inspired by the &lt;a href=&quot;https://www.shellhacks.com/show-git-branch-terminal-command-prompt&quot;&gt;following post&lt;/a&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# git branches&lt;/span&gt;
git_branch&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  git branch 2&amp;gt; /dev/null | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'/^[^*]/d'&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'s/* \(.*\)/(\1)/'&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;PS1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PS1&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\[\0&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;33[00;31m&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\]\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;(git_branch)&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\[\0&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;33[00m&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\]\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;img src=&quot;../../../../public/images/git_branch.png&quot; alt=&quot;image of commandline&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;speed-aliases&quot;&gt;Speed Aliases&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# speed&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;ve&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;virtualenv --python=python3.8 ./venv/py38 &amp;amp;&amp;amp; source ./venv/py38/bin/activate&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;qg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;git add . &amp;amp;&amp;amp; git commit -m 'quick commit' &amp;amp;&amp;amp; git push origin&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;gs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;git status&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;rl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;readlink -f&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;gf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'git flow'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ve&lt;/code&gt; Typing this in any repo will generate a virtualenv and source it automatically. I use this all the time and is great when experimenting and exploring github repos. Virtualenv is supposed to be replaced now with venv.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;qg&lt;/code&gt; Stands for quick git. It’s ruining the git commit messages but it assumes you’ll squash later. Also it’s risky-ish since it’s adding everything with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git add .&lt;/code&gt; but each to their own.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs&lt;/code&gt; Stands for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git status&lt;/code&gt;. Used in conjunction with #2. There is already a program in called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gs&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/bin&lt;/code&gt; something to do with pdfs, i’ve never used before. Apparently if you want to not use the alias you can easily skip by escaping… so &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\gs&lt;/code&gt; will return the Ghost shell.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rl&lt;/code&gt; When working with a team it’s great to send them the exact full path of the file. I use it so often and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;readlink -f&lt;/code&gt; takes too long.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gf&lt;/code&gt; Useful if you use &lt;a href=&quot;http://danielkummer.github.io/git-flow-cheatsheet/&quot;&gt;gitflow&lt;/a&gt;. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gf init&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;audio-aliases&quot;&gt;Audio Aliases&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# audio&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;wavcount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;find -type f -name '*.wav' -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2&amp;gt;/dev/null | perl -nle '/ID_LENGTH=([0-9&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;]+)/ &amp;amp;&amp;amp; (&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;t +=&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;1) &amp;amp;&amp;amp; printf &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;%02d:%02d:%02d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;t/3600,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;t/60%60,&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\$&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;t%60' | tail -n 1&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wavcount&lt;/code&gt; Counts the number of hours:mins:secs of audio data is in a directory recursively.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rob@rob-T480s:~/projects/audio &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;master&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;wavcount
06:49:34
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;
&lt;h3 id=&quot;android-changes&quot;&gt;Android Changes&lt;/h3&gt;

&lt;p&gt;When I work on Android, I find the following are useful. The first is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aver&lt;/code&gt; which is a special alias which is exported so that it can take advantage of using a variable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$1&lt;/code&gt; in the middle of the command.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# android specific&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;aver &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; aapt dump badging &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;versionName&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; aver
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;sy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'watch -n 2 scrcpy -m 1024 --always-on-top'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aver&lt;/code&gt; - Stands for APK version. I can run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;aver apk_name.apk&lt;/code&gt; it prints the APK version information using the aapt tool.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rob@rob-T480s:~/$ aver spotify.apk
package: name='com.spotify.music' versionCode='65804403' versionName='8.5.82.894' platformBuildVersionName=''
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sy&lt;/code&gt; - Scrcpy (presumably pronounced Screencopy) is a great tool to see the android interface on your machine. The command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sy&lt;/code&gt; starts &lt;a href=&quot;https://github.com/Genymobile/scrcpy&quot;&gt;scrcpy&lt;/a&gt; with watch -n 2 which will try to restart it every 2 secs as soon as it ends. Useful for development purposes.&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;which-bash-configuration-file-to-use&quot;&gt;Which bash configuration file to use?&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;To .bashrc or .profile? That is the question.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.profile&lt;/code&gt; is executed on startup only. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; is executed every time you open a new terminal. I generally use .bashrc since I think it’s more common. I also put the following snippet into my code so I can test when each gets executed. I put this in both &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; and inside &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.profile&lt;/code&gt; just append it to the end.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;# this prints an echo every time the script is executed (useful to know)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;readlink&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;BASH_SOURCE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[0]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$self&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$basename&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; was executed&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rob@rob-T480s:~/projects/blog/github.io (master)$ source ~/.profile
.bashrc was executed
.profile was executed
rob@rob-T480s:~/projects/blog/github.io (master)$ source ~/.bashrc
.bashrc was executed
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;useful-crontabs&quot;&gt;Useful crontabs&lt;/h2&gt;

&lt;p&gt;I want to purge my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/Downloads&lt;/code&gt; folder for files and directories older than 15 days, but I want to send them to the Trash instead. The trash I want to empty at a longer every 180 days automatically on reboot only.&lt;/p&gt;

&lt;p&gt;User: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;crontab -e&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;0 0 &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; find /home/username/Downloads/ &lt;span class=&quot;nt&quot;&gt;-mindepth&lt;/span&gt; 1 &lt;span class=&quot;nt&quot;&gt;-mtime&lt;/span&gt; +15 &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; gio trash &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Root: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo crontab -e&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@reboot find /home/username/.local/share/Trash/expunged/ &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-mtime&lt;/span&gt; +180 &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
@reboot find /home/username/.local/share/Trash/files/ &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-mtime&lt;/span&gt; +180 &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
@reboot find /home/username/.local/share/Trash/info/ &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; f &lt;span class=&quot;nt&quot;&gt;-mtime&lt;/span&gt; +180 &lt;span class=&quot;nt&quot;&gt;-exec&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</content>
 </entry>
 

</feed>
