Last active
May 19, 2016 02:12
-
-
Save IuryAlves/d3c28a5d5acd0a923e9d946ff9ffacd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
""" | |
Instale: | |
pip install sounddevice | |
pip install soundfile | |
baixe esse arquivo de audio e renomeie para: audio.ogg | |
https://upload.wikimedia.org/wikipedia/en/9/9f/Sample_of_%22Another_Day_in_Paradise%22.ogg | |
""" | |
import sounddevice as sd | |
import soundfile as sf | |
# todos dispositivos de audio | |
devices = sd.query_devices(kind='output') | |
# abre um arquivo de audio | |
data, fs = sf.read('audio.ogg', dtype='float32') | |
# pulse audio on my system | |
selected_device = devices[6]['name'].encode("utf-8") | |
# toca o audio | |
# device precisa ser uma string, com unicode não funciona. | |
sd.play(data, blocking=True, device=selected_device) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment