Support for representation classes that instantiate the object when calling the construvtor
Normally, when we want to instantiate a class in python or any other object oriented laguange we simply have to call the class constructor as in:
our_obj = Our_class(whatever_arguments)
And that is it.
With ketos audio_representation, this is not the case. We have a number of different ways to create the object depending on the type of data we have, which makes things confusing in my opinion.
For instance, if we have the data array we call the constructor. If we have the waveform loaded already, we call the from_waveform method. And if we have the audio file we call the from_wav method instead. While this works, I think since we dont have many different ways of creating the object, we should group everything with the constructor. And the constructor should decide how to handle it. For instance how pandas deal with csv. the filepath_or_buffer argument allows you to pass either a data buffer or a string with a path an the function takes it from there and decide what to do with the argument and how to load the data.
The advantage of using such an approach is that we can standardize how representations are create accross the code. for instance, the load_audio function calls the constructor while the create_database
function eventually calls the from_wav
method.
The problem here is that someone implementing a new representation effectively has to create all these different methods to handle all the different ways we initialize representations. Furthermore, if they dont know ketos inner-workings, it becomes hard to predict what methods are mandatory to create. If we standardize this process, than we have to create just a constructor to handle the different ways to handle the data. And the reason i favor a constructor rather then a method is because that is the standard way of creating objects and people are already familiar with the process.
In addition, this doesnt exclude the other functions such as from_waveform and from_wav from existing if we deem it necessary. They just become an alternative, and backwards compatible. But we would start favouring using just the constructor.
tldr; Support for representation classes that create the representation when you instantiate the class