voxseg_/utils.py
def read_sigs(data: pd.DataFrame) -> pd.DataFrame:
    '''Reads audio signals from a pd.DataFrame containing the directories of
    .wav files, and optionally start and end points within the .wav files. 

    Args:
        data: A pd.DataFrame created by prep_data().

    Returns:
        A pd.DataFrame with columns 'recording-id' and 'signal', or if segments were provided
        'utterance-id' and 'signal'. The 'signal' column contains audio as np.ndarrays.

    Raises:
        AssertionError: If a wav file is not 16k mono.
    '''

    wavs = {}
    ret = []
    for i, j in zip(data['recording-id'].unique(), data['extended filename'].unique()):
        rate, wavs[i] = wavfile.read(j)
        #assert rate == 16000 and wavs[i].ndim == 1, f'{j} is not formatted in 16k mono.'
        assert wavs[i].ndim == 1, f'{j} is not formatted in mono.'
        logging.info("File: {}\tlength: {}\tsampling rate: {}".format(j, len(wavs[i]), rate))
        
    if 'utterance-id' in data:
        for _, row in data.iterrows():
            ret.append([row['utterance-id'], wavs[row['recording-id']][int(float(row['start']) * rate): int(float(row['end']) * rate)]])
        return (rate, pd.DataFrame(ret, columns=['utterance-id', 'signal']))
    else:
        for _, row in data.iterrows():
            ret.append([row['recording-id'], wavs[row['recording-id']]])
        return (rate, pd.DataFrame(ret, columns=['recording-id', 'signal']))
Reads audio signals from a pd.DataFrame containing the directories of
    .wav files, and optionally start and end points within the .wav files. 

    Args:
        data: A pd.DataFrame created by prep_data().

    Returns:
        A pd.DataFrame with columns 'recording-id' and 'signal', or if segments were provided
        'utterance-id' and 'signal'. The 'signal' column contains audio as np.ndarrays.

    Raises:
        AssertionError: If a wav file is not 16k mono.
    
Reads audio signals from a pd.DataFrame containing the directories of
.wav files, and optionally start and end points within the .wav files.
Reads audio signals from a pd . DataFrame containing the directories of . wav files and optionally start and end points within the . wav files .
def read_sigs(data: pd.DataFrame) -> pd.DataFrame:
    wavs = {}
    ret = []
    for i, j in zip(data['recording-id'].unique(), data['extended filename'].unique()):
        rate, wavs[i] = wavfile.read(j)
        assert wavs[i].ndim == 1, f'{j} is not formatted in mono.'
        logging.info("File: {}\tlength: {}\tsampling rate: {}".format(j, len(wavs[i]), rate))
    if 'utterance-id' in data:
        for _, row in data.iterrows():
            ret.append([row['utterance-id'], wavs[row['recording-id']][int(float(row['start']) * rate): int(float(row['end']) * rate)]])
        return (rate, pd.DataFrame(ret, columns=['utterance-id', 'signal']))
    else:
        for _, row in data.iterrows():
            ret.append([row['recording-id'], wavs[row['recording-id']]])
        return (rate, pd.DataFrame(ret, columns=['recording-id', 'signal']))
def read_sigs ( data : pd . DataFrame ) -> pd . DataFrame : wavs = { } ret = [ ] for i , j in zip ( data [ 'recording-id' ] . unique ( ) , data [ 'extended filename' ] . unique ( ) ) : rate , wavs [ i ] = wavfile . read ( j ) assert wavs [ i ] . ndim == 1 , f'{j} is not formatted in mono.' logging . info ( "File: {}\tlength: {}\tsampling rate: {}" . format ( j , len ( wavs [ i ] ) , rate ) ) if 'utterance-id' in data : for _ , row in data . iterrows ( ) : ret . append ( [ row [ 'utterance-id' ] , wavs [ row [ 'recording-id' ] ] [ int ( float ( row [ 'start' ] ) * rate ) : int ( float ( row [ 'end' ] ) * rate ) ] ] ) return ( rate , pd . DataFrame ( ret , columns = [ 'utterance-id' , 'signal' ] ) ) else : for _ , row in data . iterrows ( ) : ret . append ( [ row [ 'recording-id' ] , wavs [ row [ 'recording-id' ] ] ] ) return ( rate , pd . DataFrame ( ret , columns = [ 'recording-id' , 'signal' ] ) )
Reads audio signals from a pd.DataFrame containing the directories of
.wav files, and optionally start and end points within the .wav files.
Reads audio signals from a pd . DataFrame containing the directories of . wav files and optionally start and end points within the . wav files .
'''Reads audio signals from a pd.DataFrame containing the directories of
    .wav files, and optionally start and end points within the .wav files. 

    Args:
        data: A pd.DataFrame created by prep_data().

    Returns:
        A pd.DataFrame with columns 'recording-id' and 'signal', or if segments were provided
        'utterance-id' and 'signal'. The 'signal' column contains audio as np.ndarrays.

    Raises:
        AssertionError: If a wav file is not 16k mono.
    ''' #assert rate == 16000 and wavs[i].ndim == 1, f'{j} is not formatted in 16k mono.'
A pd.DataFrame with columns 'recording-id' and 'signal', or if segments were provided
'utterance-id' and 'signal'. The 'signal' column contains audio as np.ndarrays.
A pd . DataFrame with columns ' recording - id ' and ' signal ' or if segments were provided ' utterance - id ' and ' signal ' . The ' signal ' column contains audio as np . ndarrays .
If a wav file is not 16k mono.
If a wav file is not 16k mono .
AssertionError
data
pd.DataFrame
A pd.DataFrame created by prep_data().
A pd . DataFrame created by prep_data () .