dlpy.audio.AudioTable.load_audio_files¶
-
classmethod
AudioTable.
load_audio_files
(conn, path=None, casout=None, caslib=None, local_audio_path=None, server_audio_path=None, as_specgram=False, label_level=0)¶ Load audio files from path
Parameters: - conn : CAS
CAS connection object
- path : string, optional
Path to the audio listing file. This path must user the server-side style and can be access by the server.
- casout : dict, string, or CASTable, optional
The output CAS table specification
- caslib : string, optional
The caslib to load audio files from
- local_audio_path : string, optional
The local location that contains all the audio files. This path is on the client side and is host-dependent and must be accessible on the server side. When this path is specified, the path option will be ignored. All the audio files that are supported by soundfile will be first converted into the wave files (i.e., 1 channel, 16 bits, 16K Hz) and then will be loaded into the server. When caslib is specified, the contents under local_audio_path must be accessible with the given caslib. When caslib is None, server_audio_path (if specified) will be used to check whether any existing caslib on the server can be mapped back to local_audio_path and to create the caslib. If no caslib can be found, a new caslib with a random name will be generated with local_audio_path. This option requires VDMML 8.5 at least.
- server_audio_path : string, optional
The server location that contains all the audio files. Both local_audio_path and server_audio_path point to the same physical location. They could be same if the client and server run on the same machine. When caslib is specified, the server_audio_path option will be ignored. When caslib is None and the existing caslibs on the server contain the server_audio_path, the corresponding caslib will be used. Otherwise, a caslib with a random name will be created.
- as_specgram: bool, optional
when True, the audio files under local_audio_path will be converted into PNG files that contain spectrograms and will be loaded as images into the server.
Default: False- label_level : optional
Specifies which path level should be used to generate the class labels for each image when as_specgram is True. For instance, label_level = 1 means the first directory and label_level = -2 means the last directory. This internally use the SAS scan function (check https://www.sascrunch.com/scan-function.html for more details). In default, no class labels are generated. If the label column already exists, this option will be ignored.
Default: 0
Returns: - AudioTable or `ImageTable`
If audio files are found, return AudioTable. When as_specgram is True, return ImageTable
- None
If no audio files are found
Examples
>>> import swat >>> from dlpy.audio import AudioTable >>> s=swat.CAS("cloud.example.com", 5570) >>> aud_table = AudioTable.load_audio_files(s, "/path/to/audio/file.txt")