durations = np.diff(onset_frame_indices)
        onset_times = onset_frame_indices / samples.samples_per_second
        onset_durations = durations / samples.samples_per_second

        annotations = []
        for onset_time, duration in zip(onset_times[:-1], onset_durations):
            annotations.append({
                'start_seconds': onset_time,
                'duration_seconds': duration,
                'tags': ['onset']
            })
        logger.info(f'Created {len(annotations)} onsets for {sound["id"]}')

        if not annotations:
            return

        self.client.create_annotations(sound['id'], *annotations)


if __name__ == '__main__':
    main(
        user_name='onset_bot',
        bucket_name='onset-bot',
        email='*****@*****.**',
        about_me='onset_bot.md',
        info_url=
        'https://librosa.github.io/librosa/generated/librosa.onset.onset_detect.html',
        listener_cls=OnsetListener,
        logger=logger)
Exemple #2
0
        # pack the chroma data and create the resources
        binary_data = BinaryData(chroma)
        sound_id = self._sound_id_from_uri(annotation['sound'])

        # push output to s3
        data_url = self.s3_client.put_object(
            sound_id, binary_data.packed_file_like_object(),
            'application/octet-stream')

        logger.info(f'pushed binary data to {data_url}')

        # create annotation
        self.client.create_annotations(
            sound_id, {
                'start_seconds': annotation['start_seconds'],
                'duration_seconds': annotation['duration_seconds'],
                'data_url': data_url
            })
        logger.info('created annotation')


if __name__ == '__main__':
    main(user_name='chroma_bot',
         bucket_name='chroma-bot',
         email='*****@*****.**',
         about_me='chroma_bot.md',
         info_url='https://en.wikipedia.org/wiki/Chroma_feature',
         listener_cls=ChromaListener,
         logger=logger)
Exemple #3
0
        # processing pipeline to compute spectrograms
        samples = zounds.AudioSamples.from_file(raw_audio)

        binary_data = self._process_samples(samples)

        # push output to s3
        data_url = self.s3_client.put_object(
            sound['id'], binary_data.packed_file_like_object(),
            'application/octet-stream')
        logger.info(f'pushed binary data to {data_url}')

        # create annotation
        self.client.create_annotations(
            sound['id'], {
                'start_seconds': 0,
                'duration_seconds': sound['duration_seconds'],
                'data_url': data_url
            })
        logger.info('created annotation')


if __name__ == '__main__':
    main(user_name='stft_bot',
         bucket_name='stft-bot',
         email='*****@*****.**',
         about_me='stft_bot.md',
         info_url='https://en.wikipedia.org/wiki/Short-time_Fourier_transform',
         listener_cls=FFTListener,
         logger=logger)
        raw_audio = BytesIO(resp.content)

        # processing pipeline to compute spectrograms
        samples = zounds.AudioSamples.from_file(raw_audio).mono
        binary_data = self._process_samples(samples)

        # push output to s3
        data_url = self.s3_client.put_object(
            sound['id'], binary_data.packed_file_like_object(),
            'application/octet-stream')
        logger.info(f'pushed binary data to {data_url}')

        # create annotation
        self.client.create_annotations(
            sound['id'], {
                'start_seconds': 0,
                'duration_seconds': sound['duration_seconds'],
                'data_url': data_url
            })
        logger.info('created annotation')


if __name__ == '__main__':
    main(user_name='spectrogram_bot',
         bucket_name='spectrogram-bot',
         email='*****@*****.**',
         about_me='spectrogram_bot.md',
         info_url='https://en.wikipedia.org/wiki/Spectrogram',
         listener_cls=SpectrogramListener,
         logger=logger)
Exemple #5
0
                   zounds.IdentityDimension()]).astype(np.float32)

        # pack the chroma data and create the resources
        binary_data = BinaryData(mfcc)
        sound_id = self._sound_id_from_uri(annotation['sound'])

        # push output to s3
        data_url = self.s3_client.put_object(
            sound_id, binary_data.packed_file_like_object(),
            'application/octet-stream')
        logger.info(f'pushed binary data to {data_url}')

        # create annotation
        self.client.create_annotations(
            sound_id, {
                'start_seconds': annotation['start_seconds'],
                'duration_seconds': annotation['duration_seconds'],
                'data_url': data_url
            })
        logger.info('created annotation')


if __name__ == '__main__':
    main(user_name='mfcc_bot',
         bucket_name='mfcc-bot',
         email='*****@*****.**',
         about_me='mfcc_bot.md',
         info_url='https://en.wikipedia.org/wiki/Mel-frequency_cepstrum',
         listener_cls=MFCCListener,
         logger=logger)