<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=ISO-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 11.00.9600.16521"></HEAD>
<BODY bgColor=#ffffff text=#000000>
<DIV><FONT size=2 face=Arial>OK, quick test, and, thanks!</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Just got it to start recording, while, using
sound_lib loaded a prior recording into a FileStream, and let it play back while
the new recording was taking place, then called finrecord(), loaded new
recording clip into another stream, and you could hear the whole thing
operating/cooperating, etc. etc.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>In other words, perfect!</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial><smile></FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT><FONT size=2 face=Arial></FONT><BR>Jacob
Kruger<BR>Blind Biker<BR>Skype: BlindZA<BR>"Roger Wilco wants to welcome
you...to the space janitor's closet..."<BR></DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; PADDING-RIGHT: 0px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=mc@mclaveau.com href="mailto:mc@mclaveau">mc@mclaveau</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=python-win32@python.org
href="mailto:python-win32@python.org">python-win32@python.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, 18 March, 2014 7:55
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [python-win32] Simple audio
recording</DIV>
<DIV><BR></DIV>
<DIV class=moz-cite-prefix>Hi!<BR><BR>The exampl below run OK on my Win.7 with
Python 2.7 + pywin32.<BR><BR>@+<BR>
<DIV class=moz-signature>-- <BR><IMG
src="cid:586F05C21BE14180A673BFBD0BF7B7B1@JakePC"></DIV><BR>
<HR SIZE=2 width="100%">
# -*- coding: utf-8 -*-<BR><BR>import time,os<BR>from ctypes import windll,
c_buffer<BR><BR>class mci:<BR><BR> def
__init__(self):<BR>
self.w32mci =
windll.winmm.mciSendStringA<BR>
self.w32mcierror = windll.winmm.mciGetErrorStringA<BR><BR>
def send(self,commande):<BR>
buffer = c_buffer(255)<BR>
errorcode =
self.w32mci(str(commande),buffer,254,0)<BR><BR>
if errorcode: # There was an
error<BR>
return errorcode,
self.get_error(errorcode)<BR>
else: # commande
returned
0<BR> return
errorcode,buffer.value<BR><BR> def
get_error(self,error):<BR> """Given
an error code, will return a description of the
error."""<BR> error =
int(error)<BR> buffer =
c_buffer(255)<BR>
self.w32mcierror(error,buffer,254)<BR>
return buffer.value<BR><BR> def directsend(self,
txt):<BR>
(err,buf)=self.send(txt)<BR> if err
!= 0:<BR>
print'Erreur',str(err),'sur',txt,':',buf<BR>
return (err,buf)<BR><BR> def
record(self):<BR>
print"Record"<BR>
self.directsend('open new type waveaudio alias
toto')<BR> self.directsend('Set toto
time format milliseconds')<BR>
self.directsend('set toto bitspersample 8') # 8 bits ou 16
bits<BR> self.directsend('set toto
samplespersec 11025') # 11025 low
quality 22050 medium quality 44100 high quality
(CD)<BR> self.directsend('set toto
channels 1') # 1 mono 2
stereo<BR><BR>
self.directsend('record toto')<BR>
time.sleep(0.1)<BR><BR> def finrecord(self,
nomfichier):<BR>
self.directsend('stop toto')<BR>
self.directsend('save toto
'+nomfichier)<BR>
self.directsend('close toto')<BR>
#self.directsend('delete toto')<BR><BR> def play(self,
nomfichier):<BR>
self.directsend('open "'+nomfichier+'" alias
toto')<BR> self.directsend('set toto
time format milliseconds')<BR>
err,duree=self.directsend('status toto length
')<BR> self.directsend('play toto
from 0 to '+str(duree))<BR>
time.sleep(float(duree)/1000.0)<BR>
self.directsend('stop toto')<BR>
self.directsend('close toto')<BR><BR>if
__name__=='__main__':<BR>
message=mci()<BR> message.record()<BR> for
i in xrange(4):<BR>
time.sleep(1)<BR> print
4-i<BR> print "Fin"<BR>
message.finrecord(os.getcwd()+"\\test.wav")<BR>
<HR SIZE=2 width="100%">
<BR><BR><BR>Le 18.03.14 06:14, Jacob Kruger a écrit :<BR></DIV>
<BLOCKQUOTE cite=mid:887F4F9C6A374B0D9004C5CFA7BD3779@JakePC type="cite">
<META name=GENERATOR content="MSHTML 11.00.9600.16521">
<STYLE></STYLE>
<DIV><FONT size=2 face=Arial>Am playing around with a bit of a personal
assistant app, that includes letting people record smallish audio
notes/sound clips, etc., and am currently using pyAudio to handle recording
- relatively simple/easy, etc., but, one small issue seems to be that if I
use something like winsound to beep just before start recording, to sort of
notify user that recording is about to start, this seems to possibly cause
input/output stream issues.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>In other words, possible to avoid/work around,
but, just wondering what guys would recommend looking into for simple little
bits of audio recording of sound clips, etc.?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2 face=Arial>TIA</FONT></DIV>
<DIV><FONT size=2 face=Arial><BR>Jacob Kruger<BR>Blind Biker<BR>Skype:
BlindZA<BR>"Roger Wilco wants to welcome you...to the space janitor's
closet..."<BR></FONT></DIV><BR>
<FIELDSET class=mimeAttachmentHeader></FIELDSET> <BR><PRE wrap="">_______________________________________________
python-win32 mailing list
<A class=moz-txt-link-abbreviated href="mailto:python-win32@python.org">python-win32@python.org</A>
<A class=moz-txt-link-freetext href="https://mail.python.org/mailman/listinfo/python-win32">https://mail.python.org/mailman/listinfo/python-win32</A>
</PRE></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>python-win32 mailing
list<BR>python-win32@python.org<BR>https://mail.python.org/mailman/listinfo/python-win32<BR></BLOCKQUOTE></BODY></HTML>