Skip to content

Instantly share code, notes, and snippets.

@xatier
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save xatier/f2671dea9b7f1aaea12b to your computer and use it in GitHub Desktop.

Select an option

Save xatier/f2671dea9b7f1aaea12b to your computer and use it in GitHub Desktop.

Revisions

  1. xatier revised this gist Apr 9, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion oxford.pl
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@
    ##
    ## a little script to grab pronunciations from Oxford online dictionary
    ##
    ## Usage: ./oxford.pl meteorological
    ## Usage: ./oxford meteorological
    ##
    ## Author: @xatierlikelee
    ## License: GPL
  2. xatier revised this gist Apr 9, 2015. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions oxford.pl
    Original file line number Diff line number Diff line change
    @@ -34,3 +34,12 @@

    say "=> http://www.oxforddictionaries.com/definition/american_english/$word";
    system "mplayer -really-quiet -nolirc -user-agent chrome -prefer-ipv4 $base$query";

    =foo
    $ oxford meticulous
    => http://www.oxforddictionaries.com/definition/american_english/meticulous
    $ oxford fledgling
    => http://www.oxforddictionaries.com/definition/american_english/fledgling
    $ oxford egoism
    => http://www.oxforddictionaries.com/definition/american_english/egoism
    =cut
  3. xatier created this gist Apr 9, 2015.
    36 changes: 36 additions & 0 deletions oxford.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/usr/bin/env perl

    use 5.018;

    #####################################################
    ##
    ## How does Oxford pronounce the word
    ##
    ## a little script to grab pronunciations from Oxford online dictionary
    ##
    ## Usage: ./oxford.pl meteorological
    ##
    ## Author: @xatierlikelee
    ## License: GPL
    ######################################################
    #
    # the uri of the pronunciation should be like this:
    #
    # http://www.oxforddictionaries.com/media/american_english/us_pron/e/ent/entre/entrepreneur__us_2.mp3
    # http://www.oxforddictionaries.com/media/american_english/us_pron/r/rem/remon/remonstrate__us_1.mp3
    # http://www.oxforddictionaries.com/media/american_english/us_pron/l/lau/laud_/laud__us_1.mp3
    #
    # note, there're still some exceptions don't follow the above format :(

    my $base = "http://www.oxforddictionaries.com/media/american_english/us_pron/";

    my $word = $ARGV[0];

    my $query = (join "/", ((substr $word, 0, 1),
    (substr $word, 0, 3),
    (length $word < 5 ? $word . "_"x(5 - length $word) :
    substr $word, 0, 5),
    $word)) . "__us_1.mp3";

    say "=> http://www.oxforddictionaries.com/definition/american_english/$word";
    system "mplayer -really-quiet -nolirc -user-agent chrome -prefer-ipv4 $base$query";