GithubHelp home page GithubHelp logo

Comments (5)

pzelasko avatar pzelasko commented on September 7, 2024

Regarding subests of channels - it's already supported, note the test_get_audio_multichannel - I'll document it better. I elaborated more in issue #4

Regarding the raw-PCM thing: I think if there is any common/universal format it would probably be wav, not raw pcm, as raw pcm is too easy to get wrong (no error if wrong format).

That's just for the command type of input, where we could always place sox at the end of the pipe to convert practically anything to PCM, and it is very easy to load with numpy as it's just a cast of binary buffer to int16. But we can make it work with wav too I guess.

I didn't really understand the AudioSource code well as your Python style is very modern... e.g. no init function.

Alright, let me elaborate on that. Python 3.7 introduced dataclass, based on attrs library. It basically reduces the amount of boilerplate code you need to write. You can specify the members similarly as in C++, e.g.:

@dataclass
class Foo:
  x: int
  y: List[str]

and it automatically creates default __init__, __eq__, __repr__, and can also create comparison operators, __hash__, or impose immutability with extra arguments to dataclass. The __init__ would look something like:

def __init__(self, x: int, y: List[str]):
  self.x = x
  self.y = y
  self.__post_init__()

It also provides a method asdict which can convert a dataclass into a nice dictionary, making serialization very easy (notice the code is quite terse for what it does). There's a __post_init__ that's automatically called in the auto-generated constructor, it allows you to customize __init__ without having to write the boilerplate.

Also, I find the typing module extremely useful for static code analysis and improving documentation. List[int] type means the variable will be a list of int, Optional means it can be None, Union[int, str] means it can be either an int or str.

from lhotse.

csukuangfj avatar csukuangfj commented on September 7, 2024

Alright, let me elaborate on that. Python 3.7 introduced dataclass

The users of this library are forced to use Python 3.7. If some of them do not have
sudo permission, they will have difficulties upgrading their python version to 3.7

from lhotse.

danpovey avatar danpovey commented on September 7, 2024

Mm. My feeling is the python3.7 thing may be OK... this is a rather forward-looking project, and my feeling is enough people have python3.7 (or could install it in user-space).
If it's a problem later we can always change the code, but for now I don't want to slow this project down by worrying too much about such thigns.

from lhotse.

pzelasko avatar pzelasko commented on September 7, 2024

from lhotse.

jtrmal avatar jtrmal commented on September 7, 2024

from lhotse.

Related Issues (20)

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.