Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way to access a a computers microphone in Python?

I need to get some numbers so I can generate random numbers using ambient sound.

I want something on this level pseudo code:

import microphone
p = pitch.get()
print p

Edit:

This is in Windows 7, BTW

like image 816
rectangletangle Avatar asked Jul 10 '10 04:07

rectangletangle


People also ask

How to program a microphone in Python?

Let’s get started. To work with the microphone or audio input device in your Python program, you have to enter the device name or index to specify which device you want to use. To find the mic device attached to your computer you will need to have the following packages installed on your python.

How to find all the microphone names and device index in Python?

To know your device index follow the tutorial: Find all the microphone names and device index in Python using PyAudio To recognize input from the microphone you have to use a recognizer class. Let’s just create one. So our program will be like this till now:

How to take voice input from the user in Python?

Take voice input from the user in Python using PyAudio – speech_recognizer. What we gonna do in simple steps: Take input from the mic. Convert the voice or speech to text. Store the text in a variable/or you can directly take it as user input.

Is there a way to capture sound in Python?

For windows, we have PyAudio and there is also a library called SoundAnalyse. I found an example for Linux here: #!/usr/bin/python ## This is an example of a simple sound capture script.


1 Answers

Depends on the platform. On Windows, this SO question has some answers; for Linux, try this one instead.

like image 149
Alex Martelli Avatar answered Nov 05 '22 08:11

Alex Martelli