HydrogenAudio

Lossy Audio Compression => Speech Codecs => Topic started by: zima on 2005-06-06 15:33:22

Title: Automatic recording
Post by: zima on 2005-06-06 15:33:22
OK, this is a weird one I admit...

My sister has a very pesky speaking bird (uhmm...don't know English name, search for "gwarek" on google image search) that...well...doesn't speak almost (probably...) at all. Almost...unfortunatelly :/
And he especially doesn't speak when someobody's in room, etc
So: she has the idea to record it (she claims that once the bird speaks, he speaks almost perfectly...oh well, some imagination probably)

Here's the idea: I'll donate my very old laptop (with win95...) to the cause...unfortunatelly it has very small HDD, so speex would be great I guess (voice activated recording - perfect). Since this is my dumb sister and I'm not living with family anymore, it would be preferable if the thing started automatically with win and reamained...well, not in front will be enough I guess (but it's not necessesity; if she claims she trained the bird, I hope I can train her...)

Any ideas?
Title: Automatic recording
Post by: zima on 2005-06-11 11:55:28
OK, I've found something: Sound Snooper, quite perfect for the job. Unfortunatelly, although I did install illiminable codecs, Speex doesn't appear on the list, and the other are totally alien for me. So I'll list them and I ask you for help in choosing one that will have good sound quality and at the same time smallest possible size. What's worse it seems I'm quite limited in choosing kbps, bits per channel, and frequency in this app (I'll also list what's available)...

ACELP.net  11kHz, mono, 1kb/s (?!)
CCITT A-Law  11kHz, 8bits, mono, 10kb/s
CCITT U-Law  as above
GSM 6.10  11kHz, mono, 2kb/s (?!)
IMA ADPCM  this one has 4bits...so terrible I think
Microsoft ADPCM  as above
Microsoft G.723.1  8kHz, mono,  6400 & 5333 bit/s, 0 kb/s (?!)
Windows Media Audio V1  10kbps, 11KHz, mono, 1kb/s (?!)
Windows Media Audio V2  as above

(main reason I'm asking instead on trying - I have no microphone, and I'd like to finish at my sisters place as quick as possible when I'll ride there one day)

Or is there any way to use Speex? (Sound snooper says in help file "Sound Snooper can save records in different formats that are supported by ACM (Windows Audio Compression Manager).")
Title: Automatic recording
Post by: Brink on 2005-06-11 21:46:38
You can try to use liveincode, and record the bird speaking directly to speex files.
Title: Automatic recording
Post by: rutra80 on 2005-06-11 21:47:39
Speex has 2 nice options --VAD (Voice Activity Detection) and --DTX (file-based discontinuous transmission), thanks to them you can save a lot of disk space. Lately I recorded 24 hours in speex format and it took about 120MB IIRC (the room was empty for 23 hours and for 1 hour there was those thiefs speaking  ).
I used foobar2000's Record function with following Speexenc command-line in Diskwriter:
--quality 10 --vbr --vad --dtx --nframes 10 --comp 10 --denoise --agc - %d
I think I've set sample rate to 8000Hz, bits per sample to 16, and channels to 1.
I used very crappy microphone but the effect was more than good enough.
Title: Automatic recording
Post by: zima on 2005-06-15 18:20:25
Is Speexenc the standard form the speex site?

(and I seem to remember that I've read somewhere that the official one doesn't have yet VAD...so is there some special one I'd have to download?)
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-15 18:31:59
Quote
Is Speexenc the standard form the speex site?

(and I seem to remember that I've read somewhere that the official one doesn't have yet VAD...so is there some special one I'd have to download?)
[{POST_SNAPBACK}][/a] (http://index.php?act=findpost&pid=306402")

I think it's had VAD in for a long time, but why not use latest unstable version? (Found e.g. on  [a href="http://rarewares.org/others.html]RareWares[/url].) I don't know why there's a "stable" and an "unstable" branch, unstable has been working without any problems for me....
Title: Automatic recording
Post by: zima on 2005-06-16 17:00:03
Quote
Speex has 2 nice options --VAD (Voice Activity Detection) and --DTX (file-based discontinuous transmission), thanks to them you can save a lot of disk space. Lately I recorded 24 hours in speex format and it took about 120MB IIRC (the room was empty for 23 hours and for 1 hour there was those thiefs speaking  ).
I used foobar2000's Record function with following Speexenc command-line in Diskwriter:
--quality 10 --vbr --vad --dtx --nframes 10 --comp 10 --denoise --agc - %d
I think I've set sample rate to 8000Hz, bits per sample to 16, and channels to 1.
I used very crappy microphone but the effect was more than good enough.
[a href="index.php?act=findpost&pid=305380"][{POST_SNAPBACK}][/a]


Is this possible in fully automatic fashion? (so foobar will start recording right after startup by link in autostart, all by itself)
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-16 17:48:51
Quote
Is this possible in fully automatic fashion? (so foobar will start recording right after startup by link in autostart, all by itself)
[{POST_SNAPBACK}][/a] (http://index.php?act=findpost&pid=306574")

You could probably make a batchfile with command line options and put a link to it in autostart. Or Scheduled Tasks, run at startup. Find foobars command line options by running "your path to foobar"\foobar2000.exe /? in CMD. (You can also search on forum for how to access menu or context menu options by way of commandline).

Another option is to use Case's piperec (preferably the version where Preuss fixed the CPU hog bug), put speexenc.exe and piperec.exe somewhere in %PATH% and make a batchfile like e.g.
Code: [Select]
@echo off
title record speex from recording device
piperec 16000 16 1 | speexenc --quality 8 --vbr --vad --dtx --nframes 10 --comp 10 --denoise --agc - - > "C:\My Recordings\test.spx"

And just have the batchfile autostart at startup. This is a fully commandline solution, and quite simple. To stop recording, bring the CMD window in focus and hit CTRL+C.

[a href="http://www.hydrogenaudio.org/forums/index.php?showtopic=33453&view=findpost&p=292439]link 1[/url], link 2 (http://www.hydrogenaudio.org/forums/index.php?showtopic=34787&view=findpost&p=305756), link 3 (http://www.hydrogenaudio.org/forums/index.php?showtopic=34832&view=findpost&p=306143), link 4 (http://www.hydrogenaudio.org/forums/index.php?showtopic=34731&view=findpost&p=305363)

EDIT:
You shouldn't take anyones word for what's best wav input samplerate/bitdepth/channels or best switches for speexenc. Experiment, and see what fits best in regards to filesize/quality for your use. Switches can be found by running speexenc -h in CMD.
Title: Automatic recording
Post by: zima on 2005-06-16 18:23:02
Thank you for quick reply.

I wonder...does the command line options in foobar allow automatic recording, when doing it manually requires choosing menu options form tool window inside foobar, clicking ok, choosing path, etc.? I can't quite find anything that would suggest it... 
(The real issue probably is that I'm totally ignorant when it comes to command line, batch files, etc. - although I am cosnidered by few as "advanced" and such crap, the thuth is: only in GUI, and probably only bacause I don't afraid it, not because I  know everything...I started serious adventure with classic macs, then moved directly to windows...)

Also, another thing: I don't have means to check it (public computer at uni), but I assume that use of piperec will cause a command line window to appear whole the time...as I mentioned above, the less things the user of this solution will be able to do wrong, the better (so it's preferable if it'll be fully automatic & hidden...). or perhaps it's possible to hide this window?

Thanks again for help.
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-16 18:39:39
Quote
I wonder...does the command line options in foobar allow automatic recording, when doing it manually requires choosing menu options form tool window inside foobar, clicking ok, choosing path, etc.? I can't quite find anything that would suggest it... 
[{POST_SNAPBACK}][/a] (http://index.php?act=findpost&pid=306596")

All settings in foobar would have had to be set beforehand, I guess. I haven't tried if this can actually work. Maybe not. So I think piperec solution would be better for you.

Quote
Also, another thing: I don't have means to check it (public computer at uni), but I assume that use of piperec will cause a command line window to appear whole the time...as I mentioned above, the less things the user of this solution will be able to do wrong, the better (so it's preferable if it'll be fully automatic & hidden...). or perhaps it's possible to hide this window?
[a href="index.php?act=findpost&pid=306596"][{POST_SNAPBACK}][/a]

Check [a href="http://www.hydrogenaudio.org/forums/index.php?showtopic=34760&view=findpost&p=306118]this[/url].
EDIT: Alternative is to make a shortcut to the batchfile and choose in the Properties of the shortcut to start up minimized (and drag shortcut into Startup folder). This way it will still show up on Taskbar, but that gives you an opportunity to maximize window to stop recording if desired (not sure if first option allows for that, or if you will just continue recording until you shutdown system).

You can easily learn enough 'bout commandline and batchfiles to get something like this going.... 
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-17 01:12:44
Take care that if restarting machine like this it will start recording, overwriting any existing file. The best ting here would be to have the setup not overwriting existing file, but auto append a number to the filename or something (e.g. date & time), like if you have it write to a file recording.spx, if a file of that name already exists it doesn't overwrite it, but creates a new file recording_1.spx, then recording_2.spx, and so on. However, I hardly think something like that is possible within the framework of a simple batchfile. I guess it would take some more advanced scripting, or the addition of some program of which I don't know the existence of to the setup to achieve something like that.... It's beyond me, I'm afraid.... Maybe someone else have a suggestion?
Title: Automatic recording
Post by: ChiGung on 2005-06-17 01:44:43
Quote
Maybe someone else have a suggestion?


Code: [Select]
piperec 16000 16 1 | speexenc --quality 8 --vbr --vad --dtx --nframes 10 --comp 10 --denoise --agc - - > "C:\My Recordings\earwig%TIME%.spx"


i think you can add %time% to the filename...

maybe not if the times format messes up the filename,

oh yeah this is it,
%random%%random%

Code: [Select]
piperec 16000 16 1 | speexenc --quality 8 --vbr --vad --dtx --nframes 10 --comp 10 --denoise --agc - - > "C:\My Recordings\earwig%random%%random%.spx"


That makes it ~usualy not overwrite a previous file~
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-17 07:25:05
Quote
That makes it ~usualy not overwrite a previous file~
[a href="index.php?act=findpost&pid=306684"][{POST_SNAPBACK}][/a]

Super  !
I guess it would take a lot of trial to get %random%%random% to produce the same number twice, so I guess it's quite safe

(If one where paranoid one could do somename%random%%random%%random%%random%.spx)
Title: Automatic recording
Post by: zima on 2005-06-17 10:08:26
Awesome guys! Thank you very much for the help. It seems I'm all set (now I just have to download all files & instructions on cdr (uni) and hope I'll be able to do it all  )
Title: Automatic recording
Post by: zima on 2005-06-17 16:01:56
One problem with piperec: the archive with version that doesn't hog cpu is apparently broken...
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-17 16:12:54
Quote
One problem with piperec: the archive with version that doesn't hog cpu is apparently broken...
[a href="index.php?act=findpost&pid=306774"][{POST_SNAPBACK}][/a]

It works OK here. Try to empty all cache, tempdirs, downloads and restart browser, then try again. (If you absolutely can't make it work PM me an e-mail adress I can send it to).

EDIT: BTW. The fixed version in the package are named piperec_fix.exe, piperec.exe are the original. Difference in size are due to UPX compression of original.
Title: Automatic recording
Post by: ChiGung on 2005-06-17 17:07:27
Quote
Quote
That makes it ~usualy not overwrite a previous file~
Super  !
I guess it would take a lot of trial to get %random%%random% to produce the same number twice, so I guess it's quite safe

(If one where paranoid one could do somename%random%%random%%random%%random%.spx)

Heh, ive already been kinda paranoid, because %random% returns a four digit number ( on my system anyway), but odds can be deceptive and after a modest number of saves I think even 9999:1 gets a little risky.

Nice automatic recording setup here though. I did this with linco.exe and lame before, but had to run lame in high priority to stop dropouts - thats something to look out for.

A Low vbr lame command line could be,

Code: [Select]
start /high /min piperec 22050 16 1 | lame -r --bitwidth 16 -s 22.05 -V9 -m m --resample 22 -B64 --lowpass-width 3 -q 5 - "C:\My Recordings\Learwig%random%%random%.mp3"


I havent used speex, but dont like it when I get a phone connection which compresses the ambient noise out - so the line goes totaly silent when no ones speaking.

[span style='font-size:7pt;line-height:100%']edit:fixed one bug in commandline[/span]
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-17 17:35:08
Quote
Heh, ive already been kinda paranoid, because %random% returns a four digit number ( on my system anyway), but odds can be deceptive and after a modest number of saves I think even 9999:1 gets a little risky.
[a href="index.php?act=findpost&pid=306781"][{POST_SNAPBACK}][/a]

I know.  I was kinda joking. Well, putting in 4 %randoms%'s produce an 18-20 number digit, which should satisfy even the hyper hyper paranoid.....
Thank you, BTW!

Quote
Code: [Select]
start /high /min piperec 22000 16 1 | lame -r --bitwidth 16 -s 22.05 -V9 -m m --resample 22 -B64 --lowpass-width 3 -q 5 - "C:\My Recordings\Learwig%random%%random%.mp3"

[a href="index.php?act=findpost&pid=306781"][{POST_SNAPBACK}][/a]

Eh, shouldn't that be ... piperec 22050 16 1 ... ?

Quote
I havent used speex, but dont like it when I get a phone connection which compresses the ambient noise out - so the line goes totaly silent when no ones speaking.
[a href="index.php?act=findpost&pid=306781"][{POST_SNAPBACK}][/a]

Speex is quite nice for it's use. And you can get plenty of continual annoying background noise if you want, just drop --denoise and such, play around with the switches......
Title: Automatic recording
Post by: ChiGung on 2005-06-17 17:48:50
Quote
Eh, shouldn't that be ... piperec 22050 16 1 ... ?

Good catch
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-17 18:19:26
Actually, it doesn't like start /high /min piperec etc....

My PC starts beeping as mad.

But if you put piperec 22000 16 1 | lame -r --bitwidth 16 -s 22.05 -V9 -m m --resample 22 -B64 --lowpass-width 3 -q 5 - "C:\My Recordings\Learwig%random%%random%.mp3" in a mp3rec.bat on the other hand, and start it from CMD thus:
start /high /min mp3rec.bat
it starts just fine.....

That Lame commandline produces a file that playbacks as pure static at my place, though.... 

Doing it with my Speex batch file, though, produces a good file
start /high /min spxrec.bat

And it was same thing; putting start /high /min piperec (etc....) in the batchfile itself made my system protest like hell....
Title: Automatic recording
Post by: ChiGung on 2005-06-17 18:33:32
Quote
Actually, it doesn't like start /high /min piperec etc....
My PC starts beeping as mad.

oh well 
Quote
That Lame commandline produces a file that playbacks as pure static at my place, though.... 

-x swaps the byte endianism, could fix the static, or maybe piperec wont do that samplerate.

new lame try:
Code: [Select]
piperec 22050 16 1 | lame -r -x --bitwidth 16 -s 22.05 --priority 3 -V9 -m m --resample 22 -B64 --lowpass-width 3 -q 5 - "C:\My Recordings\Learwig%random%%random%.mp3"


experimental, add --scale 0.1 --athaa-sensitivity 3 to encourage silence detection, while increasing sensitivity at reduced volume, could decrease bitrate, file needs reamplified at playback.
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-17 18:58:46
Quote
new lame try:
Code: [Select]
piperec 22050 16 1 | lame -r -x --bitwidth 16 -s 22.05 --priority 3 -V9 -m m --resample 22 -B64 --lowpass-width 3 -q 5 - "C:\My Recordings\Learwig%random%%random%.mp3"

[a href="index.php?act=findpost&pid=306801"][{POST_SNAPBACK}][/a]

That line produced a working file.

Adding --scale 0.1 --athaa-sensitivity 3 also produce a working file, but volume level are almost inaudible..... much preamp would be necessary for playback...
Title: Automatic recording
Post by: zima on 2005-06-18 11:33:10
Yep, something was wrong on the PC I've been using, it works fine on another one.

BTW, do I have to car about this "start /high /min" thing when using Speex?
Title: Automatic recording
Post by: ChiGung on 2005-06-18 14:18:16
Only if you notice jitters happening in the recordings - then raising the processes priorities might help.
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-18 15:25:57
Quote
Only if you notice jitters happening in the recordings - then raising the processes priorities might help.
[a href="index.php?act=findpost&pid=306989"][{POST_SNAPBACK}][/a]
In that case you can do as follows:

Make a spxrec.bat thus:
Code: [Select]
@echo off
title record speex from recording device
piperec 16000 16 1 | speexenc --quality 8 --vbr --vad --dtx --nframes 10 --comp 10 --denoise --agc - - > "C:\My Recordings\polly%random%%random%.spx"

and put it in your %PATH%. Then make a run.bat:
Code: [Select]
start /high /min spxrec.bat

Make a shortcut to run.bat. Open Properties of this shortcut and choose Run: Minimized, then drag that shortcut into your Startup folder. Now it should start spxrec.bat as a high priority thread, minimized to taskbar when Windows starts up.
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-18 16:18:43
Unfortunately, when checking closer, that seems to start only CMD.exe with high priority, while piperec.exe and speexenc.exe still runs at normal priority.... 
As posted above, adding start /high /min (http://www.robvanderwoude.com/index.html) in  the batchfile itself only achieved manic beeping from my PC, so then I don't know how to start speexenc.exe with high priority in this setup....
Title: Automatic recording
Post by: ChiGung on 2005-06-18 16:44:07
Yeh tricky that, but ive got you hacking ahead of yourself  Theres probably no problem with it at normal priority 
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-18 16:50:43
Quote
Yeh tricky that, but ive got you hacking ahead of yourself  Theres probably no problem with it at normal priority 
[a href="index.php?act=findpost&pid=307013"][{POST_SNAPBACK}][/a]

Yes. It's probably only stupid to do it unless you get dropouts or stuttering or such.... on a reasonably fast system this shouldn't happen. I was more thinking of zima whom I think said was going to use an old comp, in which case such things might occur.....
Title: Automatic recording
Post by: zima on 2005-06-20 15:55:59
OTOH...does this priority stuff works at all in win9x? Somehow I don't think so...
Title: Automatic recording
Post by: Mr_Rabid_Teddybear on 2005-06-20 18:09:21
Quote
OTOH...does this priority stuff works at all in win9x? Somehow I don't think so...
[{POST_SNAPBACK}][/a] (http://index.php?act=findpost&pid=307518")

I have no access to 9x, so you have to figure out what works and what don't yourself. Try some googleing. Experiment. One thing I'm pretty sure of is that the purely cosmetic "title" line I've added to my batchfile don't work. However, all it does are displaying the text after on the title bar.

I don't think you should care to much about priority, there's other things that's more important. I've been revising the Speex commandline that I basically just [a href="http://www.hydrogenaudio.org/forums/index.php?showtopic=34607&view=findpost&p=305380]copied[/url] off rutra80.
Quote
--quality 10 --vbr --vad --dtx --nframes 10 --comp 10 --denoise --agc - %d
I think I've set sample rate to 8000Hz, bits per sample to 16, and channels to 1.
I used very crappy microphone but the effect was more than good enough.
[{POST_SNAPBACK}][/a] (http://index.php?act=findpost&pid=305380")


First of all I think samplerate of 8000 give some very strange sounds on s and f's. I'll go for 16000 as good for speech (speex supports 8, 16 and 32 kHz). I'll also go for 16 bits as 8 bits gives some really ugly distortion on background noise (8 and 16 supported). Stereo are a total waste of bits for speech, so channels number 1; mono.

Speex options can be found [a href="http://www.speex.org/manual2/node5.html#SECTION00051000000000000000]here[/url].
I don't think its necessary, but I'll add -w for wideband (16 kHz) input. Options are -n, -w and -u (8, 16 and 32 kHz).

--quality 10 makes a file which averages at 38-40 kbps. Reducing to --quality 8 averages at 25-27 kbps, and sound quality is somewhat lower, but quite good. So this is a diskspace issue.

--vbr is a must for allocating bits intelligently. However;
Quote
VAD is always implicitly activated when encoding in VBR, so the option is only useful in non-VBR operation.

So one can remove --vad, it's on already.

--dtx
Quote
Discontinuous transmission is an addition to VAD/VBR operation, that allows to stop transmitting completely when the background noise is stationary. In file-based operation, since we cannot just stop writing to the file, only 5 bits are used for such frames (corresponding to 250 bps).

Very good for saving diskspace when nothing is happening.

--nframes. This is the documentaion I can find:
Quote
It is also possible to pack more that one frame in an Ogg packet (--nframes), reducing the overhead for low bit-rates.   

-nframes n
    Pack n frames in each Ogg packet (this saves space at low bit-rates)
    Number of frames per Ogg packet (1-10), default 1

I don't really understand if this is useful here. Keep it in if you want, I think I'll take it out. I'm really unsure here. Wish there was some more comprehensive documentation on this switch...

Now we come to CPU consumption. This is what complexity, --comp, is about:
Quote
With Speex, it is possible to vary the complexity allowed for the encoder. This is done by controlling how the search is performed with an integer ranging from 1 to 10 in a way that's similar to the -1 to -9 options to gzip and bzip2 compression utilities. For normal use, the noise level at complexity 1 is between 1 and 2 dB higher than at complexity 10, but the CPU requirements for complexity 10 is about 5 times higher than for complexity 1. In practice, the best trade-off is between complexity 2 and 4, though higher settings are often useful when encoding non-speech sounds like DTMF tones.

So this is a complexity vs. speed switch. The higher complexity the more CPU useage (speex default are 3). --comp 10 using 5 times as much CPU as --comp 1. So it might not be wise to use --comp 10 on an old 9x box.

--denoise
Quote
Denoise the input before encoding

Very good when recording from a cheap mic.

--agc
Quote
Apply adaptive gain control (AGC) before encoding

Also good when recording from cheap mic, I suppose. Keep it in.

Also adding -V (prints bitrate used to console), so you'll see some activity if you'll ever maximise the window...


So my revised line will be something like this, edit according to your needs:
Code: [Select]
piperec 16000 16 1 | speexenc -w --quality 8 --vbr --dtx --comp 4 --denoise --agc -V - - > "C:\My Recordings\polly%random%%random%.spx"



EDIT: BTW. One thing I forgot to mention; If you use ICL compiles from RareWares, don't forget to put libmmd.dll (http://www.rarewares.org/files/libmmd8.1.zip) in %PATH%.