Popular recipes tagged "sample"http://code.activestate.com/recipes/tags/sample/2014-11-15T12:11:16-08:00ActiveState Code RecipesGuess a number 2 (the computer attempts to guess your number) (Python) 2014-11-15T12:11:16-08:00Benoithttp://code.activestate.com/recipes/users/4191135/http://code.activestate.com/recipes/578963-guess-a-number-2-the-computer-attempts-to-guess-yo/ <p style="color: grey"> Python recipe 578963 by <a href="/recipes/users/4191135/">Benoit</a> (<a href="/recipes/tags/ai/">ai</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/sample/">sample</a>). Revision 2. </p> <p>Guess a number was part 1 was Human trying to guess a random number between 1 and 100 in 10 tries. This time the computer is trying to guess. Simple program for beginner to learn very simple formula as a start to an algorithm for AI. And conditional choice. The program is not perfect, as it will not force a victory when the computer guessed right, neither it can control if you cheated or not. But this is not the goal here. </p> Not Quite So Simple QuickTime Player, Python Audio Capture. (Python) 2014-11-08T19:10:58-08:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578960-not-quite-so-simple-quicktime-player-python-audio-/ <p style="color: grey"> Python recipe 578960 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/apple/">apple</a>, <a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/audio_capture/">audio_capture</a>, <a href="/recipes/tags/capture/">capture</a>, <a href="/recipes/tags/macbook_pro/">macbook_pro</a>, <a href="/recipes/tags/maccbook_pro/">maccbook_pro</a>, <a href="/recipes/tags/sample/">sample</a>, <a href="/recipes/tags/signal_capture/">signal_capture</a>). </p> <p>Not Quite So Simple QuickTime Player, Python Audio Capture.</p> <p>This DEMO code captures a function to generate a user 5 second Audio sample in Apple *.aifc format. It is then converted to DC quailty *.WAV format.</p> <p>It uses default shell system files to do the task.</p> <p>An AppleScript is created to do the sample but due to the limitations of QT Player there is a 1.5 second delay to allow QuickTine Player to start up. It is not entirely quiet but unobtrusive enough as to be like quiet mode...</p> <p>This is again a means a signal capture for an AudioScope without the need for special tools or installs.</p> <p>Read the code for more information.</p> <p>IMPORTANT!!! This DEMO WILL delete all *.aifc files inside the default $HOME/Movies directory, so be aware.</p> <p>A simple ALSA one is on its way too...</p> <p>It actually works on Python 3.4.1 but I have no idea if it works below Python 2.5.6...</p> <p>Bazza...</p> Guess a number (Python) 2014-11-15T09:06:05-08:00Benoithttp://code.activestate.com/recipes/users/4191135/http://code.activestate.com/recipes/578962-guess-a-number/ <p style="color: grey"> Python recipe 578962 by <a href="/recipes/users/4191135/">Benoit</a> (<a href="/recipes/tags/function/">function</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/sample/">sample</a>). </p> <p>This is just a little game to explain some very basic function in Python for beginner. RANDOM, Loop, Try and except... </p> Simple Audio Capture For Windows... (Python) 2014-10-17T14:39:16-07:00Barry Walkerhttp://code.activestate.com/recipes/users/4177147/http://code.activestate.com/recipes/578952-simple-audio-capture-for-windows/ <p style="color: grey"> Python recipe 578952 by <a href="/recipes/users/4177147/">Barry Walker</a> (<a href="/recipes/tags/audio/">audio</a>, <a href="/recipes/tags/audio_capture/">audio_capture</a>, <a href="/recipes/tags/capture/">capture</a>, <a href="/recipes/tags/sample/">sample</a>, <a href="/recipes/tags/signal_capture/">signal_capture</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>This snippet will capture from approximately 1 second to nearly 10000 hours of audio silently using Windows SoundRecorder.exe and save automatically to a file named SAMPLE.WAV in the C:\Windows\Temp\ folder/drawer/directory. It is 16 bit signed integer depth, stereo and sampled at 44100 Hz. This is for Python 2.0.1 to 3.3.2, (my latest version).</p> <p>Enjoy finding simple solutions to very difficult problems...</p> <p>(An OSX version is on its way too...)</p> <p>Bazza...</p>