Coder Social home page Coder Social logo

torchhtk's Introduction

torch-htk

This project provides a simple api to load and save HTK features.

This library is so far only tested on linux, thus there is no guarantee for Wind and OSX!

Prequisites

  • Torch is the only prequisite for this library.

Installation

The most convinient way is to reach this repository over luarocks.

luarocks install torchhtk

If that is not possible, do it manually:

git clone https://github.com/RicherMans/torchhtk
cd torchhtk
luarocks make rocks/torchhtk-scm-1.rockspec

Methods and classes

  • [header] loadheader( filepath [string]) : Loads only the header of the specified filepath. No extra memory is allocated or data loaded.
  • [torch.FloatTensor] load(filepath [string]) : Loads the data from the given filepath. Returns a torch.FloatTensor which dimensions are nsamples * featuredim.
  • write( filepath [string], data [torch.FloatTensor], featuretype [string]) : Writes out an htk file. data specifies the vector which should be written out with sizes nsampels * featuredim. featuretype needs to be one of the known HTK types, e.g. PLP_0 or for any default data, simply use USER.
  • loadsample(filepath[string], sample [number]) Loads only a given sample from the provided file. This method is generally less efficient than load, if one wants to load in the whole file at once, but more efficient if only single samples are needed.

Usage

To read HTK files simply use the provided API.

local htkutils = require 'torchhtk'
-- Only loads the header of a file
local header = htkutils.loadheader('feature.plp')
print(header) -- prints number of samples and other information
-- Returns a torch.FloatTensor()
local tensor = htkutils.load('feature.plp')
-- Loads only the first sample in (instead of the whole utterance)
local sample = htkutils.loadsample('feature.plp',1)

To write files ( note that we only support torch.FloatTensor ):

require 'torch'
local htkutils = require 'torchhtk'

local size = 50000
local dim = 4
local tensor = torch.FloatTensor(size,dim)
for i=1,size do
    tensor[i]:fill(i)
end
-- Outputfile should be named feature.plp
-- Featuretype is set to be PLP
htkutils.write("feature.plp",tensor,"PLP")

torchhtk's People

Contributors

richermans avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

q121q

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.