Giter Site home page Giter Site logo

parse-pause's Introduction

parse-pause

Detect chapters and parts based on iso8601-durations in an xml-file.

Clone repo and open a terminal window at the top of the source folder. Then build and run the application.

$ cargo build

$ ./target/debug/parse-pause -f pause.xml -c 4 -p 1 -s 220

Duration as parameters is in seconds. Internally it is using milliseconds.

It reads the xml-file, add from and until into a struct which is then pushed to a vector. This vector is traversed and length of a spoken part is derived from the silent parts and put in another struct, along with the silence-duration that immediately follows and pushed to another vector. This vector is traversed and when a chapter or part occurs based on command line input put to a third struct and vector. Then traversed and print json (handcoded) to stdout.

Input:

<?xml version="1.0" encoding="UTF-8"?>  
<silences>  
    <silence from="PT1M44.025S" until="PT1M44.914S" />  
    <silence from="PT3M39.714S" until="PT3M40.251S" />  
    <silence from="PT5M58.959S" until="PT6M0.988S" />  
    <silence from="PT7M32.452S" until="PT7M34.431S" />  
</silences>

Output:

{
  "segments": [
    {
      "title": "Chapter 1, part 1",
      "offset": "PT0.000S",
      "part_duration": "PT3M40.250S",
      "chapter_duration": "PT34M13.082S"
    },
    {
      "title": "Chapter 1, part 2",
      "offset": "PT3M40.250S",
      "part_duration": "PT2M20.738S",
      "chapter_duration": "PT34M13.082S"
    },
    {
      "title": "Chapter 1, part 3",
      "offset": "PT6M0.988S",
      "part_duration": "PT1M33.443S",
      "chapter_duration": "PT34M13.082S"
    }
  ]
}

parse-pause's People

Contributors

kometen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.