Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] pyaudio error in inline script

edited April 2014 in OpenSesame

HI all,
Can you help me correct my experiment?
I'm getting the following message when my experiment runs.

Error while executing inline script
phase: run
item: _inline_script
line: 442
exception message: 
exception type: IOError

Traceback (also in debug window):
  File "dist\libopensesame\inline_script.py", line 154, in run
  File "", line 45, in 
  File "pyaudio.pyo", line 747, in open
  File "pyaudio.pyo", line 442, in __init__
IOError: [Errno Device unavailable] -9985

I dont know what the problem is.
Help Please!
Thanks.

Comments

  • edited 5:46AM

    According to the error message, you seem to be experiencing a problem in line 442 of an inline_script item called _inline_script. This problem originates from your use of the pyaudio module. It seems the device you are trying to use does not exist. These kind of things can happen e.g. when you use incorrect port numbers.

    Without further information we cannot provide any further help. Further information that would be useful is the specific inline_script (although with at least 442 lines, I hope a snippet of your code will suffice).

    Good luck!

  • edited April 2014

    Thank you for replying, Edwin
    This is the full inline_script that I used.

    """
    This example listens for a sound from the microphone.
    It has been adapted from:
    http://stackoverflow.com/questions/4160175/detect-tap-with-pyaudio-from-live-mic
    """
    
    # Measure the start of the response interval
    start_response_interval = self.time()
    
    import pyaudio
    
    TAP_THRESHOLD = 0.050
    FORMAT = pyaudio.paInt16 
    SHORT_NORMALIZE = (1.0/32768.0)
    CHANNELS = 2
    RATE = 44100  
    INPUT_BLOCK_TIME = 0.01
    INPUT_FRAMES_PER_BLOCK = int(RATE*INPUT_BLOCK_TIME)
    
    def get_rms( block ):
    
        """Get root mean square as a measure of loudness"""
    
        import struct
        import math 
    
        global SHORT_NORMALIZE
    
        count = len(block)/2
        format = "%dh" % (count)
        shorts = struct.unpack( format, block )
        sum_squares = 0.0
        for sample in shorts:
            n = sample * SHORT_NORMALIZE
            sum_squares += n*n
        return math.sqrt( sum_squares / count )
    
    # Open the mic
    stream = pyaudio.PyAudio().open(format = FORMAT,
        channels = CHANNELS,
        rate = RATE,
        input = True,
        input_device_index = 0,
        frames_per_buffer = INPUT_FRAMES_PER_BLOCK)
    
    # Listen until a sound has been detected
    while True:
        try:
            block = stream.read(INPUT_FRAMES_PER_BLOCK)
        except IOError, e:
            print e
        loudness = get_rms( block )
        if loudness > TAP_THRESHOLD:
            break
    
    self.experiment.set("response_time", self.time() - start_response_interval)
    self.experiment.set("loudness", loudness)
    
    # Close the mic
    stream.close()
    
    

    I'm still experiencing problems.
    Help please.
    Thanks guys!

  • edited April 2014

    Couple of questions:

    1) Is this the entire inline_script named "_inline_script"? Why did the previous error state an error in line 442? (clearly, this script is shorter: could it be that you have some leftover script in the unused items?)

    2) Are you sure there is a microphone attached? If yes: is the mic not accessed by any other piece of software? This seems to be a silly question, but your script looks fine, and your error indicates that there is no available device. So double-checking this is important!

    BTW: I just tested your code (using OpenSesame 2.8.0 on Ubuntu 12.04), and it runs fine. This means that it's likely not a problem with your script, but with your setup.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games