How to use the pydub.playback.play function in pydub

To help you get started, we’ve selected a few pydub examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mikeyy / nonoCAPTCHA / test_speech.py View on Github external
def play_audio(mp3_filename):
    playback.play(AudioSegment.from_mp3(mp3_filename))
github joaoperfig / mikezart / source / musictheory.py View on Github external
def fitest():
    inst = filezart.getInfo()[2]
    a = getNote(inst, mnote(35))
    b = getNote(inst, mnote(60))
    play(a)
    play(b)
    n = AudioSegment.silent(3000)
    n = n.overlay(a)
    n = n.overlay(b)
    play(n)
github calpoly-csai / CSAI_Voice_Assistant / data_aug.py View on Github external
def test():
    generator = DataGenerator.from_file(sys.argv[1])
    while True:
        play(AudioSegment(next(generator), sample_width=SAMPLE_WIDTH,
                          frame_rate=SAMPLE_RATE, channels=NUM_CHANNELS))
github joaoperfig / mikezart / source / musictheory.py View on Github external
def fitest():
    inst = filezart.getInfo()[2]
    a = getNote(inst, mnote(35))
    b = getNote(inst, mnote(60))
    play(a)
    play(b)
    n = AudioSegment.silent(3000)
    n = n.overlay(a)
    n = n.overlay(b)
    play(n)
github richtier / alexa-voice-service-client / alexa_client / demo / streaming_microphone.py View on Github external
while True:
            directives = alexa_client.send_audio_file(
                input_buffer,
                dialog_request_id=dialog_request_id
            )
            stream.stop_stream()
            if directives:
                dialog_request_id = None
                print('Alexa\'s turn.')
                for directive in directives:
                    if directive.name == 'ExpectSpeech':
                        dialog_request_id = directive.dialog_request_id
                    if directive.name in ['Speak', 'Play']:
                        output_buffer = io.BytesIO(directive.audio_attachment)
                        track = AudioSegment.from_mp3(output_buffer)
                        play(track)
                input_buffer = io.BytesIO()
            stream.start_stream()
            print('Your turn. Say something.')
            time.sleep(1)
    finally:
        stream.stop_stream()
        stream.close()
        p.terminate()
github ariaaan / traffic-signs-detector / detector / detector.py View on Github external
def __notification_thread(self):
        while self.sound_notifications_lock:
            if len(self.__notification_queue) > 0:
                class_id = self.__notification_queue.pop()

                notification_path = os.path.join(self.__classes_sound_path, 'notification.mp3')
                notification_sound = AudioSegment.from_mp3(notification_path)

                play(notification_sound)

                class_sound_path = os.path.join(self.__classes_sound_path, str(class_id) + '.mp3')
                class_name_sound = AudioSegment.from_mp3(class_sound_path)

                play(class_name_sound)
github joaoperfig / mikezart / source / musictheory.py View on Github external
def poop():
    piano = filezart.getInfo()[3]
    for i in listNotes(piano):
        play(getNote(piano, i))
github joaoperfig / mikezart / source / musictheory.py View on Github external
v1.autoProg(prog, 4, 4)
    v2.autoProg(prog, 4, 4)
    
    print(s)
    print(prog)
    print(v1)
    print(v1._progs)
    print(v2)
    print(v2._progs)    
    
    #play(v1._progs[0].getAudio(instg, 120))
    #play(v2._progs[0].getAudio(inst, 120))
    
    sampleCProg(prog)
    
    play((v1._progs[0].getAudio(instg, 120)).overlay(v2._progs[0].getAudio(inst, 120)-15))
github joaoperfig / mikezart / source / musictheory.py View on Github external
def sampleCProg(cprog, inst = filezart.getInfo()[2]):
    audio = AudioSegment.silent((len(cprog)*1000) + 3000)
    t = 0
    for chord in cprog:
        audio = audio.overlay(chord.sampleAudio(inst), t)
        t = t + 1000
    play(audio)