Пример #1
0
def device_test():
    """Print some diagnostics about the underlying portaudio library and host audio support"""
    rates = [192, 250, 256, 300, 384, 441, 480, 500, 750, 768]

    def test_rates(rates):
        for r in rates:
            try:
                sounddevice.check_input_settings(samplerate=int(r*1000))
                print('\t%.1f kHz OK' % r)
            except sounddevice.PortAudioError:
                print('\t%.1f kHz not supported!' % r)

    print('sounddevice ' + sounddevice.__version__)
    print(sounddevice.get_portaudio_version()[1])
    print(sounddevice.query_devices())

    print('\n10x Time Expansion:')
    test_rates([r/10.0 for r in rates])
    print('\nRealtime:')
    test_rates(rates)
try:
    import sounddevice as sd
except Exception:
    raise DependencyError("sounddevice not working")
try:
    import soundfile as sf
except Exception:
    raise DependencyError("soundfile not working")

import numpy as np

travisCI = bool(str(os.environ.get('TRAVIS')).lower() == 'true')

logging.info("Loaded SoundDevice with {}".format(
    sd.get_portaudio_version()[1]))


def init(rate=44100, stereo=True, buffer=128):
    pass  # for compatibility with other backends


def getDevices(kind=None):
    """Returns a dict of dict of audio devices of specified `kind`

    The dict keys are names and items are dicts of properties
    """
    devs = {}
    if travisCI:  # travis-CI testing does not have a sound device
        return devs
    else:
Пример #3
0
<ul>
        <li>Python %s</li>
        <li>PyQt %s (Qt %s)</li>
        <li>Python-sounddevice %s (%s)</li>
        <li>Numpy %s</li>
        <li>Cython</li>
        <li>PyOpenGL %s</li>
</ul>
""" % (
    friture.__version__,
    friture.__releasedate__,
    "%d.%d" % (sys.version_info.major, sys.version_info.minor),
    QtCore.PYQT_VERSION_STR,
    QtCore.qVersion(),
    sounddevice.__version__,
    sounddevice.get_portaudio_version()[1],
    numpy.__version__,
    # Cython.__version__, #this pulls the whole Cython, makes PyInstaller think it needs all the dependencies, even IPython!
    OpenGL.__version__)


class About_Dialog(QtWidgets.QDialog):
    def __init__(self, parent, timer):
        super().__init__(parent)

        self.setObjectName("About_Dialog")
        self.resize(400, 300)
        self.setWindowTitle("About Friture")

        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images-src/window-icon.svg"),
Пример #4
0
from ._base import _SoundBase, HammingWindow

try:
    import sounddevice as sd
except Exception:
    raise DependencyError("sounddevice not working")
try:
    import soundfile as sf
except Exception:
    raise DependencyError("soundfile not working")

import numpy as np

travisCI = bool(str(os.environ.get('TRAVIS')).lower() == 'true')

logging.info("Loaded SoundDevice with {}".format(sd.get_portaudio_version()[1]))


def init(rate=44100, stereo=True, buffer=128):
    pass  # for compatibility with other backends


def getDevices(kind=None):
    """Returns a dict of dict of audio devices of specified `kind`

    The dict keys are names and items are dicts of properties
    """
    devs = {}
    if travisCI:  # travis-CI testing does not have a sound device
        return devs
    else:
Пример #5
0
from psychopy.tools import attributetools
from ._base import _SoundBase

from psychopy.constants import NOT_STARTED, PLAYING, PAUSED, STOPPED, FINISHED
from psychopy import logging
import sounddevice as sd
import soundfile as sf

import numpy as np

logging.console.setLevel(logging.INFO)

END=-1
streams = {}

print("using SoundDevice with {}".format(sd.get_portaudio_version()[1]))
startTime = time.time()

def init():
    pass  # for compatibility with other backends

class SoundStream(object):
    def __init__(self, sampleRate, channels, blockSize, duplex=False):
        # initialise thread
        self.streams = []
        self.list = []
        # sound stream info
        self.sampleRate = sampleRate
        self.channels = channels
        self.duplex = duplex
        self.blockSize = blockSize
Пример #6
0
from psychopy import logging, exceptions
from psychopy.constants import (PLAYING, PAUSED, FINISHED, STOPPED,
                                NOT_STARTED)
from psychopy.exceptions import SoundFormatError
from ._base import _SoundBase, HammingWindow

import sounddevice as sd
import soundfile as sf

import numpy as np

travisCI = bool(str(os.environ.get('TRAVIS')).lower() == 'true')
logging.console.setLevel(logging.INFO)

logging.info("Loaded SoundDevice with {}".format(sd.get_portaudio_version()[1]))


def init(rate=44100, stereo=True, buffer=128):
    pass  # for compatibility with other backends


def getDevices(kind=None):
    """Returns a dict of dict of audio devices of sepcified `kind`

    The dict keys are names and items are dicts of properties
    """
    devs = {}
    if travisCI:  # travis-CI testing does not have a sound device
        return devs
    else:
Пример #7
0
    ':sunglasses: :+1: :+1: :+1: **MS Rec made just for *you* ** :+1: :+1: :+1: :sunglasses:'
)
image = Image.open(r"/Users/yuxinzhu/.spyder-py3/StreamlitSD/logo1.png")
st.image(image, use_column_width=True)

################# TO CHECK MICROPHONE USED
import sounddevice as sd
print(sd.query_devices())
# My computer has two microphones, one built-in and one via USB, and I want to record using the USB mic.
# The Stream class has an input_device_index for selecting the device, but it's unclear how this index correlates to the devices.
# For example, how do I know which device index 0 refers to?
# You can use the code above to check!
# As you can see from below terminal output, when I put my headset to mic jack ,
# Index 1 is available as input. 1 Jack Mic (2 in, 0 out)
# While default laptop audio microphone comes up as index 2
print(sd.get_portaudio_version())
################################

import IPython.display as ipd
import soundfile as sf
from pydub import AudioSegment
from glob import glob
from scipy.io import wavfile as wav
import numpy as np
import IPython.display as ipd
from IPython.display import Audio
import pyaudio
import wave
import matplotlib.pyplot as plt
import librosa
from pathlib import Path
Пример #8
0
 def query_api_version(self):
     return sounddevice.get_portaudio_version()[1]
Пример #9
0
<ul>
        <li>Python %s</li>
        <li>PyQt %s (Qt %s)</li>
        <li>Python-sounddevice %s (%s)</li>
        <li>Numpy %s</li>
        <li>Cython</li>
        <li>PyOpenGL %s</li>
</ul>
""" % (friture.__version__,
       friture.__releasedate__,
       "%d.%d" % (sys.version_info.major, sys.version_info.minor),
       QtCore.PYQT_VERSION_STR,
       QtCore.qVersion(),
       sounddevice.__version__,
       sounddevice.get_portaudio_version()[1],
       numpy.__version__,
       #Cython.__version__, #this pulls the whole Cython, makes PyInstaller think it needs all the dependencies, even IPython!
       OpenGL.__version__)


class About_Dialog(QtWidgets.QDialog):

    def __init__(self, parent, logger, audiobackend, timer):
        super().__init__(parent)

        self.setObjectName("About_Dialog")
        self.resize(400, 300)
        self.setWindowTitle("About Friture")

        icon = QtGui.QIcon()
Пример #10
0
 def query_api_version(self) -> str:
     return sounddevice.get_portaudio_version()[1]  # type: ignore
Пример #11
0
def getVersion():
    return sounddevice.get_portaudio_version()
Пример #12
0
def main():
    print(sd.get_portaudio_version())
    #use cut name for first device
    # '1 - Acer T272HL (AMD High Defin' instead of '1 - Acer T272HL (AMD High Definition Audio Device)'
    connect_devices("Mikrofon (2- USB PnP Sound Devi",
                    "1 - Acer T272HL (AMD High Defin")
Пример #13
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb  4 14:33:36 2020

Tests for audio : portaudio and sounddevice

@author: crouzet-o
"""
"""
 PyAudio seems to dysfunction with Anaconda (but not tested with Debian Python)

"""

import pyaudio
#p = pyaudio.PyAudio()

import sounddevice as sd
import numpy as np

noise = np.random.normal(0, 1, 44100)
fs = 44100

sd.play(noise, fs)
sd.get_portaudio_version()

# Seem to work with alsa only
#import simpleaudio as sa
#play_obj = sa.play_buffer(noise, 1, 2, 44100)
#play_obj.wait_done()