¡Hola chicos! Estoy tratando de abrir un canal para grabar algo con mycrophone en google colab pero tengo un error.
OSError: [Errno -9996] Invalid input device (no default output device)Si ejecuto el código en Spyder, ¡en Spyder funciona! ¿Alguna idea de cómo habilitar Google Colabs para ver " mi micrófono predeterminado? El código es:
import pyaudio import wave from array import array import struct import time # Initialize variables RATE = 24414 CHUNK = 512 RECORD_SECONDS = 7.1 FORMAT = pyaudio.paInt32 CHANNELS = 1 WAVE_OUTPUT_FILE = "/content/drive/My Drive/Colab Notebooks/output.wav" # Open an input channel p = pyaudio.PyAudio() stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, frames_per_buffer=CHUNK) # Initialize a non-silent signals array to state "True" in the first 'while' iteration. data = array('h', np.random.randint(size = 512, low = 0, high = 500)) # SESSION START print("** session started") total_predictions = [] # A list for all predictions in the session. tic = time.perf_counter() while is_silent(data) == False: print("* recording...") frames = [] data = np.nan # Reset 'data' variable. timesteps = int(RATE / CHUNK * RECORD_SECONDS) # => 339 # Insert frames to 'output.wav'. for i in range(0, timesteps): data = array('l', stream.read(CHUNK)) frames.append(data) wf = wave.open(WAVE_OUTPUT_FILE, 'wb') wf.setnchannels(CHANNELS) wf.setsampwidth(p.get_sample_size(FORMAT)) wf.setframerate(RATE) wf.writeframes(b''.join(frames)) print("* done recording")